Skip to content

Commit

Permalink
Create readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
khwaishchawla authored Nov 10, 2024
1 parent 256515d commit c7d1ad5
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Miscellaneous Algorithms/two level scheduling/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Two-level scheduling is a strategy used in operating systems to manage processes efficiently. It divides the scheduling process into two distinct phases to balance resource usage and system responsiveness, particularly in systems with a mix of interactive and batch processes.

### Description of Two-Level Scheduling

1. **First Level (Long-Term Scheduling):**
- The long-term scheduler, also called the admission scheduler, determines which processes are admitted to the system for execution.
- It decides the overall mix of active processes in the system by selecting a subset from a larger pool of tasks. Only a portion of processes are allowed into memory based on system resource availability.
- Long-term scheduling helps control the degree of multiprogramming (i.e., the number of concurrent processes in memory).

2. **Second Level (Short-Term Scheduling):**
- The short-term scheduler, or CPU scheduler, operates on the processes that are already in memory.
- It frequently selects one of these processes to execute on the CPU, switching between processes as needed to optimize CPU utilization and system responsiveness.
- Short-term scheduling uses various algorithms (e.g., round-robin, priority scheduling) to decide which process gets CPU time next.

### Pros of Two-Level Scheduling

1. **Improved Resource Utilization:**
- Long-term scheduling controls memory usage by limiting the number of concurrent processes, helping to reduce memory thrashing (frequent page swaps).

2. **Enhanced System Performance:**
- By focusing on short-term scheduling among active processes, it achieves higher CPU utilization and responsiveness, especially beneficial for interactive applications.

3. **Reduced Overhead in Process Management:**
- By admitting only a manageable number of processes to memory, the system reduces overhead in handling context switching and managing process queues.

4. **Flexibility with Different Process Types:**
- Works well in systems with mixed workloads by allowing batch jobs to run efficiently in the background and giving priority to interactive tasks.

### Cons of Two-Level Scheduling

1. **Increased Complexity:**
- Requires careful design and tuning to manage the two levels of scheduling effectively, adding to the complexity of the operating system.

2. **Potential Latency for Batch Processes:**
- Long-term scheduling may delay certain processes (especially lower-priority or batch jobs), affecting the turnaround time for such tasks.

3. **Memory Management Challenges:**
- Determining the right mix of processes admitted to memory requires sophisticated memory management, and poor decisions may lead to inefficient memory usage.

4. **Higher Initial Overhead:**
- The process of admitting and scheduling processes at two levels can introduce some initial overhead, potentially slowing down system responsiveness under heavy load conditions.

Two-level scheduling is particularly beneficial for multi-user systems and real-time applications where maintaining responsiveness for interactive users is critical. However, the additional complexity requires careful management and may not be suitable for simpler or single-user systems.

0 comments on commit c7d1ad5

Please sign in to comment.