Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Unversity of Sialkot

Operating System Lab Project

Group Members : Layeha(22101001-117)


Hamza Nadeem(22101001-106)
Maham(22101001-110)
Haseeb(22101001-107)

Subject : Operating System Lab


Sumitted to : Ma’m Faryal Iqbal
Project Name : Development and Assessment of Cyclic Executive Scheduler
Department : Software Engineering
Section : Grey
Semester : 4th

Submission date : 10 June,2024


A software company wants to implement a simple, yet efficient, scheduler for a highly
deterministic system. Your task is to develop a Cyclic Executive scheduler that executes a fixed
sequence of tasks within a specified frame of time. Assess the predictability, jitter, and CPU
overhead of your scheduler compared to a conventional Time-Slice Round Robin system.

Development and Assessment of Cyclic Executive Scheduler:


Introduction:
In real-time systems, efficient task scheduling is critical for ensuring timely and deterministic
execution of tasks. The Cyclic Executive scheduler offers a straightforward approach to
managing tasks within fixed time frames. This project aims to develop and assess the
performance of a Cyclic Executive scheduler for a highly deterministic system, comparing it with
a conventional Time-Slice Round Robin system.

Scope:
• Develop a C++ implementation of the Cyclic Executive scheduler.
• Define a fixed sequence of tasks and frame periods.
• Assess the predictability, jitter, and CPU overhead of the Cyclic Executive scheduler.
• Implement a Time-Slice Round Robin scheduler for comparison.
• Conduct performance evaluations under various workload scenarios

C++ Implementation:
#include <iostream>
#include <vector>
#include <chrono>
#include <thread>
using namespace std;

// Task structure
struct Task {
int id;
int execution_time; // Time taken by task to execute
};

// Cyclic Executive Scheduler


void cyclic_executive_scheduler(const vector<Task>& tasks, int frame_period);

// Time-Slice Round Robin Scheduler


void round_robin_scheduler(const vector<Task>& tasks, int time_slice);

int main() {
// Define tasks with their execution times
vector<Task> tasks = {{1, 20}, {2, 15}, {3, 25}};
int frame_period = 50; // Frame period for Cyclic Executive scheduler
int time_slice = 10; // Time slice for Round Robin scheduler

// Run Cyclic Executive scheduler


cout << "Cyclic Executive Scheduler:" << endl;
cyclic_executive_scheduler(tasks, frame_period);
cout << endl;

// Run Round Robin scheduler


cout << "Round Robin Scheduler:" << endl;
round_robin_scheduler(tasks, time_slice);
return 0;
}
void cyclic_executive_scheduler(const vector<Task>& tasks, int frame_period) {
while (true) {
auto start_time = chrono::steady_clock::now();
// Execute tasks in the fixed sequence
for (const auto& task : tasks) {
cout << "Executing Task " << task.id << " for " << task.execution_time << " units." << endl;
this_thread::sleep_for(chrono::milliseconds(task.execution_time));
}
auto end_time = chrono::steady_clock::now();
auto elapsed_time =chrono::duration_cast<chrono::milliseconds>(end_timestart_time).count();
// Wait until the frame period ends
if (elapsed_time < frame_period) {
auto remaining_time = frame_period - elapsed_time;
cout << "Frame period completed. Remaining time: " << remaining_time << " milliseconds." <<
endl;
this_thread::sleep_for(chrono::milliseconds(remaining_time));
} else {
cout << "Frame period overrun by " << elapsed_time - frame_period << " milliseconds." << endl;
}
}
}
void round_robin_scheduler(const vector<Task>& tasks, int time_slice) {
while (true) {
// Execute tasks in Round Robin fashion with fixed time slice
for (const auto& task : tasks) {
cout << "Executing Task " << task.id << " for " << time_slice << " units." << endl;
this_thread::sleep_for(chrono::milliseconds(time_slice));
}
}
}
Output:

Performance Assessment:

• Predictability: The Cyclic Executive scheduler offers high predictability as tasks are
executed in a fixed sequence within predefined time frames. In contrast, the Round
Robin scheduler may have lower predictability due to task preemption and dynamic
scheduling decisions.
• Jitter: The Cyclic Executive scheduler minimizes jitter as tasks execute within fixed time
frames. The Round Robin scheduler may introduce jitter due to task preemption and
varying execution times within time slices.
• CPU Overhead: The Cyclic Executive scheduler typically incurs lower CPU overhead since
it avoids frequent context switches compared to the Round Robin scheduler, which
involves task preemption and context switching.
Advantages:
• Fairness: Time-Slice Round Robin ensures fairness among tasks by providing each task
with a fair share of CPU time.
• Multitasking Support: This scheduler allows concurrent execution of multiple tasks,
making it suitable for multitasking environments where tasks have varying priorities and
execution requirements.
Disadvantages:
• Higher Jitter: Task preemption and context switches introduce jitter, as the execution
times of tasks may vary due to scheduling decisions.
• Lower Predictability: The dynamic nature of task scheduling in Time-Slice Round Robin
can lead to less predictable behavior compared to a Cyclic Executive scheduler.
• Increased CPU Overhead: Context switching incurs overhead due to saving and restoring
task contexts, leading to higher CPU utilization compared to a Cyclic Executive scheduler

Cyclic Executive Scheduler:


The Cyclic Executive scheduler offers a deterministic approach where tasks are executed in a
fixed sequence within predefined time frames (frames). This deterministic nature ensures high
predictability and minimal jitter, as tasks execute with fixed intervals and there are no context
switches within frames. Additionally, the scheduler incurs low CPU overhead since it avoids
frequent context switches.

Time-Slice Round Robin Scheduler:


In contrast, the Time-Slice Round Robin scheduler allocates fixed time slices to tasks and
switches between them in a cyclic manner. While this approach provides fairness and
multitasking support, it may introduce higher jitter due to task preemption and context
switches. Additionally, the scheduler incurs higher CPU overhead compared to the Cyclic
Executive scheduler.

Comparison and Evaluation:


Comparing the two schedulers, the Cyclic Executive scheduler excels in scenarios where
determinism, predictability, and low jitter are paramount. Its fixed sequence execution and
minimal overhead make it suitable for real-time systems with stringent timing requirements. On
the other hand, the Time-Slice Round Robin scheduler offers fairness and multitasking support
but may struggle in scenarios where predictability and minimal jitter are critical.

You might also like