Support sleep(0)

This commit is contained in:
Ali Mashtizadeh 2015-01-16 14:52:20 -08:00
parent 37a8bebd1b
commit 2342aefe9e

View File

@ -327,11 +327,14 @@ Syscall_ThreadSleep(uint64_t time)
{
Thread *cur = Thread_Current();
cur->timerEvt = Timer_Create(time, ThreadWakeupHelper, cur);
if (cur->timerEvt == NULL)
return -ENOMEM;
// If the sleep time is zero just yield
if (time != 0) {
cur->timerEvt = Timer_Create(time, ThreadWakeupHelper, cur);
if (cur->timerEvt == NULL)
return -ENOMEM;
Thread_SetWaiting(cur);
Thread_SetWaiting(cur);
}
Thread_Scheduler();
return 0;