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

Function load_process

lab8/src/3/src/kernel/program.cpp:289–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289void load_process(const char *filename)
290{
291 interruptManager.disableInterrupt();
292
293 PCB *process = programManager.running;
294 ProcessStartStack *interruptStack =
295 (ProcessStartStack *)((int)process + PAGE_SIZE - sizeof(ProcessStartStack));
296
297 interruptStack->edi = 0;
298 interruptStack->esi = 0;
299 interruptStack->ebp = 0;
300 interruptStack->esp_dummy = 0;
301 interruptStack->ebx = 0;
302 interruptStack->edx = 0;
303 interruptStack->ecx = 0;
304 interruptStack->eax = 0;
305 interruptStack->gs = 0;
306
307 interruptStack->fs = programManager.USER_DATA_SELECTOR;
308 interruptStack->es = programManager.USER_DATA_SELECTOR;
309 interruptStack->ds = programManager.USER_DATA_SELECTOR;
310
311 interruptStack->eip = (int)filename;
312 interruptStack->cs = programManager.USER_CODE_SELECTOR; // 用户模式平坦模式
313 interruptStack->eflags = (0 << 12) | (1 << 9) | (1 << 1); // IOPL, IF = 1 开中断, MBS = 1 默认
314
315 interruptStack->esp = memoryManager.allocatePages(AddressPoolType::USER, 1);
316 if (interruptStack->esp == 0)
317 {
318 printf("can not build process!\n");
319 process->status = ProgramStatus::DEAD;
320 asm_halt();
321 }
322 interruptStack->esp += PAGE_SIZE;
323 interruptStack->ss = programManager.USER_STACK_SELECTOR;
324
325 asm_start_process((int)interruptStack);
326}
327
328void ProgramManager::activateProgramPage(PCB *program)
329{

Callers

nothing calls this directly

Calls 3

printfFunction · 0.70
disableInterruptMethod · 0.45
allocatePagesMethod · 0.45

Tested by

no test coverage detected