Download presentation
Presentation is loading. Please wait.
Published byPercival Carson Modified over 6 years ago
1
A Step By Step Picture of How Processes Schedule (Using Test4 and TestX as examples)
Version 4.40: September 2017
2
A Step By Step Picture of How Processes Schedule (Using Test4 and TestX as examples)
Here are the assumptions we’re using: To keep it simple, Test4 will start only ONE TestX. The dispatcher has a mechanism as we talked about in class – this allows the simulator’s clock to advance. While (NothingOnReadyQ() ) { CALL(WasteTime(); } The “times” listed are made up – may not be real. Remember CODE is static – PROCESSES are moving around.
3
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code Test4 osCreateProcess Time = 50 Test4 has created TestX and put the TestX PCB on the ready Q. Test4 Does a Sleep(1000) Ready Queue SVC TestX PCB Dispatcher Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Z502Timer Z502StartContext Hardware Interrupt Code TestX Interrupt
4
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 73 Test4 puts its PCB on timer Q Test4 starts the timer. Ready Queue SVC TestX PCB Dispatcher Make_Ready_ To_Run Timer Queue Test4 Start Timer InterruptHandler Test4 PCB T = 1073 T = 1000 Z502Timer Z502StartContext Hardware Interrupt Code Delay = 1000, Interrupt at 1073 TestX Interrupt
5
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 79 Test4 finds TestX PCB on ready Does a StartContext(Test4) after which Test4 is suspended in the hardware Ready Queue SVC Dispatcher Test4 Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Test4 PCB T = 1073 StartContext(Test4) Z502Timer Z502StartContext Hardware Interrupt Code Delay = 1000, Interrupt at 1073 TestX Interrupt
6
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code TestX osCreateProcess Time = 85 Process TestX in TestX code. TestX does a Sleep(500) Ready Queue SVC Dispatcher Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Test4 PCB T = 1073 Z502Timer Z502StartContext Hardware Interrupt Code Delay = 1000, Interrupt at 1073 Test4 Interrupt
7
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 93 Process TestX in StartTimer. The new sleep is sooner than the existing one. Put new time on head of timer Q Replace the current timer value with the new time. Ready Queue SVC Dispatcher Make_Ready_ To_Run Timer Queue TestX Start Timer InterruptHandler TestX PCB T = 593 Test4 PCB T = 1073 Delay = 500 Z502Timer Z502StartContext Hardware Interrupt Code Delay = 500, Interrupt at 593 Test4 Interrupt
8
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 101 Nothing on Ready Q TestX executes while() Call loop – see page 1 Ready Queue SVC Dispatcher TestX Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler TestX PCB T = 593 Test4 PCB T = 1073 Z502Timer Z502StartContext Hardware Interrupt Code Delay = 500, Interrupt at 593 Test4 Interrupt
9
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 597 Interrupt in Interrupt Handler Remove TestX PCB from head of timer Q Ready Queue SVC Dispatcher TestX Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Interrupt Test4 PCB T = 1073 Z502Timer Z502StartContext Hardware Interrupt Code Timer Not Active Test4
10
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 598 Interrupt in Make Ready Puts TestX PCB on Ready Q Ready Queue SVC TestX PCB Dispatcher TestX Make_Ready_ To_Run Interrupt Timer Queue Start Timer InterruptHandler Test4 PCB T = 1073 Z502Timer Z502StartContext Hardware Interrupt Code Timer Not Active Test4
11
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 600 Interrupt in InterruptHandler Puts new delay time in the timer Delay is 1073 – 600 = 473 Ready Queue SVC TestX PCB Dispatcher TestX Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Interrupt Test4 PCB T = 1073 Delay = 473 Z502Timer Z502StartContext Hardware Interrupt Code Delay =473, Interrupt at 1073 Test4
12
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 601 TestX sees PCB on Ready Q and removes it Does StartContext(TestX) Hardware knows this context is already running and simply returns Ready Queue SVC Dispatcher TestX Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Test4 PCB T = 1073 StartContext(TestX) Z502Timer Z502StartContext Hardware Interrupt Code Delay =473, Interrupt at 1073 Test4 Interrupt
13
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 603 TestX returns all the way back to TestX code. Ready Queue SVC Dispatcher TestX Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Test4 PCB T = 1073 Z502Timer Z502StartContext Hardware Interrupt Code Delay =473, Interrupt at 1073 Test4 Interrupt
14
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code TestX osCreateProcess Time = 603 TestX does Sleep(463) Ready Queue SVC Dispatcher Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Test4 PCB T = 1073 Z502Timer Z502StartContext Hardware Interrupt Code Delay =473, Interrupt at 1073 Test4 Interrupt
15
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 612 TestX puts its PCB on Timer Q (note the order) NO NEED to restart timer Ready Queue SVC Dispatcher Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Test4 PCB T = 1073 TestX PCB T = 1075 TestX Z502Timer Z502StartContext Hardware Interrupt Code Delay =473, Interrupt at 1073 Test4 Interrupt
16
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 620 Nothing on Ready Q TestX executes the while CALL loop Ready Queue SVC Dispatcher TestX Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Test4 PCB T = 1073 TestX PCB T = 1075 Z502Timer Z502StartContext Hardware Interrupt Code Delay =473, Interrupt at 1073 Test4 Interrupt
17
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 1077 Interrupt in InterruptHandler Removes first PCB on Timer Q Ready Queue SVC Dispatcher TestX Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Interrupt Test4 PCB T = 1073 TestX PCB T = 1075 Z502Timer Z502StartContext Hardware Interrupt Code Nothing on Timer Test4
18
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 1079 Interrupt Thread in MakeReady Puts Test4 on Ready Q Ready Queue SVC Test4 PCB Dispatcher TestX Make_Ready_ To_Run Interrupt Timer Queue Start Timer InterruptHandler TestX PCB T = 1075 Z502Timer Z502StartContext Hardware Interrupt Code Nothing on Timer Test4
19
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 1081 Interrupt in InterruptHandler Current time is AFTER when next interrupt would occur, so no need to start timer. Simply take this PCB off the timer Q. Ready Queue SVC Test4 PCB Dispatcher TestX Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Interrupt Z502Timer Z502StartContext Hardware Interrupt Code Nothing on Timer Test4
20
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 1083 Interrupt in MakeReady Puts TestX PCB on Ready Q in proper priority order. The Interrupt is now done. Ready Queue SVC Test4 PCB TestX PCB Dispatcher TestX Make_Ready_ To_Run Interrupt Timer Queue Start Timer InterruptHandler Z502Timer Z502StartContext Hardware Interrupt Code Nothing on Timer Test4
21
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 1090 TestX thread now removes the first item on the Ready Q. TestX process calls hardware StartContext to begin running the new process. Ready Queue SVC TestX PCB Dispatcher TestX Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler StartContext(Test4) Z502Timer Z502StartContext Hardware Interrupt Code Nothing on Timer Test4 Interrupt
22
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code Test4 osCreateProcess Time = 1095 Test4 process is now running and returns all the way back to user code. Ready Queue SVC TestX PCB Dispatcher Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Z502Timer Z502StartContext Hardware Interrupt Code Nothing on Timer TestX Interrupt
23
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code Test4 osCreateProcess Time = 1100 Test4 does a Sleep(1000) Ready Queue SVC TestX PCB Dispatcher Make_Ready_ To_Run Timer Queue Start Timer InterruptHandler Z502Timer Z502StartContext Hardware Interrupt Code Nothing on Timer TestX Interrupt
24
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess Time = 1110 Test4 in StartTimer Puts its PCB on the Timer Q Ready Queue SVC TestX PCB Dispatcher Make_Ready_ To_Run Test4 Timer Queue Start Timer InterruptHandler Test4 PCB T = 2110 Delay = 1000 Z502Timer Z502StartContext Hardware Interrupt Code Delay =1000, Interrupt at 2110 TestX Interrupt
25
Hardware Interrupt Code
Yellow is CODE, Blues are Queues and Queue Elements, Red shows where a process is currently executing or suspended. Test4 code TestX code osCreateProcess You should now be able to predict the next steps and write code that performs the way described in the previous slides. Ready Queue SVC TestX PCB Dispatcher Make_Ready_ To_Run Test4 Timer Queue Start Timer InterruptHandler Test4 PCB T = 2110 Z502Timer Z502StartContext Hardware Interrupt Code Delay =1000, Interrupt at 2110 TestX Interrupt
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.