From 5e9aa4043f82eba950cb0afd353d183b3c688fe4 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 27 Sep 2009 13:37:56 +0800 Subject: [PATCH] Added tracing of task switches --- Kernel/arch/x86/proc.c | 11 +++++++++++ Kernel/syscalls.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index d468d11a..f04793a2 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -10,6 +10,9 @@ # include #endif +// === FLAGS === +#define DEBUG_TRACE_SWITCH 1 + // === CONSTANTS === #define SWITCH_MAGIC 0xFFFACE55 // There is no code in this area #define TIMER_DIVISOR 11931 //~100Hz @@ -497,6 +500,14 @@ void Proc_Scheduler(int CPU) return; } + #if DEBUG_TRACE_SWITCH + Log("Switching to task %i, CR3 = 0x%x, EIP = %p", + thread->TID, + thread->MemState.CR3, + thread->SavedState.EIP + ); + #endif + // Set current thread gCurrentThread = thread; diff --git a/Kernel/syscalls.c b/Kernel/syscalls.c index f655707c..74eaaeaa 100644 --- a/Kernel/syscalls.c +++ b/Kernel/syscalls.c @@ -57,8 +57,8 @@ void SyscallHandler(tSyscallRegs *Regs) case SYS_CLONE: // Call clone system call ret = Proc_Clone(&err, Regs->Arg1); - // Change user stack if requested - if(ret == 0 && !(Regs->Arg1 & CLONE_VM)) + // Change user stack if a new stack address is passed + if(ret == 0 && Regs->Arg2) Regs->StackPointer = Regs->Arg2; break; -- 2.20.1