about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-09-27 15:46:41 -0700
committerKartik Agaram <vc@akkartik.com>2019-09-27 15:46:41 -0700
commitf470eca4ee9455cbefadb90af876acae62607257 (patch)
treec9bfdf0652055143c60e1df05027b2d589387c50
parent8ccd1cfbcfe7cca692caadf0803790e8322b2398 (diff)
downloadmu-f470eca4ee9455cbefadb90af876acae62607257.tar.gz
5693
Undo previous commit.
-rw-r--r--kernel.soso/process.c23
-rw-r--r--kernel.soso/process.h3
2 files changed, 11 insertions, 15 deletions
diff --git a/kernel.soso/process.c b/kernel.soso/process.c
index e1088bd8..7964467b 100644
--- a/kernel.soso/process.c
+++ b/kernel.soso/process.c
@@ -547,7 +547,7 @@ BOOL isProcessValid(Process* process) {
     return FALSE;
 }
 
-static void switchToTask(Thread* current, int mode);
+static void switchToTask(Thread* current);
 
 static void updateMetrics(Thread* thread) {
     uint32 seconds = getUptimeSeconds();
@@ -657,20 +657,10 @@ void schedule(TimerInt_Registers* registers) {
     */
 
     updateMetrics(current);
-
-    if (current->regs.cs != 0x08) {
-        switchToTask(current, USERMODE);
-    }
-    else {
-        switchToTask(current, KERNELMODE);
-    }
+    switchToTask(current);
 }
 
-
-
-//The mode indicates whether this process was in user mode or kernel mode
-//When it was previously interrupted by the scheduler.
-static void switchToTask(Thread* current, int mode) {
+static void switchToTask(Thread* current) {
     uint32 kesp, eflags;
     uint16 kss, ss, cs;
 
@@ -682,11 +672,14 @@ static void switchToTask(Thread* current, int mode) {
     cs = current->regs.cs;
     eflags = (current->regs.eflags | 0x200) & 0xFFFFBFFF;
 
-    if (mode == USERMODE) {
+    int oldMode;
+    if (cs != 0x08) {
+        oldMode = USERMODE;
         kss = current->kstack.ss0;
         kesp = current->kstack.esp0;
     }
     else {
+        oldMode = KERNELMODE;
         kss = current->regs.ss;
         kesp = current->regs.esp;
     }
@@ -715,6 +708,6 @@ static void switchToTask(Thread* current, int mode) {
         "m"(current->regs.eip), \
         "m"(current), \
         [KMODE] "i"(KERNELMODE), \
-        [mode] "g"(mode)
+        [mode] "g"(oldMode)
         );
 }
diff --git a/kernel.soso/process.h b/kernel.soso/process.h
index ab4e3615..a2979714 100644
--- a/kernel.soso/process.h
+++ b/kernel.soso/process.h
@@ -1,6 +1,9 @@
 #ifndef PROCESS_H
 #define PROCESS_H
 
+#define KERNELMODE	0
+#define USERMODE	1
+
 #define MAX_OPENED_FILES 20
 
 #include "common.h"