X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Ftime.c;h=54ef08fc065a3d5f26241fe6d5e977c5c5d71d6b;hb=82adac267bc089391397b36413bba210a8e7c68f;hp=c048d11af41e23ceeaffae5558a233a78905ce6e;hpb=da7ef0c8cace452ccfdfa0881a3c0b09970874d8;p=tpg%2Facess2.git diff --git a/Kernel/time.c b/Kernel/time.c index c048d11a..54ef08fc 100644 --- a/Kernel/time.c +++ b/Kernel/time.c @@ -17,25 +17,15 @@ typedef struct sTimer { } tTimer; // === PROTOTYPES === -Sint64 now(void); void Timer_CallTimers(void); // === GLOBALS === -Uint64 giTicks = 0; -Sint64 giTimestamp = 0; -Uint64 giPartMiliseconds = 0; -tTimer gTimers[NUM_TIMERS]; +volatile Uint64 giTicks = 0; +volatile Sint64 giTimestamp = 0; +volatile Uint64 giPartMiliseconds = 0; +tTimer gTimers[NUM_TIMERS]; // TODO: Replace by a ring-list timer // === CODE === -/** - * \fn Sint64 now() - * \brief Return the current timestamp - */ -Sint64 now(void) -{ - return giTimestamp; -} - /** * \fn void Timer_CallTimers() */ @@ -43,16 +33,15 @@ void Timer_CallTimers() { int i; void (*callback)(void *); + void *arg; - for(i = 0; - i < NUM_TIMERS; - i ++) + for(i = 0; i < NUM_TIMERS; i ++) { if(gTimers[i].Callback == NULL) continue; if(giTimestamp < gTimers[i].FiresAfter) continue; - callback = gTimers[i].Callback; + callback = gTimers[i].Callback; arg = gTimers[i].Argument; gTimers[i].Callback = NULL; - callback(gTimers[i].Argument); + callback(arg); } } @@ -96,7 +85,9 @@ void Time_RemoveTimer(int ID) void Time_Delay(int Delay) { Sint64 dest = giTimestamp + Delay; - while(dest < giTimestamp) Threads_Yield(); + //Log("Time_Delay: dest = %lli", dest); + while(dest > giTimestamp) Threads_Yield(); + //Log("Time_Delay: giTimestamp = %lli", giTimestamp); } // === EXPORTS ===