MCPcopy Create free account
hub / github.com/YatSenOS/YatSenOS-Tutorial-Volume-1 / first_process

Function first_process

lab8/src/6/src/kernel/setup.cpp:31–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void first_process()
32{
33 int pid = fork();
34 int retval;
35
36 if (pid)
37 {
38 pid = fork();
39 if (pid)
40 {
41 while ((pid = wait(&retval)) != -1)
42 {
43 printf("wait for a child process, pid: %d, return value: %d\n", pid, retval);
44 }
45
46 printf("all child process exit, programs: %d\n", programManager.allPrograms.size());
47
48 asm_halt();
49 }
50 else
51 {
52 uint32 tmp = 0xffffff;
53 while (tmp)
54 --tmp;
55 printf("exit, pid: %d\n", programManager.running->pid);
56 exit(123934);
57 }
58 }
59 else
60 {
61 uint32 tmp = 0xffffff;
62 while (tmp)
63 --tmp;
64 printf("exit, pid: %d\n", programManager.running->pid);
65 exit(-123);
66 }
67}
68
69void second_thread(void *arg)
70{

Callers

nothing calls this directly

Calls 5

forkFunction · 0.70
waitFunction · 0.70
printfFunction · 0.70
exitFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected