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

Function setup_kernel

lab8/src/5/src/kernel/setup.cpp:68–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68extern "C" void setup_kernel()
69{
70
71 // 中断管理器
72 interruptManager.initialize();
73 interruptManager.enableTimeInterrupt();
74 interruptManager.setTimeInterrupt((void *)asm_time_interrupt_handler);
75
76 // 输出管理器
77 stdio.initialize();
78
79 // 进程/线程管理器
80 programManager.initialize();
81
82 // 初始化系统调用
83 systemService.initialize();
84 // 设置0号系统调用
85 systemService.setSystemCall(0, (int)syscall_0);
86 // 设置1号系统调用
87 systemService.setSystemCall(1, (int)syscall_write);
88 // 设置2号系统调用
89 systemService.setSystemCall(2, (int)syscall_fork);
90 // 设置3号系统调用
91 systemService.setSystemCall(3, (int)syscall_exit);
92
93 // 内存管理器
94 memoryManager.initialize();
95
96 // 创建第一个线程
97 int pid = programManager.executeThread(first_thread, nullptr, "first thread", 1);
98 if (pid == -1)
99 {
100 printf("can not execute thread\n");
101 asm_halt();
102 }
103
104 ListItem *item = programManager.readyPrograms.front();
105 PCB *firstThread = ListItem2PCB(item, tagInGeneralList);
106 firstThread->status = ProgramStatus::RUNNING;
107 programManager.readyPrograms.pop_front();
108 programManager.running = firstThread;
109 asm_switch_thread(0, firstThread);
110
111 asm_halt();
112}

Callers

nothing calls this directly

Calls 8

printfFunction · 0.70
initializeMethod · 0.45
enableTimeInterruptMethod · 0.45
setTimeInterruptMethod · 0.45
setSystemCallMethod · 0.45
executeThreadMethod · 0.45
frontMethod · 0.45
pop_frontMethod · 0.45

Tested by

no test coverage detected