daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void green_cond_wait(green_cond_t* suspended, green_mutex_t *mutex){
  2.  
  3.   sigprocmask(SIG_BLOCK, &block, NULL);
  4.   green_t *susp = running;
  5.   suspendCond(suspended);
  6.  
  7.   if(mutex != NULL){
  8.     mutex->taken = FALSE;
  9.     readyQueue(mutex->suspended);
  10.   }
  11.  
  12.   green_t *next = running->next;
  13.  
  14.   running = next;
  15.   swapcontext(susp->context, next->context);
  16.  
  17.     if(mutex != NULL){
  18.       struct green_t *susp = running;
  19.       while(mutex->taken){
  20.         suspendMutex(mutex);
  21.         struct green_t *next = running->next;
  22.         running = next;
  23.         swapcontext(susp->context, next->context);
  24.       }
  25.       mutex->taken = TRUE;
  26.  
  27.     }
  28.   sigprocmask(SIG_UNBLOCK, &block, NULL);
  29.  
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top