summaryrefslogtreecommitdiff
path: root/src/kernel/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r--src/kernel/proc.c17
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;