Processor Management Notes

Overview of Processor Management

  • Understanding the processor management in a computer system is essential for efficient task handling and resource management.

Key Concepts

Job Scheduling vs. Process Scheduling
  • Job Scheduling: Determines when a job (program) is admitted to the system and sent to execution.
  • Process Scheduling: Allocates CPU to the jobs that have been admitted into the system, managing job execution.
Interrupts and Interrupt Handlers
  • Interrupt: A hardware signal that temporarily halts the execution of a program, transferring control to the interrupt handler.
  • Context Switch: The process of saving and restoring the state of a CPU so that multiple processes can share the same CPU resources.
Process Scheduling Policies
  • A variety of scheduling algorithms can be employed based on the nature of jobs:
    • First Come, First Served (FCFS)
    • Non-preemptive.
    • Jobs are serviced in the order they arrive.
    • Shortest Job Next (SJN)
    • Non-preemptive.
    • Priority is given to jobs with the shortest processors time.
    • Priority Scheduling
    • Non-preemptive.
    • Processes are assigned priority levels; lower numbers are higher priorities.
    • Shortest Remaining Time (SRT)
    • Preemptive version of SJN.
    • The job with the least remaining time is processed next.
    • Round Robin
    • Preemptive.
    • Each job is assigned a time slice to ensure fair CPU access.
    • Multiple Level Queues
    • Different queues for different task types, using varying scheduling approaches.

Process States

  • HOLD: Job accepted by the system and placed in a queue.
  • READY: Job is ready to run but waiting for the CPU.
  • WAITING: Job cannot continue until a specific resource is available.
  • RUNNING: Job is being processed by the CPU.
  • FINISHED: Job execution completed and results returned to the user.

Process Control Block (PCB)

  • A PCB contains necessary information for the operating system to manage job execution, including:
    • Process ID.
    • State of the process.
    • CPU registers information.
    • Memory management information.
    • Accounting information (e.g., CPU usage).

Deadlock Management

  • Deadlock: A situation where two or more processes are blocked forever, each waiting for a resource held by the other.
  • Conditions that lead to deadlock:
    • Mutual Exclusion.
    • Hold and Wait.
    • No Preemption.
    • Circular Wait.
  • Deadlock Handling Strategies:
    • Avoidance: Preventing deadlocks by denying conditions.
    • Detection: Monitoring for deadlock states.
    • Recovery: Recovering from deadlocks by terminating processes or preempting resources.

Performance Metrics and Goals for Processor Management

  • Maximize Throughput: Complete as many jobs as possible in a given timeframe.
  • Minimize Response Time: Quick turnaround for interactive requests.
  • Minimize Turnaround Time: Efficient movement of jobs in and out of the system.
  • Maximize CPU Efficiency: Keep CPU busy as much as possible.
  • Fairness: Ensure every job gets a fair share of CPU and I/O time.

Summary of Scheduling Algorithms

  1. First Come, First Served (FCFS) - Simple but can lead to long waiting times.
  2. Shortest Job Next (SJN) - Optimal turnaround time but leads to starvation.
  3. Priority Scheduling - Quick service for important jobs but can starve lower priority jobs.
  4. Shortest Remaining Time (SRT) - Preemptive; manages job interruptions but increases overhead.
  5. Round Robin - Fair time sharing; dependent on the time quantum chosen.
  6. Multiple Level Queues - Complex but effective in managing diverse job types.

Best Practices and Considerations

  • Selection of scheduling policy should be tuned to the system environment.
  • Monitor system performance and adjust policies as needed to accommodate changes in user load or job characteristics.
  • Aim for a balance between maximizing CPU usage and minimizing waiting times to ensure system efficiency and responsiveness.