Professional Documents
Culture Documents
College of informatics
Information system
Name id
1. Abenezer nega gur/40679/13
2. Yohannes Berhanu gur/40191/13
3. Ejige Dessie gur/23115/13
4. Haile Nigusie gur/22852/13
5. Yonael Fikresilase gur/22949/13
non-preemptive
Non-preemptive priority scheduling is a scheduling algorithm
used by operating systems to determine the order in which processes are
executed on a CPU. In non-preemptive priority scheduling, each process is
assigned a priority value, which indicates the relative importance of the process.
The scheduler selects the process with the highest priority to run next, and that
process continues to execute until it completes its execution or is blocked (e.g.,
waiting for I/O). If a process with a higher priority becomes ready to run while a
lower-priority process is running, the scheduler does not interrupt the lower-
priority process. Instead, the higher-priority process waits until the lower-
priority process completes its execution.
Non-preemptive priority scheduling is sometimes referred to as
"priority-based scheduling," "static priority scheduling," or "fixed-priority
scheduling." This scheduling algorithm has some advantages over other
scheduling algorithms, such as round-robin scheduling or first-come, first-served
scheduling, as it allows the operating system to give more processing time to
more important tasks. However, it can also lead to problems such as priority
inversion, where a low-priority process holds a resource that a high-priority
process needs to continue execution.
In non-preemptive priority scheduling, the priority of a process can be set in a
variety of ways. For example, it could be set based on the type of task the
process performs, the user who submitted the process, or the relative importance
of the process to the overall system performance. The priority value of a process
can be adjusted dynamically based on changing system conditions or user
preferences.
int main()
{
int n;
cout << "Enter the number of processes: ";
cin >> n;
return 0;
}
Example 2:
#include <iostream>
#include <vector>
#include <algorithm>
struct Process {
int id;
int burstTime;
int priority;
};
int main()
{
int n;
cout << "Enter the number of processes: ";
cin >> n;
vector<Process> processes(n);
return 0;
}