Kernel - Added a per-thread timer object to reduce malloc use
authorJohn Hodge <[email protected]>
Thu, 23 Aug 2012 05:30:03 +0000 (13:30 +0800)
committerJohn Hodge <[email protected]>
Thu, 23 Aug 2012 05:30:03 +0000 (13:30 +0800)
KernelLand/Kernel/include/threads_int.h
KernelLand/Kernel/include/timers_int.h [new file with mode: 0644]
KernelLand/Kernel/time.c

index 2f15a72..881db4a 100644 (file)
@@ -1,5 +1,9 @@
 /*
- * Internal Threading header
+ * Acess2 Kernel
+ * - By John Hodge (thePowersGang)
+ *
+ * include/threads_int.h
+ * - Internal Threading header
  * - Only for use by stuff that needs access to the thread type.
  */
 #ifndef _THREADS_INT_H_
@@ -7,6 +11,7 @@
 
 #include <threads.h>
 #include <proc.h>
+#include <timers_int.h>
 
 typedef struct sProcess        tProcess;
 
@@ -92,6 +97,8 @@ struct sThread
        
        // --- event.c
        Uint32  EventState;
+       // --- timer.c
+       tTimer  ThreadTimer;
 };
 
 
diff --git a/KernelLand/Kernel/include/timers_int.h b/KernelLand/Kernel/include/timers_int.h
new file mode 100644 (file)
index 0000000..85a52ec
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Acess2 Kernel
+ * - By John Hodge (thePowersGang)
+ *
+ * include/timers_int.h
+ * - Timer internal header
+ * - Only for use by code that needs access to timer internals
+ */
+#ifndef _KERNEL__TIMERS_INT_H_
+#define _KERNEL__TIMERS_INT_H_
+
+#include <timers.h>
+
+// === TYPEDEFS ===
+struct sTimer {
+       tTimer  *Next;
+       Sint64  FiresAfter;
+       void    (*Callback)(void*);
+       void    *Argument;
+//     tMutex  Lock;
+       BOOL    bActive;
+};
+
+#endif
+
index d8c2924..449afcd 100644 (file)
@@ -8,19 +8,11 @@
 #define DEBUG  0
 #include <acess.h>
 #include <timers.h>
+#include <timers_int.h>
 #include <events.h>
 #include <hal_proc.h>  // Proc_GetCurThread
 #include <workqueue.h>
-
-// === TYPEDEFS ===
-struct sTimer {
-       tTimer  *Next;
-       Sint64  FiresAfter;
-       void    (*Callback)(void*);
-       void    *Argument;
-//     tMutex  Lock;
-       BOOL    bActive;
-};
+#include <threads_int.h>       // Used to get thread timer
 
 // === PROTOTYPES ===
 void   Timer_CallbackThread(void *Unused);
@@ -240,11 +232,10 @@ void Time_FreeTimer(tTimer *Timer)
  */
 void Time_Delay(int Delay)
 {
-       tTimer  *t;
-       t = Time_AllocateTimer(NULL, NULL);
+       tTimer  *t = &Proc_GetCurThread()->ThreadTimer;
+       Time_InitTimer(t, NULL, NULL);
        Time_ScheduleTimer(t, Delay);
        Threads_WaitEvents(THREAD_EVENT_TIMER);
-       Time_FreeTimer(t);
 }
 
 // === EXPORTS ===

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