Operating System Lecture Notes PDF

Document Details

EntrancingOnomatopoeia5884

Uploaded by EntrancingOnomatopoeia5884

Tags

operating systems process management scheduling computer science

Summary

These lecture notes provide an overview of operating systems concepts, focusing on processes, scheduling algorithms, and process control blocks. They cover process states, scheduling queues, and process control block (PCB) components. Great for understanding fundamental operating system principles.

Full Transcript

Computer dept./fourth class/third lecture/OS 3.1 Process A process or task is a program in execution. It is more than the program code,which is sometimes called text section.  The execution of a process must programs in a sequential manner. At any time at most one instruction is executed....

Computer dept./fourth class/third lecture/OS 3.1 Process A process or task is a program in execution. It is more than the program code,which is sometimes called text section.  The execution of a process must programs in a sequential manner. At any time at most one instruction is executed.  The process includes the current value of the program counter(pc) and the content of the processors registers.  Also it includes the process stack which contain temporary data (such as function parameters, return address and local variables) & a data section which contain global variables.  Morever, it contains a heap which is a memory that is dynamically allocated during process run time. Difference between process & program: A program by itself is not a process. A program in execution is known as a process.  A program is a passive entity, such as the contents of a file stored on disk where as process is an active entity with a program counter specifying the next instruction to execute and a set of associated resources may be shared among several process with some scheduling algorithm being used to determinate when the stop work on one process and service a different one. 3.2 Process state: As a process executes, it changes state. The state of a process is defined by the correct activity of that process. Each process may be in one of the following states. New: The process is being created. Ready: The process is waiting to be assigned to a processor. Running: Instructions are being executed. Waiting: The process is waiting for some event to occur. Terminated: The process has finished execution. Many processes may be in ready and waiting state at the same time. But only one process can be running on any processor at any instant. Fig.3.1 process states diagram 1 Computer dept./fourth class/third lecture/OS 3.3 Process Scheduling Queues Scheduling is a fundamental function of OS. When a computer is multiprogrammed, it has multiple processes completing for the CPU at the same time. If only one CPU is available, then a choice has to be made regarding which process to execute next. This decision making process is known as scheduling and the part of the OS that makes this choice is call in making this choice is called scheduling algorithm. Scheduling queues: As processes enter consists of all process in the system. The scheduling process queues are:- Job Queue: This queue consists of all processes in the system; those processes are entered to the system as new processes. Ready Queue: This queue consists of the processes that are residing in main memory and are ready and waiting to execute by CPU. This queue is generally stored as a linked list. A ready-queue header contains pointers to the first and final PCBs in the list. Each PCB includes a pointer field that points to the next PCB in the ready queue. Device Queue: This queue consists of the processes that are waiting for a particular I/O device. Each device has its own device queue. Fig.3.3 representation of process scheduling 3.4 Process Control Block (PCB) is a data structure that contains information of the process related to it. It is also, known as a task control block, entry of the process table are 1. Process state: The state may be new, ready, running, waiting, halted,. 2. Program counter: The counter indicates the address of the next instruction to be executed for this process. 3. CPU registers: The registers vary in number and type, depending on the computer architecture. They include accumulators, index registers, stack pointers, and general-purpose registers, plus any condition-code 2 Computer dept./fourth class/third lecture/OS information. Along with the program counter, this state information must be saved when an interrupt occurs, to allow the process to be continued correctly afterward. 4. CPU-scheduling information: This information includes a process priority, pointers to scheduling queues, and any other scheduling parameters. 5. Memory-management information: This information may include such information as the value of the base and limit registers, the page tables, or the segment tables, depending on the memory system used by the OS. 6. Accounting information: This information includes the amount of CPU and real time used, time limits, account numbers, job or process numbers. 7. status information: The information includes the list of I/O dev. allocated to this process, a list of open files, and so on. 3.5 Schedulers A scheduler is a decision maker that selects the processes from one scheduling queue to another or allocates CPU for execution. The Operating System has three types of scheduler: 1. Long-term scheduler or Job scheduler 2. Short-term scheduler or CPU scheduler 3. Medium-term scheduler Long-term scheduler or Job scheduler The long-term scheduler or job scheduler selects processes from discs and loads them into main memory for execution. It executes much less frequently. It controls the degree of multiprogramming (i.e., the number of processes in memory). Because of the longer interval between executions, the long-term scheduler can afford to take more time to select a process for execution. Short-term scheduler or CPU scheduler The short-term scheduler or CPU scheduler selects a process from among the processes that are ready to execute and allocates the CPU. The short-term scheduler must select a new process for the CPU frequently. A process may execute for only a few milliseconds before waiting for an I/O request. Medium-term scheduler The medium-term scheduler schedules the processes as intermediate level of scheduling Processes can be described as either: ✦I/O-bound process – spends more time doing I/O than computations, many short CPU bursts. ✦CPU-bound process – spends more time doing computations; few very long CPU bursts. 3

Use Quizgecko on...
Browser
Browser