LAB 4 IS DONE.

This commit is contained in:
winPond
2019-07-06 10:39:40 +08:00
parent 21dd0e1a51
commit e78b336ba8
113 changed files with 11622 additions and 0 deletions

31
lab/user/spin.c Normal file
View File

@@ -0,0 +1,31 @@
// Test preemption by forking off a child process that just spins forever.
// Let it run for a couple time slices, then kill it.
#include <inc/lib.h>
void
umain(int argc, char **argv)
{
envid_t env;
cprintf("I am the parent. Forking the child...\n");
if ((env = fork()) == 0) {
cprintf("I am the child. Spinning...\n");
while (1)
/* do nothing */;
}
cprintf("I am the parent. Running the child...\n");
sys_yield();
sys_yield();
sys_yield();
sys_yield();
sys_yield();
sys_yield();
sys_yield();
sys_yield();
cprintf("I am the parent. Killing the child...\n");
sys_env_destroy(env);
}