Cleanup (debug statements removed)
[tpg/acess2.git] / Kernel / time.c
index 30d11dc..e64d0b7 100644 (file)
@@ -21,21 +21,12 @@ 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()
  */
@@ -45,9 +36,7 @@ void Timer_CallTimers()
        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;
@@ -97,7 +86,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 ===

UCC git Repository :: git.ucc.asn.au