| 111 | } |
| 112 | |
| 113 | static void schedule(struct thread *t) |
| 114 | { |
| 115 | struct thread *current = current_thread(); |
| 116 | |
| 117 | /* If t is NULL need to find new runnable thread. */ |
| 118 | if (t == NULL) { |
| 119 | t = pop_runnable(); |
| 120 | if (t == NULL) |
| 121 | die("Runnable thread list is empty!\n"); |
| 122 | } else { |
| 123 | /* current is still runnable. */ |
| 124 | push_runnable(current); |
| 125 | } |
| 126 | |
| 127 | if (t->handle) |
| 128 | t->handle->state = THREAD_STARTED; |
| 129 | |
| 130 | set_current_thread(t); |
| 131 | |
| 132 | switch_to_thread(t->stack_current, ¤t->stack_current); |
| 133 | } |
| 134 | |
| 135 | static void terminate_thread(struct thread *t, enum cb_err error) |
| 136 | { |
no test coverage detected