A Step By Step Picture of How Processes Schedule (Using Test4 and TestX as examples) Version 4.40: September 2017.

Slides:



Advertisements
Similar presentations
OPERATING SYSTEMS PROCESSES
Advertisements

CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
The Operating System Project Start Here Version 4.10: September 2014.
Processes 1 CS502 Spring 2006 Processes Week 2 – CS 502.
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Slides by Magnus Almgren Introduction to Lab 2 EDA092 – Operating Systems Wolfgang John.
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
CS1550 Assignment 5 Multiprogramming Implementation notes Matt Craven.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Chapter 4 Processes. Process: what is it? A program in execution A program in execution usually usually Can also have suspended or waiting processes Can.
1 RTOS Design Some of the content of this set of slides is taken from the documentation existing on the FreeRTOS website
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Tami Meredith, Ph.D. CSCI  Devices need CPU access  E.g., NIC has a full buffer it needs to empty  These device needs are often asynchronous.
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
The act of Scheduling a process means changing the active PCB pointed to by the CPU. Also called a context switch. A context switch is essentially the.
CIS250 OPERATING SYSTEMS Chapter 6 - CPU Scheduling Basic Concepts The objective of multi-programming is have a program running at all times Maximize.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
The Operating System Project Start Here Version 4.20: September 2015.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Processes 2 Introduction to Operating Systems: Module 4.
The OS 215 Project. 2 OS 215 Project Outline Architecture of the Simulator Environment Z215 Hardware Organization and Architecture Generic Operating System.
Process Control Management Prepared by: Dhason Operating Systems.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
CS162 Section 2. True/False A thread needs to own a semaphore, meaning the thread has called semaphore.P(), before it can call semaphore.V() False: Any.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Process Synchronization. Concurrency Definition: Two or more processes execute concurrently when they execute different activities on different devices.
Multiprogramming. Readings r Chapter 2.1 of the textbook.
REAL-TIME OPERATING SYSTEMS
Processes and threads.
Process concept.
CS 6560: Operating Systems Design
CS703 – Advanced Operating Systems
Advanced OS Concepts (For OCR)
Operating systems - Processes
OPERATING SYSTEMS CS3502 Fall 2017
Day 08 Processes.
Day 09 Processes.
Event Driven Programming Dick Steflik
Intro to Processes CSSE 332 Operating Systems
Real-time Software Design
Structure of Processes
The Execution Of Sleep()
Introduction What is an operating system bootstrap
OPERATING SYSTEMS PROCESSES
Processor Fundamentals
Operating systems - Processes
Process & its States Lecture 5.
PROCESS MANAGEMENT Information maintained by OS for process management
Multithreaded Programming
CPU SCHEDULING.
Lecture Topics: 11/1 General Operating System Concepts Processes
Implementing Mutual Exclusion
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Implementing Mutual Exclusion
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
CS333 Intro to Operating Systems
Chapter 5: CPU Scheduling
Use-Case Design in Context
Process Description and Control in Unix
Process Description and Control in Unix
Chapter 3: Processes Process Concept Process Scheduling
Presentation transcript:

A Step By Step Picture of How Processes Schedule (Using Test4 and TestX as examples) Version 4.40: September 2017

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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