implement POSIX timers
this implementation is superior to the glibc/nptl implementation, in that it gives true realtime behavior. there is no risk of timer expiration events being lost due to failed thread creation or failed malloc, because the thread is created as time creation time, and reused until the timer is deleted.
This commit is contained in:
parent
bf619d82c8
commit
80c4dcd253
7 changed files with 160 additions and 6 deletions
12
src/time/timer_delete.c
Normal file
12
src/time/timer_delete.c
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <time.h>
|
||||
#include "pthread_impl.h"
|
||||
|
||||
int timer_delete(timer_t t)
|
||||
{
|
||||
if (t->thread) pthread_cancel(t->thread);
|
||||
else {
|
||||
if (t->timerid >= 0) __syscall(SYS_timer_delete, t->timerid);
|
||||
free(t);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue