ObjType type;
void (*cleanup)(union drd_clientobj*);
ExeContext* first_observed_at;
- UInt initial_value; // Value assigned through sem_init().
+ UInt waits_to_skip; // Number of sem_wait() calls to skip
+ // (due to the value assigned by sem_init()).
UInt value; // Semaphore value.
UWord waiters; // Number of threads inside sem_wait().
DrdThreadId last_sem_post_tid; // Thread ID associated with last sem_post().
tl_assert(p->type == ClientSemaphore);
p->cleanup = (void(*)(DrdClientobj*))semaphore_cleanup;
- p->initial_value = 0;
+ p->waits_to_skip = 0;
p->value = 0;
p->waiters = 0;
p->last_sem_post_tid = DRD_INVALID_THREADID;
struct semaphore_info* semaphore_init(const Addr semaphore,
const Word pshared, const UInt value)
{
- /* unsigned n; */
struct semaphore_info* p;
Segment* sg;
- /* const DrdThreadId drd_tid = thread_get_running_tid(); */
if (s_trace_semaphore)
{
p = semaphore_get_or_allocate(semaphore);
}
tl_assert(p);
- p->initial_value = value;
+ p->waits_to_skip = value;
p->value = value;
return p;
}
}
p->value--;
tl_assert((int)p->value >= 0);
- if (p->initial_value > 0)
- p->initial_value--;
+ if (p->waits_to_skip > 0)
+ p->waits_to_skip--;
else
{
sg = segment_pop(p);