64 |
if (timeouts->next->time > 0) { |
if (timeouts->next->time > 0) { |
65 |
time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time); |
time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time); |
66 |
} else { |
} else { |
67 |
time = 0xffffffff; |
time = SYS_ARCH_TIMEOUT; |
68 |
} |
} |
69 |
|
|
70 |
if (time == 0xffffffff) { |
if (time == 0xffffffff) { |
84 |
/* We try again to fetch a message from the mbox. */ |
/* We try again to fetch a message from the mbox. */ |
85 |
goto again; |
goto again; |
86 |
} else { |
} else { |
87 |
/* If time != 0xffffffff, a message was received before the timeout |
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout |
88 |
occured. The time variable is set to the number of |
occured. The time variable is set to the number of |
89 |
milliseconds we waited for the message. */ |
milliseconds we waited for the message. */ |
90 |
if (time <= timeouts->next->time) { |
if (time <= timeouts->next->time) { |
119 |
if (timeouts->next->time > 0) { |
if (timeouts->next->time > 0) { |
120 |
time = sys_arch_sem_wait(sem, timeouts->next->time); |
time = sys_arch_sem_wait(sem, timeouts->next->time); |
121 |
} else { |
} else { |
122 |
time = 0xffffffff; |
time = SYS_ARCH_TIMEOUT; |
123 |
} |
} |
124 |
|
|
125 |
if (time == 0xffffffff) { |
if (time == SYS_ARCH_TIMEOUT) { |
126 |
/* If time == 0xffffffff, a timeout occured before a message could be |
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message |
127 |
fetched. We should now call the timeout handler and |
could be fetched. We should now call the timeout handler and |
128 |
deallocate the memory allocated for the timeout. */ |
deallocate the memory allocated for the timeout. */ |
129 |
tmptimeout = timeouts->next; |
tmptimeout = timeouts->next; |
130 |
timeouts->next = tmptimeout->next; |
timeouts->next = tmptimeout->next; |
140 |
/* We try again to fetch a message from the mbox. */ |
/* We try again to fetch a message from the mbox. */ |
141 |
goto again; |
goto again; |
142 |
} else { |
} else { |
143 |
/* If time != 0xffffffff, a message was received before the timeout |
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout |
144 |
occured. The time variable is set to the number of |
occured. The time variable is set to the number of |
145 |
milliseconds we waited for the message. */ |
milliseconds we waited for the message. */ |
146 |
if (time <= timeouts->next->time) { |
if (time <= timeouts->next->time) { |
279 |
} |
} |
280 |
|
|
281 |
/*-----------------------------------------------------------------------------------*/ |
/*-----------------------------------------------------------------------------------*/ |
282 |
|
void |
283 |
|
sys_msleep(u32_t ms) |
284 |
|
{ |
285 |
|
sys_sem_t delaysem = sys_sem_new(0); |
286 |
|
|
287 |
|
sys_sem_wait_timeout(delaysem, ms); |
288 |
|
|
289 |
|
sys_sem_free(delaysem); |
290 |
|
} |
291 |
|
/*-----------------------------------------------------------------------------------*/ |
292 |
|
|
293 |
#endif /* NO_SYS */ |
#endif /* NO_SYS */ |