From: John Hodge Date: Sun, 16 Sep 2012 04:07:38 +0000 (+0800) Subject: Kernel - API Change - Proc_SpawnWorker return thread pointer X-Git-Tag: rel0.15~706^2~8 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=721192b8e194d068bb6cc59749fe4a36477ddc3f;p=tpg%2Facess2.git Kernel - API Change - Proc_SpawnWorker return thread pointer --- diff --git a/KernelLand/Kernel/arch/armv7/proc.c b/KernelLand/Kernel/arch/armv7/proc.c index cd998f2b..9d5643ef 100644 --- a/KernelLand/Kernel/arch/armv7/proc.c +++ b/KernelLand/Kernel/arch/armv7/proc.c @@ -130,7 +130,7 @@ tTID Proc_Clone(Uint Flags) return new->TID; } -int Proc_SpawnWorker( void (*Fnc)(void*), void *Ptr ) +tThread *Proc_SpawnWorker( void (*Fnc)(void*), void *Ptr ) { tThread *new; Uint32 sp; @@ -144,7 +144,7 @@ int Proc_SpawnWorker( void (*Fnc)(void*), void *Ptr ) if(!new->KernelStack) { // TODO: Delete thread Log_Error("Proc", "Unable to allocate kernel stack"); - return -1; + return NULL; } sp = new->KernelStack; @@ -158,7 +158,7 @@ int Proc_SpawnWorker( void (*Fnc)(void*), void *Ptr ) Threads_AddActive(new); - return new->TID; + return new; } tTID Proc_NewKThread( void (*Fnc)(void*), void *Ptr ) diff --git a/KernelLand/Kernel/arch/x86/proc.c b/KernelLand/Kernel/arch/x86/proc.c index de0d5c3c..f68e6635 100644 --- a/KernelLand/Kernel/arch/x86/proc.c +++ b/KernelLand/Kernel/arch/x86/proc.c @@ -663,7 +663,7 @@ tPID Proc_Clone(Uint Flags) * \fn int Proc_SpawnWorker(void) * \brief Spawns a new worker thread */ -int Proc_SpawnWorker(void (*Fcn)(void*), void *Data) +tThread *Proc_SpawnWorker(void (*Fcn)(void*), void *Data) { tThread *new; Uint stack_contents[4]; @@ -672,7 +672,7 @@ int Proc_SpawnWorker(void (*Fcn)(void*), void *Data) new = Threads_CloneThreadZero(); if(!new) { Warning("Proc_SpawnWorker - Out of heap space!\n"); - return -1; + return NULL; } // Create the stack contents @@ -694,7 +694,7 @@ int Proc_SpawnWorker(void (*Fcn)(void*), void *Data) new->Status = THREAD_STAT_PREINIT; Threads_AddActive( new ); - return new->TID; + return new; } /** diff --git a/KernelLand/Kernel/heap.c b/KernelLand/Kernel/heap.c index af2bde49..be8eeaf6 100644 --- a/KernelLand/Kernel/heap.c +++ b/KernelLand/Kernel/heap.c @@ -512,7 +512,12 @@ void Heap_Dump(void) { tHeapHead *head, *badHead; tHeapFoot *foot = NULL; + static int in_heap_dump; + if( in_heap_dump ) return; + + in_heap_dump = 1; + head = gHeapStart; while( (Uint)head < (Uint)gHeapEnd ) { @@ -560,12 +565,16 @@ void Heap_Dump(void) } // If the heap is valid, ok! - if( (tVAddr)head == (tVAddr)gHeapEnd ) + if( (tVAddr)head == (tVAddr)gHeapEnd ) { + in_heap_dump = 0; return ; + } // Check for a bad return - if( (tVAddr)head >= (tVAddr)gHeapEnd ) + if( (tVAddr)head >= (tVAddr)gHeapEnd ) { + in_heap_dump = 0; return ; + } #if !VERBOSE_DUMP Log_Log("Heap", "%p (%P): 0x%08lx %i %4C", diff --git a/KernelLand/Kernel/include/acess.h b/KernelLand/Kernel/include/acess.h index 3abc49ab..41854a96 100644 --- a/KernelLand/Kernel/include/acess.h +++ b/KernelLand/Kernel/include/acess.h @@ -509,7 +509,7 @@ extern Sint64 now(void); * \name Threads and Processes * \{ */ -extern int Proc_SpawnWorker(void (*Fcn)(void*), void *Data); +extern struct sThread *Proc_SpawnWorker(void (*Fcn)(void*), void *Data); extern int Proc_Spawn(const char *Path); extern int Proc_SysSpawn(const char *Binary, const char **ArgV, const char **EnvP, int nFD, int *FDs); extern int Proc_Execve(const char *File, const char **ArgV, const char **EnvP, int DataSize);