Osy Microproject
Osy Microproject
Chapter No: 1
Introduction
Priority scheduling is a method used in operating systems to manage the order in which
processes are executed based on their priority levels. Each process is assigned a priority,
and the CPU is allocated to the process with the highest priority first. This helps ensure
that important tasks are completed quickly. However, it can lead to lower-priority
processes being delayed or "starved" if there are always higher-priority tasks available.
Overall, priority scheduling is essential for improving system efficiency and
responsiveness.
This micro project focuses on implementing a Priority Scheduling algorithm, which
organizes processes based on their assigned priority levels. By allocating CPU time to
the highest-priority processes first, priority scheduling enhances responsiveness,
particularly in systems where certain tasks require immediate attention.We will
implement both preemptive and non-preemptive priority scheduling techniques. The
project will involve coding and simulating how these methods work, highlighting their
advantages, such as improved responsiveness, as well as challenges like the potential
for lower-priority processes to be delayed.
This micro project is centered around Priority Scheduling, a vital algorithm in operating
systems that manages the execution of processes based on their assigned priority levels.
By prioritizing certain tasks, this scheduling method ensures that critical processes are
executed promptly, which is especially important in environments where time-sensitive
operations are required.
Example:
Chapter No:2
Aim of Micro project
Chapter No: 3
Chapter No: 4
Methodology Followed
Preemptive Scheduling: Continuously check for new processes arriving with a higher
priority. If found, preempt the current process and allocate the CPU to the higher-
priority process.
Execute Processes
Calculate Metrics
Display Results
Chapter No: 5
Resources Used
Priority Queue
A priority queue or heap is used to maintain the processes, where each process has a
priority value. The priority queue ensures efficient access to the highest-priority
process (highest or lowest depending on the system's configuration).
CPU Scheduler
The CPU scheduler uses the priority queue to select the next process for execution.
The scheduler ensures that processes with higher priority values are chosen first.
Chapter No: 6
Code:
#include <stdio.h>
struct Process {
int id; // Process ID
int burst_time; // Burst Time
int priority; // Priority
int waiting_time; // Waiting Time
int turnaround_time; // Turnaround Time
};
printf("\nGantt Chart:\n");
printf(" ");
for (int i = 0; i < n; i++) {
for (int j = 0; j < proc[i].burst_time; j++) printf("--");
printf(" ");
}
printf("\n|");
// Main function
int main() {
int n;
printf("Enter the number of processes: ");
scanf("%d", &n);
return 0;
}
Output:
Chapter No: 7
Skills Developed
• Programming Skills: Learned to write efficient code for sorting and managing
processes based on priority.
Chapter No: 8
Applications of Microproject
Conclusion
Priority scheduling is a vital CPU scheduling algorithm that ensures the efficient execution of
processes based on their assigned priority levels. By giving preference to high-priority tasks, it
optimizes system performance and resource utilization, making it particularly suitable for time-
sensitive applications such as real-time systems, operating systems, and multimedia processing.
The algorithm can be implemented in both pre-emptive and non-preemptive forms, offering
flexibility depending on system requirements. While it provides significant advantages, such
as faster handling of critical tasks, it also presents challenges like potential starvation of lower-
priority processes. These can be mitigated with techniques like aging, which dynamically
adjusts priorities over time. Overall, priority scheduling is a powerful tool for managing
computational resources effectively in diverse fields, balancing system responsiveness and
fairness.
References