Skip to content

Commit 0616dae

Browse files
Readme.md
1 parent 5a451dd commit 0616dae

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Ripple Effect Scheduling (RES) Algorithm in C
2+
3+
This project implements the **Ripple Effect Scheduling (RES)** algorithm in C, a priority-based scheduling algorithm that minimizes disruptions to lower-priority tasks. This algorithm sorts tasks based on their priority and calculates waiting and turnaround times for each process. Additionally, it applies a "ripple effect" adjustment to reduce the waiting time of lower-priority tasks.
4+
5+
## Table of Contents
6+
7+
1. [Overview](#overview)
8+
2. [Algorithm Details](#algorithm-details)
9+
3. [Code Structure](#code-structure)
10+
4. [How to Use](#how-to-use)
11+
5. [Sample Input/Output](#sample-inputoutput)
12+
13+
## Overview
14+
15+
The Ripple Effect Scheduling (RES) algorithm is a **priority-based CPU scheduling algorithm** that aims to:
16+
- Prioritize tasks based on their priority level (where a lower priority number indicates higher priority).
17+
- Minimize disruptions to lower-priority tasks using a "ripple effect" adjustment, where each process slightly adjusts the waiting time of the next lower-priority process.
18+
19+
This approach ensures that high-priority tasks are executed first but avoids causing excessive delays for lower-priority tasks.
20+
21+
## Algorithm Details
22+
23+
The algorithm involves the following steps:
24+
25+
1. **Sorting by Priority**: Processes are sorted by priority (ascending order), where a lower priority number indicates a higher priority.
26+
2. **Waiting Time Calculation**:
27+
- For each process, calculate the waiting time as the cumulative burst time of previous processes.
28+
- Apply the "ripple effect" by reducing the waiting time of the next process slightly if it has a lower priority, ensuring it doesn't fall below zero.
29+
3. **Turnaround Time Calculation**:
30+
- For each process, calculate the turnaround time as the sum of waiting time and burst time.
31+
4. **Average Waiting and Turnaround Times**: Display the average waiting and turnaround times for all processes.
32+
33+
## Code Structure
34+
35+
- **`Process` struct**: Stores the details for each process, including `id`, `priority`, `burstTime`, `waitingTime`, and `turnaroundTime`.
36+
- **`rippleEffectScheduling()`**: Sorts processes by priority and calculates waiting and turnaround times, applying the ripple effect.
37+
- **`printProcesses()`**: Displays the process details in a tabular format and calculates average waiting and turnaround times.
38+
- **`main()`**: Collects user input for each process and invokes the scheduling functions.
39+
40+
## How to Use
41+
42+
1. Clone or download this repository to your local machine.
43+
2. Compile the code using a C compiler (instructions below).
44+
3. Run the executable and input the number of processes.
45+
4. For each process, enter the priority and burst time when prompted.
46+
47+
The output will display the waiting time and turnaround time for each process, along with the average waiting and turnaround times.
48+
49+
## Sample Input/Output
50+
51+
### Sample Input
52+
53+
Enter number of processes: 3
54+
Enter priority and burst time for process 1: 1 5
55+
Enter priority and burst time for process 2: 2 8
56+
Enter priority and burst time for process 3: 1 2
57+
58+
### Sample Output
59+
60+
ID Priority Burst Time Waiting Time Turnaround Time
61+
1 1 5 0 5
62+
3 1 2 5 7
63+
2 2 8 4 12
64+
65+
Average Waiting Time: 3.00
66+
Average Turnaround Time: 8.00

0 commit comments

Comments
 (0)