aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/tasks
diff options
context:
space:
mode:
authorMarvin Borner2020-05-09 17:39:31 +0200
committerMarvin Borner2020-05-09 17:39:31 +0200
commit09a66e91ec9e8a677aa48f27798753084f213713 (patch)
tree9685a13b459e60d830179c565417ed72ae855ebe /src/kernel/tasks
parent3a97fef4bb4780e4bc2423699063d40cbf5da923 (diff)
Replaced fork() with spawn()!
Who needs forks anyway
Diffstat (limited to 'src/kernel/tasks')
-rw-r--r--src/kernel/tasks/process.c34
-rw-r--r--src/kernel/tasks/process.h5
-rw-r--r--src/kernel/tasks/userspace.c3
3 files changed, 23 insertions, 19 deletions
diff --git a/src/kernel/tasks/process.c b/src/kernel/tasks/process.c
index 431f1fb..576190b 100644
--- a/src/kernel/tasks/process.c
+++ b/src/kernel/tasks/process.c
@@ -31,13 +31,15 @@ void scheduler(struct regs *regs)
current_proc = root;
}
- debug("Max pid: %d", pid);
- debug("Task switch to %s with pid %d", current_proc->name, current_proc->pid);
+ /* debug("Max pid: %d", pid); */
+ /* debug("Task switch to %s with pid %d", current_proc->name, current_proc->pid); */
+ serial_put('.');
while (current_proc->state == PROC_ASLEEP) {
current_proc = current_proc->next;
if (current_proc == NULL) {
warn("No next process!");
+ halt_loop();
current_proc = root;
}
}
@@ -49,7 +51,7 @@ void scheduler(struct regs *regs)
void process_init(struct process *proc)
{
- log("Initializing process %d", pid + 1);
+ log("Initializing process %d", pid);
cli();
root = proc;
root->pid = pid++;
@@ -70,8 +72,6 @@ void process_kill(u32 pid)
if (proc == PID_NOT_FOUND)
panic("Can't kill unknown PID");
- // flush(proc->stdout);
- // flush(proc->stderr);
proc->state = PROC_ASLEEP;
if (proc->parent != NULL) {
@@ -82,6 +82,7 @@ void process_kill(u32 pid)
u32 process_spawn(struct process *process)
{
+ cli();
debug("Spawning process %d", process->pid);
process->next = root->next;
root->next = process;
@@ -91,6 +92,7 @@ u32 process_spawn(struct process *process)
//process_suspend(current_proc->pid);
+ sti();
return process->pid;
}
@@ -225,10 +227,6 @@ u32 kexec(char *path)
if (proc == NULL)
return -1;
- // TODO: Add stdin etc support (?)
- proc->stdin = NULL;
- proc->stdout = NULL;
- proc->stderr = NULL;
process_init(proc);
return 0;
}
@@ -242,12 +240,24 @@ u32 uexec(char *path)
if (proc == NULL)
return -1;
- proc->stdin = NULL;
- proc->stdout = NULL;
- proc->stderr = NULL;
+ proc->parent = current_proc;
+ proc->gid = current_proc->pid;
+ process_spawn(proc);
+ log("Spawned");
+ return 0;
+}
+
+u32 uspawn(char *path)
+{
+ debug("Spawning user process %s", path);
+
+ struct process *proc = elf_load(path);
+ if (proc == NULL)
+ return -1;
proc->parent = current_proc;
proc->gid = current_proc->pid;
process_spawn(proc);
+ log("Spawned");
return 0;
} \ No newline at end of file
diff --git a/src/kernel/tasks/process.h b/src/kernel/tasks/process.h
index 17467c4..8221a85 100644
--- a/src/kernel/tasks/process.h
+++ b/src/kernel/tasks/process.h
@@ -23,10 +23,6 @@ struct process {
int state;
int thread;
- u32 stdin;
- u32 stdout;
- u32 stderr;
-
u32 brk;
u32 handlers[6];
@@ -57,6 +53,7 @@ struct process *process_make_new();
u32 kexec(char *path);
u32 uexec(char *path);
+u32 uspawn(char *path);
extern struct process *current_proc;
diff --git a/src/kernel/tasks/userspace.c b/src/kernel/tasks/userspace.c
index 375e7bb..52eb528 100644
--- a/src/kernel/tasks/userspace.c
+++ b/src/kernel/tasks/userspace.c
@@ -50,9 +50,6 @@ void single_yield(struct process *proc, struct regs *regs)
u32 single_exit(struct regs *regs)
{
- //close(current_proc->stdout);
- //close(current_proc->stderr);
-
u32 hold = regs->ebx;
proc_bottom = proc_bottom->next;