Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void green_cond_wait(green_cond_t* suspended, green_mutex_t *mutex){
- sigprocmask(SIG_BLOCK, &block, NULL);
- green_t *susp = running;
- suspendCond(suspended);
- if(mutex != NULL){
- mutex->taken = FALSE;
- readyQueue(mutex->suspended);
- }
- green_t *next = running->next;
- running = next;
- swapcontext(susp->context, next->context);
- if(mutex != NULL){
- struct green_t *susp = running;
- while(mutex->taken){
- suspendMutex(mutex);
- struct green_t *next = running->next;
- running = next;
- swapcontext(susp->context, next->context);
- }
- mutex->taken = TRUE;
- }
- sigprocmask(SIG_UNBLOCK, &block, NULL);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement