Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (ut = uttable; ut < &(uttable[MAX_THREAD]);ut++)
- {
- if (ut->i_am_waiting_for == current){
- ut->state = T_RUNNABLE;
- }
- }
- int uthred_join(int tid){
- uthread_p ut;
- uthread_p thread_waiting_for;
- int found = 0;
- /* Check if tid parameter exist in thread pool */
- for (ut = uttable; ut < &(uttable[MAX_THREAD]);ut++)
- {
- if (ut->tid == tid){
- found = 1;
- thread_waiting_for = ut;
- }
- }
- if (found == 0){
- return -1;
- }
- /* check if waited thread already exited */
- if (thread_waiting_for->state == T_FREE){
- return 0; //exit immidietly
- }
- /*thread not exited. start waiting */
- current->i_am_waiting_for = thread_waiting_for;
- current->state = T_SLEEPING;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement