00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #include <kernel.h> 00010 #include <proc.h> 00011 #include <queue.h> 00012 #include <clock.h> 00013 00019 syscall sleep(int ms) 00020 { 00021 irqmask ps; 00022 00023 #ifdef RTCLOCK 00024 ASSERT( ms >= 0 ); 00025 00026 if (ms > 0) 00027 { 00028 /* tinkering with processes, no interrupts */ 00029 ps = disable(); 00030 insertd(currpid, sleepq, ms); 00031 proctab[currpid].state = PRSLEEP; 00032 restore(ps); 00033 } 00034 00035 resched(); 00036 return OK; 00037 #elif 00038 /* if we have no clock, sleep was an erroneous call */ 00039 return SYSERR; 00040 #endif 00041 }