Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement