usleep'ing for 0 usecs simply causes a context-switch.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-12-02 22:37:17 +01:00
parent 5862441351
commit b0859c6d92
2 changed files with 15 additions and 4 deletions

View File

@ -165,9 +165,10 @@ int isatty(int);
int pipe(int [2]);
ssize_t read(int, void*, size_t);
unsigned sleep(unsigned);
#if __POSIX_OBSOLETE <= 200112
/*#if __POSIX_OBSOLETE <= 200112*/
typedef unsigned int useconds_t;
int usleep(useconds_t useconds);
#endif
/*#endif*/
int unlink(const char*);
ssize_t write(int, const void*, size_t);

View File

@ -319,7 +319,12 @@ namespace Sortix
{
Thread* thread = currentthread;
uintmax_t timetosleep = ((uintmax_t) secs) * 1000ULL * 1000ULL;
if ( timetosleep == 0 ) { return; }
if ( timetosleep == 0 )
{
Switch(Syscall::InterruptRegs());
Syscall::AsIs();
return;
}
PutThreadToSleep(thread, timetosleep);
Syscall::Incomplete();
}
@ -328,7 +333,12 @@ namespace Sortix
{
Thread* thread = currentthread;
uintmax_t timetosleep = usecs;
if ( timetosleep == 0 ) { return; }
if ( timetosleep == 0 )
{
Switch(Syscall::InterruptRegs());
Syscall::AsIs();
return;
}
PutThreadToSleep(thread, timetosleep);
Syscall::Incomplete();
}