void alock_lock(array_lock_t* local_lock) { lock_shared_t *lock = local_lock->shared_data; uint32_t slot = FAI_U32(&(lock->tail)) % lock->size; local_lock->my_index = slot; volatile uint16_t* flag = &lock->flags[slot].flag; while (*flag == 0) { PAUSE; } }
/* * explicitely subscribe to the list of threads in order to used timestamps for GC */ void ssmem_gc_thread_init(ssmem_allocator_t* a, int id) { a->ts = (ssmem_ts_t*) ssmem_ts_local; if (a->ts == NULL) { a->ts = (ssmem_ts_t*) memalign(CACHE_LINE_SIZE, sizeof(ssmem_ts_t)); assert (a->ts != NULL); ssmem_ts_local = a->ts; a->ts->id = id; a->ts->version = 0; do { a->ts->next = ssmem_ts_list; } while (CAS_U64((volatile uint64_t*) &ssmem_ts_list, (uint64_t) a->ts->next, (uint64_t) a->ts) != (uint64_t) a->ts->next); __attribute__ ((unused)) uint32_t null = FAI_U32(&ssmem_ts_list_len); } }