Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. for (ut = uttable; ut < &(uttable[MAX_THREAD]);ut++)
  2. {
  3. if (ut->i_am_waiting_for == current){
  4. ut->state = T_RUNNABLE;
  5. }
  6.  
  7. }
  8.  
  9.  
  10.  
  11. int uthred_join(int tid){
  12.  
  13. uthread_p ut;
  14. uthread_p thread_waiting_for;
  15. int found = 0;
  16. /* Check if tid parameter exist in thread pool */
  17.  
  18. for (ut = uttable; ut < &(uttable[MAX_THREAD]);ut++)
  19. {
  20. if (ut->tid == tid){
  21. found = 1;
  22. thread_waiting_for = ut;
  23. }
  24. }
  25. if (found == 0){
  26. return -1;
  27. }
  28. /* check if waited thread already exited */
  29. if (thread_waiting_for->state == T_FREE){
  30. return 0; //exit immidietly
  31. }
  32.  
  33. /*thread not exited. start waiting */
  34. current->i_am_waiting_for = thread_waiting_for;
  35. current->state = T_SLEEPING;
  36.  
  37.  
  38.  
  39.  
  40. return 0;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement