Lesson 6 - Dispatchers and Processor Queue.pptx

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

DISPATCHERS AND PROCESSOR QUEUE DISPATCHERS The dispatcher is a critical part of the operating system. Its job is to hand control of the CPU to the process that was selected by the short-term scheduler. This module is responsible for getting the process ready to start o...

DISPATCHERS AND PROCESSOR QUEUE DISPATCHERS The dispatcher is a critical part of the operating system. Its job is to hand control of the CPU to the process that was selected by the short-term scheduler. This module is responsible for getting the process ready to start or continue its execution. To ensure the system runs efficiently, the dispatcher must be fast and lightweight. PROCESS STATES  Switching context: This means saving the current state of the CPU (which process was running, where it left off) and loading the state of the next process to be executed. Example: Process A is currently using the CPU. Before Process B starts, the dispatcher saves Process A's state (program counter, register values) and loads Process B's state, allowing Process B to take over.  Switching to user mode: Once the process is ready, the dispatcher switches the CPU from kernel mode (OS control) to user mode (process control) so the program can safely execute without harming the system. Example: When Process B starts running, the CPU moves from kernel mode (OS control) to user mode (Process B's control). PROCESS STATES  Jumping to the correct location in the user program: The dispatcher restarts the process at the exact point where it left off by moving the program counter to the right instruction in the process’s code. Example: Process B was interrupted after instruction 100. The dispatcher will make sure Process B starts again from instruction 101 when it's given the CPU. PROCESSOR QUEUES Processor queues are lists where processes are stored while they are waiting to be executed. There are multiple types of queues based on the status of the process: 1.Job queue: This queue holds all the processes in the system, including both new processes waiting to be loaded into memory and those waiting for other resources. Example: A process that has just started and is waiting for CPU time will sit in the job queue. 2.Ready queue: This queue holds processes that are in memory and are ready to run but are waiting for the CPU. This is usually implemented as a linked list with pointers to each process's Process Control Block (PCB). Example: If Process C is ready to run but Process B is currently using the CPU, Process C will be in the ready queue until it gets a chance to execute. PROCESSOR QUEUES 3. Device queue: Processes waiting for a specific I/O device (like a printer or disk) are placed in this queue. Each device has its own device queue. Example: If Process D is waiting for data from the hard drive, it will be in the disk's device queue until the disk is free. TYPES OF PROCESSOR QUEUE MECHANISMS  Single Queue Mechanism: This is a simple policy where all processes, regardless of type, wait in a single queue. The OS processes them in the order they arrive, giving all users equal service. Example: In a first-come, first-served system, Process A, Process B, and Process C are handled in the order they enter the queue, regardless of how long each takes. TYPES OF PROCESSOR QUEUE MECHANISMS  Input (Batch Job Arrival): Input represents the start of a process. This could be a batch job arriving into the system or an interactive user process starting. When a new process enters, it is placed in the Ready queue.  Ready: Processes that are ready to run but are waiting for the CPU are stored in this state. The dispatcher selects a process from the Ready state to move to the Run state, where the process gets CPU time to execute. Example: If Process A and Process B are ready to run, they will both be in the Ready queue, and the dispatcher will pick which one gets to execute based on scheduling policies. TYPES OF PROCESSOR QUEUE MECHANISMS  Run: This is the state where the selected process is actually executing (running on the CPU). The process will continue running until one of three things happens: It terminates (completes). It becomes blocked (waiting for an event like I/O). It is preempted (interrupted) to allow another process to run. Example: If Process A is in the Run state, it is actively using the CPU. If it needs to wait for an I/O operation (like reading from the disk), it will move to the Blocked state. TYPES OF PROCESSOR QUEUE MECHANISMS  Blocked: Processes that are waiting for a certain event (e.g., I/O completion, data availability) are placed in the Blocked state. They remain here until the event occurs. Once the event they are waiting for is complete, the process is "woken up" and moved back to the Ready queue to wait for CPU time again. Example: If Process A needs data from the disk, it will move from the Run state to the Blocked state until the I/O operation is done. TYPES OF PROCESSOR QUEUE MECHANISMS  Wake Up: When the event that caused the process to be blocked (e.g., I/O operation) is completed, the process is woken up and sent back to the Ready queue. Example: Once Process A's disk I/O operation is done, it moves back to the Ready queue and waits for CPU time again.  Terminate: Once the process has completed all its tasks, it terminates. The process is removed from the system and may produce output if required. Example: After Process A finishes executing all its instructions, it moves to the Output phase and is terminated. TYPES OF PROCESSOR QUEUE MECHANISMS  Output (Batch Job Depart): This state represents the completion of the process. If it was a batch job, the job departs after finishing its tasks. The system releases all resources allocated to the process. TYPES OF PROCESSOR QUEUE MECHANISMS  Multiple Queue Mechanism: Here, processes are divided into different queues based on their priority. Short processes get high priority and are handled faster, while longer processes have low priority. Example: If Process X is a short, high-priority task and Process Y is a long, low-priority task, Process X will be placed in the high-priority queue and processed first, even if Process Y arrived earlier. TYPES OF PROCESSOR QUEUE MECHANISMS TYPES OF PROCESSOR QUEUE MECHANISMS  Input: This is where all new processes (whether batch jobs or interactive user tasks) enter the system. Once they enter, they are classified and placed in either the High Priority Ready or Low Priority Ready queues based on their characteristics (such as length or importance of the task).  High Priority Ready Queue: Short, high-priority processes are placed in this queue. These are processes that need immediate attention or can be completed quickly. The dispatcher selects processes from this queue first before considering lower- priority processes. Example: If a user initiates a small, interactive task (like opening a calculator app), this process will enter the high-priority queue and quickly be dispatched for execution. TYPES OF PROCESSOR QUEUE MECHANISMS  Low Priority Ready Queue: Long-running, low-priority processes are placed here. These are background tasks or large processes that take longer to complete and are less urgent. The dispatcher will handle these processes after it has completed processes in the High Priority Ready Queue. Example: A large batch job, such as rendering a video or running a complex database query, would enter the low-priority queue and may not be dispatched immediately if high-priority tasks are waiting. TYPES OF PROCESSOR QUEUE MECHANISMS  I/O Bound Blocked: If a process in the High Priority Ready Queue is blocked because it is waiting for an I/O operation to complete (e.g., reading from a disk or receiving input from a user), it moves into the I/O Bound Blocked state. Once the I/O operation is complete, the process will wake up and return to the High Priority Ready Queue to resume execution. Example: A high-priority process waiting for data from an external source (like a network request) will move into the I/O Bound Blocked state until the data arrives. TYPES OF PROCESSOR QUEUE MECHANISMS  Processor Bound Blocked: Processes in the Low Priority Ready Queue can also become blocked if they are waiting for an event, typically CPU-bound tasks that are paused or need resources (like memory) to continue. Once the process is no longer blocked, it moves back to the Low Priority Ready Queue to wait for CPU time. Example: A long-running calculation or a background process that was paused due to system resource limitations will enter this state. TYPES OF PROCESSOR QUEUE MECHANISMS  Dispatcher: The dispatcher is the component responsible for managing the Ready Queues and assigning CPU time to processes. It prioritizes the High Priority Ready Queue first, dispatching processes to run on the CPU. Once a high-priority process completes or becomes blocked, the dispatcher moves on to the Low Priority Ready Queue. Example: If both high-priority and low-priority processes are waiting, the dispatcher will first pick a process from the high-priority queue to execute.  Returning to Input: After a process has completed its execution, it returns to the Input or is removed from the system. This is where processes either re-enter the cycle or terminate. THANK YOU Audi Alteram Partem Prof Juls

Use Quizgecko on...
Browser
Browser