0% found this document useful (0 votes)
133 views3 pages

Priority Scheduling Algorithm

Priority Scheduling is a CPU scheduling algorithm that assigns priorities to processes, executing the highest priority process first. It has advantages such as flexibility and improved performance but also limitations like starvation and complexity. The algorithm can be either preemptive, allowing interruption for higher priority processes, or non-preemptive, where a running process completes before switching.

Uploaded by

rkanwal5598
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views3 pages

Priority Scheduling Algorithm

Priority Scheduling is a CPU scheduling algorithm that assigns priorities to processes, executing the highest priority process first. It has advantages such as flexibility and improved performance but also limitations like starvation and complexity. The algorithm can be either preemptive, allowing interruption for higher priority processes, or non-preemptive, where a running process completes before switching.

Uploaded by

rkanwal5598
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Priority Scheduling Algorithm

Definition: Priority Scheduling is a CPU scheduling algorithm where each process is


assigned a priority. The process with the highest priority is executed first, and
the CPU is assigned to that process until it finishes or a higher priority process
arrives. If two processes have the same priority, the CPU schedules them based on
other factors, like arrival time or burst time.

Example:
Consider three processes with the following priority values:

Process A: Priority 3

Process B: Priority 1

Process C: Priority 2

In this case, Process B (with the highest priority, priority 1) will be executed
first, followed by Process C, and finally Process A.

Advantages of Priority Scheduling Algorithm


Flexible: Processes with critical tasks can be assigned higher priority, ensuring
important tasks are completed first.

Improved Performance: By prioritizing the most urgent tasks, the system can achieve
better overall performance for essential processes.

Adaptable: It can be adapted to different types of systems where the importance of


tasks varies, such as in real-time systems.

Limitations of Priority Scheduling Algorithm


Starvation: Low-priority processes may never get executed if higher-priority
processes keep arriving, which leads to starvation.

Non-Optimal for Short Processes: Short tasks may be delayed because higher-priority
long tasks are given preference, which can cause inefficiencies.

Complexity: Assigning and managing priorities for each process can add complexity,
especially if priorities change dynamically.

Preemptive Priority Scheduling Algorithm


Definition: In the Preemptive Priority Scheduling algorithm, if a new process with
a higher priority arrives while a lower priority process is running, the lower
priority process is interrupted (preempted), and the higher priority process is
executed. After the higher priority process finishes, the preempted process
resumes.

Example:

Process A (Priority 3) starts executing.

Process B (Priority 1) arrives while Process A is running.

Process A is preempted, and Process B is executed since it has a higher priority.

Non-Preemptive Priority Scheduling Algorithm


Definition: In the Non-Preemptive Priority Scheduling algorithm, once a process
starts executing, it runs to completion, even if a higher priority process arrives.
The CPU will not switch to the higher priority process until the current one
finishes.
Example:

Process A (Priority 3) starts executing.

Process B (Priority 1) arrives.

Process A continues executing until it finishes, even though Process B has a higher
priority.

In summary:

Preemptive allows interruption of the current process for a higher priority


process.

Non-Preemptive does not interrupt the running process, allowing it to finish before
switching to a higher priority process.

### Priority Scheduling Algorithm

**Definition**:
Priority Scheduling assigns a priority to each process. The process with the
highest priority is executed first. If two processes have the same priority, they
are scheduled based on other factors.

**Example**:
- Process A: Priority 3
- Process B: Priority 1
- Process C: Priority 2
Process B will execute first, followed by Process C, and then Process A.

---

### Advantages:
1. **Flexible**: Allows prioritization of important tasks.
2. **Improved Performance**: Ensures critical tasks are executed first.
3. **Adaptable**: Suitable for real-time systems.

---

### Limitations:
1. **Starvation**: Low-priority processes may never execute.
2. **Non-Optimal**: Long tasks delay short ones.
3. **Complexity**: Managing dynamic priorities can be complicated.

---
### Preemptive Priority Scheduling

**Definition**:
In Preemptive Priority Scheduling, if a new higher-priority process arrives, the
current process is interrupted and the higher priority process executes.

**Example**:
Process A (Priority 3) runs until Process B (Priority 1) arrives. Process A is
preempted, and Process B runs.

---

### Non-Preemptive Priority Scheduling

**Definition**:
In Non-Preemptive Priority Scheduling, once a process starts, it runs to
completion, even if a higher-priority process arrives.

**Example**:
Process A (Priority 3) runs until it finishes, even though Process B (Priority 1)
arrives later.

---

You might also like