* more re-work
[mascara-docs.git] / i386 / junos / ucla / src / lab3 / kern / sched.c
blobcedb0dfabca2e7f6a252dce421fddf99df6c496f
1 #include <inc/assert.h>
3 #include <kern/env.h>
4 #include <kern/pmap.h>
5 #include <kern/monitor.h>
7 // Choose a user environment to run and run it.
8 void
9 sched_yield(void)
11 // Implement simple round-robin scheduling.
12 // Search through 'envs' for a runnable environment,
13 // in circular fashion starting after the previously running env,
14 // and switch to the first such environment found.
15 // It's OK to choose the previously running env if no other env
16 // is runnable.
18 // LAB 3: Your code here.
20 // Run the special idle environment when nothing else is runnable.
21 if (envs[0].env_status == ENV_RUNNABLE)
22 env_run(&envs[0]);
23 else {
24 cprintf("Idle loop - nothing more to do!\n");
25 while (1)
26 monitor(NULL);