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

Function setup_kernel

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

Source from the content-addressed store, hash-verified

82}
83
84extern "C" void setup_kernel()
85{
86
87 // 中断管理器
88 interruptManager.initialize();
89 interruptManager.enableTimeInterrupt();
90 interruptManager.setTimeInterrupt((void *)asm_time_interrupt_handler);
91
92 // 输出管理器
93 stdio.initialize();
94
95 // 进程/线程管理器
96 programManager.initialize();
97
98 // 初始化系统调用
99 systemService.initialize();
100 // 设置0号系统调用
101 systemService.setSystemCall(0, (int)syscall_0);
102 // 设置1号系统调用
103 systemService.setSystemCall(1, (int)syscall_write);
104 // 设置2号系统调用
105 systemService.setSystemCall(2, (int)syscall_fork);
106 // 设置3号系统调用
107 systemService.setSystemCall(3, (int)syscall_exit);
108 // 设置4号系统调用
109 systemService.setSystemCall(4, (int)syscall_wait);
110
111 // 内存管理器
112 memoryManager.initialize();
113
114 // 创建第一个线程
115 int pid = programManager.executeThread(first_thread, nullptr, "first thread", 1);
116 if (pid == -1)
117 {
118 printf("can not execute thread\n");
119 asm_halt();
120 }
121
122 ListItem *item = programManager.readyPrograms.front();
123 PCB *firstThread = ListItem2PCB(item, tagInGeneralList);
124 firstThread->status = ProgramStatus::RUNNING;
125 programManager.readyPrograms.pop_front();
126 programManager.running = firstThread;
127 asm_switch_thread(0, firstThread);
128
129 asm_halt();
130}

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