Rev 1407 | Rev 1614 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1407 | Rev 1427 | ||
---|---|---|---|
Line 115... | Line 115... | ||
115 | psthread_exit(); |
115 | psthread_exit(); |
116 | } |
116 | } |
117 | 117 | ||
118 | /** Schedule next userspace pseudo thread. |
118 | /** Schedule next userspace pseudo thread. |
119 | * |
119 | * |
- | 120 | * If calling with PS_TO_MANAGER parameter, the async_futex should be |
|
- | 121 | * held. |
|
- | 122 | * |
|
120 | * @param tomanager If true, we are switching to next ready manager thread |
123 | * @param tomanager If true, we are switching to next ready manager thread |
121 | * (if none is found, thread is exited) |
124 | * (if none is found, thread is exited) |
122 | * @param frommanager If true, we are switching from manager thread |
125 | * @param frommanager If true, we are switching from manager thread |
123 | * @return 0 if there is no ready pseudo thread, 1 otherwise. |
126 | * @return 0 if there is no ready pseudo thread, 1 otherwise. |
124 | */ |
127 | */ |
Line 134... | Line 137... | ||
134 | 137 | ||
135 | if (ctype == PS_FROM_MANAGER && list_empty(&ready_list)) { |
138 | if (ctype == PS_FROM_MANAGER && list_empty(&ready_list)) { |
136 | goto ret_0; |
139 | goto ret_0; |
137 | } |
140 | } |
138 | /* If we are going to manager and none exists, create it */ |
141 | /* If we are going to manager and none exists, create it */ |
139 | if (ctype == PS_TO_MANAGER && list_empty(&manager_list)) |
142 | while (ctype == PS_TO_MANAGER && list_empty(&manager_list)) { |
- | 143 | futex_up(&psthread_futex); |
|
140 | async_create_manager(); |
144 | async_create_manager(); |
- | 145 | futex_down(&psthread_futex); |
|
- | 146 | } |
|
141 | 147 | ||
142 | pt = __tcb_get()->pst_data; |
148 | pt = __tcb_get()->pst_data; |
143 | if (!context_save(&pt->ctx)) |
149 | if (!context_save(&pt->ctx)) |
144 | return 1; // futex_up already done here |
150 | return 1; // futex_up already done here |
145 | 151 | ||
Line 257... | Line 263... | ||
257 | return; |
263 | return; |
258 | } |
264 | } |
259 | list_remove(manager_list.next); |
265 | list_remove(manager_list.next); |
260 | futex_up(&psthread_futex); |
266 | futex_up(&psthread_futex); |
261 | } |
267 | } |
- | 268 | ||
- | 269 | /** Return thread id of current running thread */ |
|
- | 270 | pstid_t psthread_get_id(void) |
|
- | 271 | { |
|
- | 272 | return (pstid_t)__tcb_get()->pst_data; |
|
- | 273 | } |