* same with xv6
[mascara-docs.git] / i386 / ucla / src / lab4 / user / idle.c
blob9b7e904248270c9256793cc61ff75d09fca17cc4
1 // idle loop
3 #include <inc/x86.h>
4 #include <inc/lib.h>
6 asmlinkage void
7 umain(int argc, char **argv)
9 binaryname = "idle";
11 // Loop forever, simply trying to yield to a different environment.
12 // Instead of busy-waiting like this,
13 // a better way would be to use the processor's HLT instruction
14 // to cause the processor to stop executing until the next interrupt -
15 // doing so allows the processor to conserve power more effectively.
16 while (1) {
17 sys_yield();
19 // Break into the JOS kernel monitor after each sys_yield().
20 // A real, "production" OS of course would NOT do this -
21 // it would just endlessly loop waiting for hardware interrupts
22 // to cause other environments to become runnable.
23 // However, in JOS it is easier for testing and grading
24 // if we invoke the kernel monitor after each iteration,
25 // because the first invocation of the idle environment
26 // usually means everything else has run to completion.
27 breakpoint();