diff options
-rw-r--r-- | apps/init.c | 3 | ||||
-rw-r--r-- | apps/mandelbrot.c | 3 | ||||
-rw-r--r-- | apps/wm.c | 2 | ||||
-rw-r--r-- | kernel/features/proc.c | 28 | ||||
-rw-r--r-- | kernel/features/syscall.c | 8 | ||||
-rw-r--r-- | kernel/inc/proc.h | 3 | ||||
-rw-r--r-- | libc/inc/sys.h | 2 |
7 files changed, 8 insertions, 41 deletions
diff --git a/apps/init.c b/apps/init.c index ccf88dd..ba6f93e 100644 --- a/apps/init.c +++ b/apps/init.c @@ -13,8 +13,5 @@ int main(int argc, char **argv) /* int test = exec("/window", "test", NULL); */ int mandelbrot = exec("/mandelbrot", "mandelbrot", NULL); - while (1) { - yield(); - }; return wm + mandelbrot; } diff --git a/apps/mandelbrot.c b/apps/mandelbrot.c index 9f73501..d5b8ae0 100644 --- a/apps/mandelbrot.c +++ b/apps/mandelbrot.c @@ -49,6 +49,7 @@ void draw_mandelbrot(struct window *win, int resolution) } gui_redraw(); print("Rendered mandelbrot successfully\n"); + yield(); } int main() @@ -61,7 +62,7 @@ int main() draw_mandelbrot(win, 50); while (1) { - wait(); + yield(); }; return 0; @@ -84,7 +84,7 @@ int main(int argc, char **argv) int mouse_skip = 0; while (1) { if (!(msg = msg_receive())) { - wait(); + yield(); continue; } diff --git a/kernel/features/proc.c b/kernel/features/proc.c index 19845d4..09f1f4e 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -32,23 +32,13 @@ void scheduler(struct regs *regs) assert(proc_list->head); - if (current) - memcpy(&((struct proc *)current->data)->regs, regs, sizeof(struct regs)); + memcpy(&((struct proc *)current->data)->regs, regs, sizeof(struct regs)); - if (current && current->next) + if (current->next) current = current->next; else current = proc_list->head; - while (((struct proc *)current->data)->state == PROC_WAITING) { - /* assert(proc_awake() > 0); */ - if (current && current->next && current->next->data) { - current = current->next; - } else { - current = proc_list->head; - } - } - memcpy(regs, &((struct proc *)current->data)->regs, sizeof(struct regs)); if (regs->cs != GDT_USER_CODE_OFFSET) { @@ -92,17 +82,6 @@ struct proc *proc_current() return current && current->data ? current->data : NULL; } -int proc_awake() -{ - int ret = 0; - struct node *iterator = proc_list->head; - do { - if (((struct proc *)iterator->data)->state != PROC_WAITING) - ret++; - } while ((iterator = iterator->next) != NULL); - return ret; -} - void proc_send(struct proc *src, struct proc *dest, enum message_type type, void *data) { // TODO: Use unique key instead of pid for IPC messaging @@ -115,8 +94,6 @@ void proc_send(struct proc *src, struct proc *dest, enum message_type type, void msg->msg->type = type; msg->msg->data = data; list_add(dest->messages, msg); - if (dest->state == PROC_WAITING) - dest->state = PROC_DEFAULT; } struct proc_message *proc_receive(struct proc *proc) @@ -198,6 +175,7 @@ void proc_init() struct node *new = list_add(proc_list, proc_make()); bin_load("/init", new->data); + current = new; _eip = ((struct proc *)new->data)->regs.eip; _esp = ((struct proc *)new->data)->regs.useresp; diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index b3af455..25770a4 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 && num != SYS_YIELD && num != SYS_WAIT && num != SYS_TIME) + if (num != SYS_RECEIVE && num != SYS_YIELD && num != SYS_TIME) printf("[SYSCALL] %d from %s: ", num, proc_current()->name); switch (num) { @@ -74,12 +74,6 @@ void syscall_handler(struct regs *r) proc_yield(r); break; } - case SYS_WAIT: { - /* printf("wait\n"); */ - proc_current()->state = PROC_WAITING; - proc_yield(r); - break; - } case SYS_TIME: { /* printf("time\n"); */ r->eax = timer_get(); diff --git a/kernel/inc/proc.h b/kernel/inc/proc.h index 9d4906d..89144ca 100644 --- a/kernel/inc/proc.h +++ b/kernel/inc/proc.h @@ -17,7 +17,7 @@ #define GDT_USER_CODE_OFFSET 0x1b // User code segment offset in GDT (with ring3 mask) #define GDT_USER_DATA_OFFSET 0x23 // User data segment offset in GDT (with ring3 mask) -enum proc_state { PROC_DEFAULT, PROC_WAITING }; +enum proc_state { PROC_DEFAULT }; struct proc { u32 pid; @@ -41,7 +41,6 @@ void scheduler_disable(); void proc_init(); void proc_print(); struct proc *proc_current(); -int proc_awake(); void proc_send(struct proc *src, struct proc *dest, enum message_type type, void *data); struct proc_message *proc_receive(struct proc *proc); struct proc *proc_from_pid(u32 pid); diff --git a/libc/inc/sys.h b/libc/inc/sys.h index 1b01127..073ccd2 100644 --- a/libc/inc/sys.h +++ b/libc/inc/sys.h @@ -16,7 +16,6 @@ enum sys { SYS_EXEC, // Execute path SYS_EXIT, // Exit current process SYS_YIELD, // Switch to next process - SYS_WAIT, // Sleep until new message arrives SYS_TIME, // Get kernel time SYS_REGISTER, // Register for event SYS_UNREGISTER, // Unregister event @@ -72,7 +71,6 @@ int sysv(enum sys num, ...); } \ } #define yield() (int)sys0(SYS_YIELD) -#define wait() (int)sys0(SYS_WAIT) #define time() (int)sys0(SYS_TIME) #define event_register(id) sys1(SYS_REGISTER, (int)(id)) |