Process Schedulers in Operating System
Q#1: How do the scheduler and dispatcher work together within the operating system’s kernel to manage processes?
Answer:
- The scheduler maintains a record of processes, adds new processes to the process pool, and removes completed processes.
- It also maintains a process table in memory.
- The dispatcher oversees execution of scheduled processes, using time slices and interrupts to switch between them.
- Together, they ensure processes are executed efficiently and fairly.
Q#2: What is the role of the process table, and what information does it contain?
Answer:
- The process table is maintained by the scheduler in main memory.
- Contains information about each process:
- Memory area assigned to the process
- Priority
- Whether the process is ready or waiting for an external event
- Allows the OS to manage processes systematically.
Q#3: How is the concept of mutual exclusion related to the use of semaphores in operating systems?
Answer:
- Mutual exclusion ensures only one process executes a critical region at a time.
- Semaphores are used to enforce mutual exclusion.
- A process must check and set a semaphore before entering a critical region, preventing concurrent access.
Q#4: What are the three conditions that must be satisfied for a deadlock to occur in resource allocation, and how can these conditions be addressed?
Answer:
- Three conditions for deadlock:
- Competition for non-sharable resources
- Partial resource requests
- Inability to forcibly retrieve allocated resources
- Deadlock handling methods:
- Detection and correction: e.g., killing processes
- Avoidance schemes: e.g., requiring all resources requested at once or converting non-sharable resources into sharable resources