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

Function setup_kernel

lab8/src/4/src/kernel/setup.cpp:62–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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