which algo is much memory efficient and has better performance in traffic control system RMS or EDF?

So guys I want to get your opinion on this. I want to implement a task scheduling algorithm to control a traffic light system with three colors: red, yellow, and green. We can use two different algorithms:

Algorithm 1: Rate Monotonic Scheduling (RMS)
#include <stdio.h>

#define RED_LIGHT 0
#define YELLOW_LIGHT 1
#define GREEN_LIGHT 2

void task_red_light(int period) {
printf("Red light ON\n");
}

void task_yellow_light(int period) {
printf("Yellow light ON\n");
}

void task_green_light(int period) {
printf("Green light ON\n");
}

void task_scheduler_rms() {
// Schedule tasks based on priority and period
task_red_light(10); 
//high priority 10ms, period
task_yellow_light(5); 
//medium priority, 5ms period
task_green_light(15);
// low priority, 15ms period
}

int main() { 
task_scheduler_rms();
return 0;
}

Algorithm 2: Earliest Deadline First (EDF) Algorithm
#include <stdio.h>

#define RED_LIGHT 0
#define YELLOW_LIGHT 1
#define GREEN_LIGHT 2

void task_red_light_edf(int deadline) {
printf("Red light ON\n");
}

void task_yellow_light_edf(int deadline) {
printf("Yellow light ON\n");
}

void task_green_light_edf(int deadline) {
printf("Green light ON\n");
}

void task_scheduler_edf() {
// Schedule tasks based on deadline and priority
task_red_light_edf(10); 
//deadline 10ms, high priority
task_yellow_light_edf(5); 
//deadline 5ms, medium priority
task_green_light_edf(15); 
// deadline 15ms, low priority
}

int main() {
task_scheduler_edf();
return 0;
}

Both algorithm achieves the Same goal but with different approaches. I know I am just printing strings to console , but in a real life scenario which is much memory efficient and has better performance in a traffic control system?
RMS or EDF?
@Middleware & OS
Was this page helpful?