diff options
author | Marvin Borner | 2020-10-25 17:52:28 +0100 |
---|---|---|
committer | Marvin Borner | 2020-10-25 17:52:28 +0100 |
commit | 4ec7c19e1567f322b1622ad506290e8eb7a4956d (patch) | |
tree | 2fbd1e7f92973105d3dea8e55fd12c8b989050cf /kernel | |
parent | c9f89174b9ce73ed93bfad14d57b8f1a43db6bf6 (diff) |
Some fixes :)
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/features/proc.c | 13 | ||||
-rw-r--r-- | kernel/features/syscall.c | 1 |
2 files changed, 11 insertions, 3 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c index 7544b68..b6ed442 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -15,6 +15,7 @@ u32 pid = 0; u32 quantum = 0; struct proc *kernel_proc; +struct proc *priority_proc; struct list *proc_list; struct node *current; @@ -35,10 +36,15 @@ void scheduler(struct regs *regs) memcpy(&((struct proc *)current->data)->regs, regs, sizeof(struct regs)); - if (current->next) + if (priority_proc) { + current = list_first_data(proc_list, priority_proc); + priority_proc = NULL; + assert(current); + } else if (current->next) { current = current->next; - else + } else { current = proc_list->head; + } memcpy(regs, &((struct proc *)current->data)->regs, sizeof(struct regs)); @@ -85,7 +91,7 @@ struct proc *proc_current() void proc_send(struct proc *src, struct proc *dest, u32 type, void *data) { - // TODO: Use unique key instead of pid for IPC messaging + // TODO: Use unique key instead of pid for IPC if (!src || !dest) return; struct proc_message *msg = malloc(sizeof(*msg)); @@ -96,6 +102,7 @@ void proc_send(struct proc *src, struct proc *dest, u32 type, void *data) msg->msg->type = type; msg->msg->data = data; list_add(dest->messages, msg); + priority_proc = dest; } struct proc_message *proc_receive(struct proc *proc) diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index 73f31eb..798ca45 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -79,6 +79,7 @@ void syscall_handler(struct regs *r) } case SYS_SEND: { proc_send(proc_current(), proc_from_pid(r->ebx), r->ecx, (void *)r->edx); + proc_yield(r); break; } case SYS_RECEIVE: { |