Document 18
Document 18
• How it works: Processes are executed in the order they arrive in the ready
queue. The first process that arrives gets executed first, and the next waits until
the CPU is free.
• Advantages: Simple and easy to implement.
• Disadvantages: Can lead to the convoy effect, where shorter processes get
stuck waiting behind longer ones, causing inefficiency.
• How it works: The process with the shortest execution time is selected for
execution next.
• Advantages: Minimizes average waiting time, making it an optimal scheduling
algorithm in many cases.
• Disadvantages: Requires knowledge of the execution time in advance, and can
lead to starvation for longer processes.
• How it works: Each process gets an equal time slice (called a quantum) to
execute. After its time slice, the process is moved to the back of the queue, and
the next process is selected.
• Advantages: Fair and responsive, particularly good for time-sharing systems.
• Disadvantages: Performance depends on the length of the time quantum. If it’s
too short, there’s a lot of context switching; if too long, it behaves like FCFS.
Operations on a Process
1. New State: A process starts in the new state when it is being created.
2. Ready State: After creation, it moves to the ready state, where it waits for the
CPU to execute it. Multiple processes can be in this state, waiting for their turn.
3. Running State: When the CPU selects a process for execution, it moves to the
running state, where it starts executing its instructions.
4. Waiting State: If the running process needs to wait for an I/O operation or
another event, it moves to the waiting state until the event is completed.
5. Terminated State: After the process finishes its execution, it moves to the
terminated state, and its resources are released.
Advantages of Concurrency:
Problems in Concurrency: