Document Details

DazzlingBrazilNutTree

Uploaded by DazzlingBrazilNutTree

Polytechnic University of the Philippines

Ma. Ymelda C. Batalla

Tags

process management operating systems computer science CPU scheduling

Summary

This document is a lecture on process management, specifically for COMP 007. It gives an overview of different concepts related to process management. The lecture material is suitable for computer science or information technology related courses at an undergraduate level at the Polytechnic University of the Philippines.

Full Transcript

COMP 007 - Week 3 to 6 Process Management Prepared by: Asst. Prof. Ma. Ymelda C. Batalla, MIT Faculty POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS At the end of the lesson,...

COMP 007 - Week 3 to 6 Process Management Prepared by: Asst. Prof. Ma. Ymelda C. Batalla, MIT Faculty POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS At the end of the lesson, the student will be able to: ▪ Describe the process states, operations and queues; ▪ Compare the two CPU scheduling category; and ▪ Solve the different CPU scheduling algorithm problems. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Introduction POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Introduction Process management is one of the essential functions of the operating systems that handles the creation, proper scheduling, and completion of each process. Let’s explore the life cycle of each process, and the different CPU algorithms. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Program vs Process POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Program vs Process A program is an inactive unit or passive entity, such as a file stored on a disk. It is also called a job, which is a unit of work that has been submitted by the user. A process is an active entity that requires a set of resources, including a processor (CPU), main memory, etc., to perform its function. It is also called a task, which is a single instance of a program in execution. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS What is a Processor Manager? A processor manager is responsible for managing and allocating the Central Processing Unit (CPU) resources to the incoming jobs to be executed. Its primary function is to ensure that each process is executed efficiently and fairly. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Components of Process Layout ▪ Memory Layout ▪ Scheduler ▪ Dispatcher ▪ Timer ▪ Process Control Block (PCB) ▪ Process States ▪ Process Scheduling POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Memory Layout of a Process ▪ Text Section – contains executable code in a program ▪ Data Section – contains global and static variables used by the program ▪ Heap Section – a dynamically allocated memory during runtime ▪ Stack Section – contains temporary storage when invoking a function Silberschatz, A. et al. (2018). POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Process Scheduler ▪ Long-Term Scheduler A long-term scheduler is also known as job scheduler. It is the high-level scheduler that selects jobs from a queue of incoming jobs in the secondary memory and place them in the ready queue. It mainly controls the degree of multiprogramming. Also, it selects the best combination of I/O and CPU resources needed by the each job. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Process Scheduler (continuation) ▪ Short-Term Scheduler A short-term scheduler is also known as CPU scheduler. It is a low-level scheduler that assigns the CPU to execute the processes of those jobs placed on the ready queue by the job scheduler. This scheduler use an algorithm to select which job will be send for execution. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Process Scheduler (continuation) ▪ Medium-Term Scheduler A medium-term scheduler handles the swapping of each process in and out of the memory. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Dispatcher The dispatcher is responsible for the switching of the CPU (context switching) from one process to another. Once the short-term scheduler determines the next process to run, the dispatcher handles the loading of the subsequent process onto the CPU and managing the transition between processes. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Timer The timer is responsible for keeping track of the time each process has been running, or the time allocated for each process to use the CPU. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Process Control Block A process control block (PCB) is used to store a collection of information about each process that is called the data structure. The PCB is essential for process management, especially during context switching and it is used by the CPU during runtime. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Components of PCB ▪ Process Identification ▪ The OS assigns each process a unique ID to easily identify other existing processes. ▪ Process State ▪ It is information that indicates the current status of each process, such as new, ready, running, waiting, and termination. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Components of PCB (continuation) ▪ Process Counter ▪ It contains the address that points to the next instruction of the process that needs to be executed. ▪ CPU Registers ▪ It stores the contents of all the CPU registers, where these are the current working values of each variables of the process. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Components of PCB (continuation) ▪ Process Priority ▪ It is a numeric value that represents the priority of each process. ▪ Process I/O Status Information ▪ It is a list of all the I/O devices needed by the process during execution. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Components of PCB (continuation) ▪ Process Accounting Information ▪ It contains information that is used for performance measurement, such as the amount of CPU time consumed, the total time spent from the new state to the terminated state (including waiting time), the number and type of I/O used, the memory space occupied, and the utilities used. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Components of PCB (continuation) ▪ Process Pointer ▪ This contains the address of the next PCB, which is now in the ready state. ▪ Process Memory Management Information ▪ This contains the information about the process memory allocation. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Components of PCB (continuation) ▪ CPU Scheduling Information ▪ This contains all the information related to scheduling parameters such as non-preemptive or preemptive scheduling. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Process States Silberschatz, A. et al. (2018). POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Process States (continuation) ▪ A new state is where a program is going to be picked up by the long-term scheduler from the secondary memory that will be placed in the main memory is called a new process. ▪ A ready state is where a process is placed inside the main memory by the long-term scheduler and ready for execution while waiting for the CPU. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Process States (continuation) ▪ A running state is where the CPU is now executing the process. Before the CPU can execute a process, the short-term scheduler is responsible for selecting which processes can be dispatched from the ready state to the running state using the scheduling algorithm. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Process States (continuation) ▪ A waiting state is where the CPU will stop the execution of the process due to an I/O request from the process or due to the scheduling algorithm, where the medium-scheduler is responsible for handling this case. ▪ A completion or termination state is where a process finish its execution. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Process Scheduling Process scheduling is a technique used by the operating system in executing every process to allocate the CPU time. Category of CPU Scheduling: ▪ Non-Preemptive ▪ Preemptive POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Category of CPU Scheduling ▪ Non-Preemptive In non-preemptive scheduling, a running process cannot be disturbed and continues to execute until it completes its execution. ▪ Preemptive In preemptive scheduling, the CPU can be interrupted during the running state of each process and allocated to another process with a higher-priority process, or it may exceed the provided time slice for each process. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Goals of CPU Scheduling ▪ Maximum CPU utilization ▪ Maximum throughput ▪ Minimum turnaround time ▪ Minimum waiting time ▪ Minimum response time ▪ Fare allocation of CPU POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS CPU Scheduling Algorithm ▪ First-Come, First Serve (FCFS) ▪ Shortest Job First (SJF) / Shortest Job Next (SJN) / Shortest Remaining Time (SRT) ▪ Priority ▪ Round Robin (RR) ▪ Highest Response Ratio Next (HRRN) POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS CPU Scheduling Algorithm (continuation) First-Come, First Serve (FCFS) is a non- preemptive scheduling algorithm that handles jobs according to their arrival time; the earlier they arrive, the sooner they’re served. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS CPU Scheduling Algorithm (continuation) Shortest Job First (SJF) is a non-preemptive or preemptive scheduling algorithm, also known as Shortest Job Next (SJN) or shortest remaining time (SRT), that handles jobs based on the length of their CPU cycle time. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS CPU Scheduling Algorithm (continuation) Priority scheduling is a non-preemptive or preemptive algorithm and one of the most common scheduling algorithms that gives preferential treatment to important jobs. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS CPU Scheduling Algorithm (continuation) Round Robin (RR) is a preemptive process scheduling algorithm that is used extensively in interactive systems. It gives a predetermined slice of time that’s given to each process to ensure that the CPU is equally shared among all active processes and isn’t monopolized by any one process. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS CPU Scheduling Algorithm (continuation) Highest Response Ratio Next (HRRN) is a non- preemptive scheduling algorithm that uses the response ratio as an additional parameter, giving priority to other processes with the highest response ratio value. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Different Time Related to Process ▪ Arrival Time (AT) It is the time when the process enters the ready queue. ▪ Burst Time (BT) It is the total time needed for each process to be executed by the CPU. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Different Time Related to Process ▪ Completion Time (CT) It is a time when a process completes or finishes its execution. ▪ Turnaround Time (TAT) It is the total time spent by each process from its arrival time to its completion. Formula: TAT = CT - AT POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Different Time Related to Process ▪ Waiting Time (WT) It is the total amount of time that each process waits to be assigned to the CPU. Formula: WT = TAT - BT ▪ Response Time (RT) It is the amount of time from the arrival time going to the CPU for the first time. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS References: ▪ Holcombe, J. (2020). Operating Systems, 6e. McGraw Hill Education ▪ Barnes, R. (2020). Understanding Operating Systems. Lanrye International ▪ Tomsho, G. (2019). Guide to Operating Systems. Cengage ▪ Silberschatz, A. et al. (2018). Operating System Concepts, 1oth edition. John Wiley & Sons, Inc. POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS References: ▪ https://www.javatpoint.com/process-management-in-os ▪ https://www.w3schools.in/operating-system/process- management ▪ https://www.geeksforgeeks.org/introduction-of-process- management/ ▪ https://www.scaler.com/topics/operating-system/process- control-block-in-os/ POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS Thank you! POLYTECHNIC UNIVERSITY OF THE PHILIPPINES SANTA ROSA CAMPUS

Use Quizgecko on...
Browser
Browser