summaryrefslogtreecommitdiff
path: root/src/kernel/proc.c
diff options
context:
space:
mode:
authordzwdz2023-01-18 23:18:49 +0100
committerdzwdz2023-01-18 23:18:49 +0100
commit1e261597a5c5f9803a65a5b13dd71d33d501f010 (patch)
tree50de2741a4917e21427c7920fa33e0372129de92 /src/kernel/proc.c
parentec81fa16d837f430add92b4d2ee4bd3727ca6c6d (diff)
kernel: add a root argument to process_next
Diffstat (limited to 'src/kernel/proc.c')
-rwxr-xr-xsrc/kernel/proc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index 408e3d0..acefeb9 100755
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -295,7 +295,7 @@ _Noreturn void process_switch_any(void) {
if (process_current && process_current->state == PS_RUNNING)
process_switch(process_current);
- for (struct process *p = process_first; p; p = process_next(p)) {
+ for (struct process *p = process_first; p; p = process_next(p, NULL)) {
if (p->state == PS_RUNNING)
process_switch(p);
}
@@ -304,7 +304,7 @@ _Noreturn void process_switch_any(void) {
}
}
-struct process *process_next(struct process *p) {
+struct process *process_next(struct process *p, struct process *root) {
/* depth-first search, the order is:
* 1
* / \
@@ -319,7 +319,8 @@ struct process *process_next(struct process *p) {
/* looking at the diagram above - we're at 4, want to find 5 */
while (!p->sibling) {
p = p->parent;
- if (!p) return NULL;
+ if (root) assert(p);
+ if (!p || p == root) return NULL;
}
return p->sibling;
}