* more re-work
[mascara-docs.git] / i386 / junos / ucla / src / lab4 / user / spin.c
blob57c819fcd686f8ab0268a73000db575f20a3f701
1 // Test preemption by forking off a child process that just spins forever.
2 // Let it run for a couple time slices, then kill it.
4 #include <inc/lib.h>
6 asmlinkage void
7 umain(int argc, char **argv)
9 envid_t env;
11 cprintf("I am the parent. Forking the child...\n");
12 if ((env = fork()) == 0) {
13 cprintf("I am the child. Spinning...\n");
14 while (1)
15 /* do nothing */;
18 cprintf("I am the parent. Running the child...\n");
19 sys_yield();
20 sys_yield();
21 sys_yield();
22 sys_yield();
23 sys_yield();
24 sys_yield();
25 sys_yield();
26 sys_yield();
28 cprintf("I am the parent. Killing the child...\n");
29 sys_env_destroy(env);