diff options
author | dzwdz | 2022-08-04 15:58:54 +0200 |
---|---|---|
committer | dzwdz | 2022-08-04 15:58:54 +0200 |
commit | 81a58004d51547d074b4218f906b0b95f2b2c5dc (patch) | |
tree | 4301047fc342e165bc5a043a04b5fed44b8e8084 /src/kernel/proc.c | |
parent | 4a844820866094ff7d57435a16b7c23a9126814d (diff) |
syscalls: add _syscall_sleep()
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r-- | src/kernel/proc.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c index e7a5ed6..3bf2b0d 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -132,6 +132,9 @@ void process_kill(struct process *p, int ret) { *iter = p->waits4pipe.next; } + if (p->state == PS_WAITS4TIMER) + timer_deschedule(p); + for (handle_t h = 0; h < HANDLE_MAX; h++) handle_close(p->handles[h]); @@ -217,14 +220,15 @@ static _Noreturn void process_switch(struct process *proc) { } _Noreturn void process_switch_any(void) { - if (process_current && process_current->state == PS_RUNNING) - process_switch(process_current); + for (;;) { + if (process_current && process_current->state == PS_RUNNING) + process_switch(process_current); - struct process *found = process_find(PS_RUNNING); - if (found) process_switch(found); + struct process *found = process_find(PS_RUNNING); + if (found) process_switch(found); - cpu_pause(); - process_switch_any(); + cpu_pause(); + } } struct process *process_next(struct process *p) { @@ -284,6 +288,7 @@ void process_transition(struct process *p, enum process_state state) { case PS_WAITS4FS: case PS_WAITS4REQUEST: case PS_WAITS4PIPE: + case PS_WAITS4TIMER: assert(last == PS_RUNNING); break; |