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

Method schedule

lab8/src/6/src/kernel/program.cpp:93–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void ProgramManager::schedule()
94{
95 bool status = interruptManager.getInterruptStatus();
96 interruptManager.disableInterrupt();
97
98 if (readyPrograms.size() == 0)
99 {
100 interruptManager.setInterruptStatus(status);
101 return;
102 }
103 else
104 {
105 //printf("amount of ready programs: %d\n", readyPrograms.size());
106 }
107
108 if (running->status == ProgramStatus::RUNNING)
109 {
110 running->status = ProgramStatus::READY;
111 running->ticks = running->priority * 10;
112 readyPrograms.push_back(&(running->tagInGeneralList));
113 }
114 else if (running->status == ProgramStatus::DEAD)
115 {
116 // 回收线程,子进程留到父进程回收
117 if(!running->pageDirectoryAddress) {
118 releasePCB(running);
119 }
120 }
121
122 ListItem *item = readyPrograms.front();
123 PCB *next = ListItem2PCB(item, tagInGeneralList);
124 PCB *cur = running;
125 next->status = ProgramStatus::RUNNING;
126 running = next;
127 readyPrograms.pop_front();
128
129 //printf("schedule: %x %x\n", cur, next);
130
131 activateProgramPage(next);
132
133 asm_switch_thread(cur, next);
134
135 interruptManager.setInterruptStatus(status);
136}
137
138void program_exit()
139{

Callers 3

program_exitFunction · 0.45
PMethod · 0.45
c_time_interrupt_handlerFunction · 0.45

Calls 7

getInterruptStatusMethod · 0.45
disableInterruptMethod · 0.45
sizeMethod · 0.45
setInterruptStatusMethod · 0.45
push_backMethod · 0.45
frontMethod · 0.45
pop_frontMethod · 0.45

Tested by

no test coverage detected