aboutsummaryrefslogtreecommitdiff
path: root/kernel/features
diff options
context:
space:
mode:
authorMarvin Borner2020-08-22 23:31:47 +0200
committerMarvin Borner2020-08-22 23:31:47 +0200
commitb667ea0fbd26af222f828199e7b9a7e62ad98081 (patch)
tree90dac52e2cf0a898da0097e9b1375506309b673f /kernel/features
parent32f63ffc96f7f7ec6c504b8f50292316f026dd21 (diff)
Some window fb and yield implementation
Diffstat (limited to 'kernel/features')
-rw-r--r--kernel/features/proc.c13
-rw-r--r--kernel/features/syscall.c7
2 files changed, 16 insertions, 4 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index d1a2780..1c0b443 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -17,8 +17,11 @@ u32 quantum = 0;
struct list *proc_list;
struct node *current;
+// TODO: Use less memcpy and only copy relevant registers
void scheduler(struct regs *regs)
{
+ timer_handler();
+
if (quantum == 0) {
quantum = PROC_QUANTUM;
} else {
@@ -34,8 +37,6 @@ void scheduler(struct regs *regs)
if (current)
memcpy(&((struct proc *)current->data)->regs, regs, sizeof(struct regs));
- timer_handler();
-
if (current && current->next)
current = current->next;
else
@@ -71,9 +72,9 @@ void scheduler(struct regs *regs)
quantum = PROC_QUANTUM;
proc->state = PROC_IN_EVENT;
- list_remove(proc->events, proc->events->head);
regs->useresp += 4;
((u32 *)regs->useresp)[1] = (u32)proc_event->data; // Huh
+ list_remove(proc->events, proc->events->head);
}
/* printf("{%d}", ((struct proc *)current->data)->pid); */
@@ -158,6 +159,12 @@ void proc_exit(struct proc *proc, int status)
hlt();
}
+// TODO: More instant yield
+void proc_yield()
+{
+ quantum = 0;
+}
+
struct proc *proc_make()
{
struct proc *proc = malloc(sizeof(*proc));
diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c
index 9bd5e9b..2a310ef 100644
--- a/kernel/features/syscall.c
+++ b/kernel/features/syscall.c
@@ -17,7 +17,7 @@ void syscall_handler(struct regs *r)
enum sys num = r->eax;
r->eax = 0;
- if (num != SYS_RECEIVE)
+ if (num != SYS_RECEIVE && num != SYS_YIELD)
printf("[SYSCALL] %d: ", num);
switch (num) {
@@ -69,6 +69,11 @@ void syscall_handler(struct regs *r)
proc_exit(proc_current(), r->ebx);
break;
}
+ case SYS_YIELD: {
+ /* printf("yield\n"); */
+ proc_yield();
+ break;
+ }
case SYS_TIME: {
printf("time\n");
r->eax = timer_get();