From a02438750b6fca3556c2e92a626da17ac9e099b9 Mon Sep 17 00:00:00 2001 From: Joostinonline Date: Tue, 29 Oct 2013 18:20:39 +0000 Subject: [PATCH] -Some minor notes and improvements to thread.c --- source/thread.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/thread.c b/source/thread.c index cca5c0a..89f86a7 100644 --- a/source/thread.c +++ b/source/thread.c @@ -6,15 +6,15 @@ #include "thread.h" #include "gui.h" -#define STACKSIZE (1024 * 64) // 64KB -#define PRIORITY 50 // Medium-ish +#define STACKSIZE (1024 * 64) // 64KB of dedicated memory for thread +#define PRIORITY 50 // Medium-ish (0-127 accepted) lwp_t Cog_Thread; u8 stack[STACKSIZE] ATTRIBUTE_ALIGN (32); vu8 done = 0; void * DrawCogThread(void *arg) { - while(!done) { + while(!done) { // Keep the thread running until done != 0 GRRLIB_DrawImg(0, 0, tex_ScreenBuf, 0, 1, 1, HEX_WHITE); if (CheckTime(Last_Cog_Turn, 25)) { Cog_Num++; @@ -34,15 +34,16 @@ inline void InitThread(void) { } inline s32 PauseThread(void) { - //if(!LWP_ThreadIsSuspended(Cog_Thread)) return 0; + if(LWP_ThreadIsSuspended(Cog_Thread) == LWP_ALREADY_SUSPENDED) return LWP_ALREADY_SUSPENDED; return LWP_SuspendThread(Cog_Thread); } inline s32 ResumeThread(void) { - //if(LWP_ThreadIsSuspended(Cog_Thread)) return 0; + if(LWP_ThreadIsSuspended(Cog_Thread) == LWP_NOT_SUSPENDED) return LWP_NOT_SUSPENDED; return LWP_ResumeThread(Cog_Thread); } +// Have yet to test this inline s32 StopThread(void) { done = 1; ResumeThread();