mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
usleep'ing for 0 usecs simply causes a context-switch.
This commit is contained in:
parent
5862441351
commit
b0859c6d92
2 changed files with 15 additions and 4 deletions
|
@ -165,9 +165,10 @@ int isatty(int);
|
||||||
int pipe(int [2]);
|
int pipe(int [2]);
|
||||||
ssize_t read(int, void*, size_t);
|
ssize_t read(int, void*, size_t);
|
||||||
unsigned sleep(unsigned);
|
unsigned sleep(unsigned);
|
||||||
#if __POSIX_OBSOLETE <= 200112
|
/*#if __POSIX_OBSOLETE <= 200112*/
|
||||||
|
typedef unsigned int useconds_t;
|
||||||
int usleep(useconds_t useconds);
|
int usleep(useconds_t useconds);
|
||||||
#endif
|
/*#endif*/
|
||||||
int unlink(const char*);
|
int unlink(const char*);
|
||||||
ssize_t write(int, const void*, size_t);
|
ssize_t write(int, const void*, size_t);
|
||||||
|
|
||||||
|
|
|
@ -319,7 +319,12 @@ namespace Sortix
|
||||||
{
|
{
|
||||||
Thread* thread = currentthread;
|
Thread* thread = currentthread;
|
||||||
uintmax_t timetosleep = ((uintmax_t) secs) * 1000ULL * 1000ULL;
|
uintmax_t timetosleep = ((uintmax_t) secs) * 1000ULL * 1000ULL;
|
||||||
if ( timetosleep == 0 ) { return; }
|
if ( timetosleep == 0 )
|
||||||
|
{
|
||||||
|
Switch(Syscall::InterruptRegs());
|
||||||
|
Syscall::AsIs();
|
||||||
|
return;
|
||||||
|
}
|
||||||
PutThreadToSleep(thread, timetosleep);
|
PutThreadToSleep(thread, timetosleep);
|
||||||
Syscall::Incomplete();
|
Syscall::Incomplete();
|
||||||
}
|
}
|
||||||
|
@ -328,7 +333,12 @@ namespace Sortix
|
||||||
{
|
{
|
||||||
Thread* thread = currentthread;
|
Thread* thread = currentthread;
|
||||||
uintmax_t timetosleep = usecs;
|
uintmax_t timetosleep = usecs;
|
||||||
if ( timetosleep == 0 ) { return; }
|
if ( timetosleep == 0 )
|
||||||
|
{
|
||||||
|
Switch(Syscall::InterruptRegs());
|
||||||
|
Syscall::AsIs();
|
||||||
|
return;
|
||||||
|
}
|
||||||
PutThreadToSleep(thread, timetosleep);
|
PutThreadToSleep(thread, timetosleep);
|
||||||
Syscall::Incomplete();
|
Syscall::Incomplete();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue