/* Unblock the first thread waiting on c, if extant */ void condition_signal(condition_t * c) { enter_critical(); ASSERT(disable_count); unblock_one( &c->wait_queue ); leave_critical(); }
static void lock_release_helper(lock_t * l){ ASSERT(disable_count); if (!unblock_one(&l->wait_queue)) { l->status = UNLOCKED; } l->held_task = NULL; }
/* TODO: Unblock the first thread waiting on c, if it exists */ void condition_signal(condition_t * c){ // disable int enter_critical(); // wake up unblock_one(&c->blocked); // enable int leave_critical(); }
/* Increment the semaphore value atomically */ void semaphore_up(semaphore_t * s) { enter_critical(); if(s->value < 1 && !queue_empty(&s->wait_queue)) unblock_one(&s->wait_queue); else s->value++; leave_critical(); }
static void lock_release_helper(lock_t * l) { ASSERT(disable_count); pcb_t *p = unblock_one(&l->wait_queue); if( p ) { p->waiting_for_lock = NULL; l->owner = p; } else { l->owner = NULL; } l->status = UNLOCKED; }
static void unblock_all(node_t * wait_queue){ while (is_empty(wait_queue)==0){ unblock_one(wait_queue); } }
/* TODO: Increment the semaphore value atomically */ void semaphore_up(semaphore_t * s){ enter_critical(); if(s->val++ == 0) unblock_one(&s->wait_queue); leave_critical(); }
/* TODO: Increment the semaphore value atomically */ void semaphore_up(semaphore_t * s){ enter_critical(); if (!unblock_one(&s->wait_queue)) ++s->value; leave_critical(); }
/* TODO: Unblock the first thread waiting on c, if it exists */ void condition_signal(condition_t * c){ enter_critical(); unblock_one(&c->wait_queue); leave_critical(); }
static void unblock_all(node_t * wait_queue) { while( unblock_one(wait_queue) ) {} }