9 * __thread_process_timeouts()
11 * Look for threads that have timed out. This should be called
12 * under interrupt lock, before calling __schedule().
14 void __thread_process_timeouts(void)
16 struct thread
*curr
= current();
17 struct thread_list
*tp
;
19 mstime_t now
= ms_timer();
20 struct thread_block
*block
;
23 /* The current thread is obviously running, so no need to check... */
24 for (tp
= curr
->list
.next
; tp
!= &curr
->list
; tp
= tp
->next
) {
25 t
= container_of(tp
, struct thread
, list
);
26 if ((block
= t
->blocked
) && (timeout
= block
->timeout
)) {
27 if ((mstimediff_t
)(timeout
- now
) <= 0) {
28 struct semaphore
*sem
= block
->semaphore
;
29 /* Remove us from the queue and increase the count */
30 block
->list
.next
->prev
= block
->list
.prev
;
31 block
->list
.prev
->next
= block
->list
.next
;
35 block
->timed_out
= true;
37 __schedule(); /* Normally sets just __need_schedule */