aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/tasks
diff options
context:
space:
mode:
authorMarvin Borner2020-05-12 20:28:08 +0200
committerMarvin Borner2020-05-12 20:28:08 +0200
commit3b16ca421aad772e0f40716e2fc66215d322f7f7 (patch)
treee0f79fd2e3c16ddb80ce2cbdd2fb13036d59687c /src/kernel/tasks
parentb28552c99b9d2bf59407411c9514d18af3d392c0 (diff)
Still searching the bug...
And fixed many other small ones
Diffstat (limited to 'src/kernel/tasks')
-rw-r--r--src/kernel/tasks/process.c24
-rw-r--r--src/kernel/tasks/process.h2
-rw-r--r--src/kernel/tasks/userspace.asm6
-rw-r--r--src/kernel/tasks/userspace.c1
4 files changed, 12 insertions, 21 deletions
diff --git a/src/kernel/tasks/process.c b/src/kernel/tasks/process.c
index a5b9c87..45c9937 100644
--- a/src/kernel/tasks/process.c
+++ b/src/kernel/tasks/process.c
@@ -67,7 +67,6 @@ void process_init(struct process *proc)
root = proc;
root->pid = pid++;
root->next = NULL;
- root->thread = PROC_ROOT; // Unkillable
root->state = PROC_RUNNING;
current_proc = root;
@@ -105,23 +104,6 @@ u32 process_spawn(struct process *process)
return process->pid;
}
-u32 process_wait_gid(u32 gid, u32 *status)
-{
- struct process *i = root;
-
- while (i != NULL) {
- if (i->gid == gid)
- if (i->state == PROC_ASLEEP) {
- *status = i->registers.ebx;
- return i->pid;
- }
-
- i = i->next;
- }
-
- return WAIT_OKAY;
-}
-
u32 process_wait_pid(u32 pid, u32 *status)
{
struct process *i = current_proc->next;
@@ -144,6 +126,9 @@ u32 process_wait_pid(u32 pid, u32 *status)
void process_suspend(u32 pid)
{
debug("Suspending process %d", pid);
+ if (pid == 1)
+ panic("Root process died");
+
struct process *proc = process_from_pid(pid);
if (proc == PID_NOT_FOUND) {
@@ -152,6 +137,7 @@ void process_suspend(u32 pid)
}
proc->state = PROC_ASLEEP;
+ process_force_switch();
}
void process_wake(u32 pid)
@@ -163,6 +149,7 @@ void process_wake(u32 pid)
return;
proc->state = PROC_RUNNING;
+ process_force_switch();
}
u32 process_child(struct process *child, u32 pid)
@@ -220,6 +207,7 @@ u32 kexec(char *path)
return -1;
process_init(proc);
+ process_force_switch();
return 0;
}
diff --git a/src/kernel/tasks/process.h b/src/kernel/tasks/process.h
index 32511c0..25b11b2 100644
--- a/src/kernel/tasks/process.h
+++ b/src/kernel/tasks/process.h
@@ -17,11 +17,9 @@ struct process {
struct regs registers;
u32 pid;
- u32 gid;
char name[256];
int state;
- int thread;
u32 brk;
u32 handlers[6];
diff --git a/src/kernel/tasks/userspace.asm b/src/kernel/tasks/userspace.asm
index 4f79d4d..a708184 100644
--- a/src/kernel/tasks/userspace.asm
+++ b/src/kernel/tasks/userspace.asm
@@ -14,6 +14,12 @@ jump_userspace:
push 0x23
push eax
pushf
+
+ ; Enable interrupts
+ pop eax
+ or eax, 0x200
+ push eax
+
push 0x1B
push dword [hl_eip]
diff --git a/src/kernel/tasks/userspace.c b/src/kernel/tasks/userspace.c
index c3fc7e2..e9fd2f0 100644
--- a/src/kernel/tasks/userspace.c
+++ b/src/kernel/tasks/userspace.c
@@ -30,7 +30,6 @@ void userspace_enter(struct process *proc)
current_proc = proc;
debug("Jumping to userspace!");
- //sti(); // TODO: Prevent race conditions in userspace jumping
jump_userspace();
}