diff --git a/Exercises/ResponseTimeAnalysis/02225_Exercise.pdf b/Exercises/ResponseTimeAnalysis/02225_Exercise.pdf deleted file mode 100644 index f49c082..0000000 Binary files a/Exercises/ResponseTimeAnalysis/02225_Exercise.pdf and /dev/null differ diff --git a/Exercises/ResponseTimeAnalysis/README.txt b/Exercises/ResponseTimeAnalysis/README.txt deleted file mode 100644 index f028b24..0000000 --- a/Exercises/ResponseTimeAnalysis/README.txt +++ /dev/null @@ -1,14 +0,0 @@ -README.txt - -The files in the Exerercise/Content tab are test cases are provided as a starting point for the 02225 DRTS exercise. - -They are in CSV (Comma-Separated Values) format and contain the model parameters for periodic tasks: - - - Task: Task name - - BCET: Best-case execution time - - WCET: Worst-case execution time - - Period: Task period - - Deadline: Task deadline (equal to the period) - - Priority: Task priority (assigned by Rate Monotonic scheduling, with lower period yielding higher priority) - -These examples illustrate one possible format. Students may use a different format and create additional test cases. diff --git a/Exercises/ResponseTimeAnalysis/build/real_time_analysis b/Exercises/ResponseTimeAnalysis/build/real_time_analysis deleted file mode 100644 index 9013645..0000000 Binary files a/Exercises/ResponseTimeAnalysis/build/real_time_analysis and /dev/null differ diff --git a/Exercises/ResponseTimeAnalysis/build/response_time_analysis b/Exercises/ResponseTimeAnalysis/build/response_time_analysis deleted file mode 100755 index c819722..0000000 Binary files a/Exercises/ResponseTimeAnalysis/build/response_time_analysis and /dev/null differ diff --git a/Exercises/ResponseTimeAnalysis/exercise-TC1.csv b/Exercises/ResponseTimeAnalysis/exercise-TC1.csv deleted file mode 100644 index 89e3ebe..0000000 --- a/Exercises/ResponseTimeAnalysis/exercise-TC1.csv +++ /dev/null @@ -1,8 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,0,1,6,6,1 -T2,3,4,60,60,7 -T3,1,1,10,10,2 -T4,1,2,12,12,3 -T5,1,2,15,15,4 -T6,1,3,20,20,5 -T7,1,4,30,30,6 \ No newline at end of file diff --git a/Exercises/ResponseTimeAnalysis/exercise-TC2.csv b/Exercises/ResponseTimeAnalysis/exercise-TC2.csv deleted file mode 100644 index 2427ced..0000000 --- a/Exercises/ResponseTimeAnalysis/exercise-TC2.csv +++ /dev/null @@ -1,12 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,0,1,15,15,1 -T2,1,2,20,20,2 -T3,2,3,25,25,3 -T4,2,4,30,30,4 -T5,3,5,50,50,5 -T6,3,5,60,60,6 -T7,4,6,75,75,7 -T8,5,9,100,100,8 -T9,3,12,120,120,9 -T10,5,11,150,150,10 -T11,6,15,300,300,11 \ No newline at end of file diff --git a/Exercises/ResponseTimeAnalysis/exercise-TC3.csv b/Exercises/ResponseTimeAnalysis/exercise-TC3.csv deleted file mode 100644 index 8cd09de..0000000 --- a/Exercises/ResponseTimeAnalysis/exercise-TC3.csv +++ /dev/null @@ -1,10 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,1,3,40,40,1 -T2,2,7,80,80,2 -T3,1,13,100,100,3 -T4,3,18,160,160,4 -T5,1,22,200,200,5 -T6,5,27,300,300,6 -T7,8,29,320,320,7 -T8,10,34,400,400,8 -T9,22,35,480,480,9 \ No newline at end of file diff --git a/Exercises/ResponseTimeAnalysis/src/real_time_analysis.cpp b/Exercises/ResponseTimeAnalysis/src/real_time_analysis.cpp deleted file mode 100644 index fbb2d2a..0000000 --- a/Exercises/ResponseTimeAnalysis/src/real_time_analysis.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include -#include -#include -#include -#include -#include - -using namespace std; - -struct Task { - string id; - int BCET; - int WCET; - int period; - int deadline; - int priority; // Lower number => higher priority for RMS, if you wish -}; - - -void readTasksCSV(const string& filename, vector& tasks) -{ - ifstream file(filename); - if (!file.is_open()) { - cerr << "Error: Could not open file " << filename << endl; - return; - } - - string line; - getline(file, line); // Skip header - - while (getline(file, line)) - { - stringstream ss(line); - Task task; - string token; - - getline(ss, token, ','); // Task ID - task.id = token; - getline(ss, token, ','); // WCET - task.WCET = stoi(token); - getline(ss, token, ','); // BCET - task.BCET = stoi(token); - getline(ss, token, ','); // Period - task.period = stoi(token); - getline(ss, token, ','); // Deadline - task.deadline = stoi(token); - getline(ss, token, ','); // Priority - task.priority = stoi(token); - - tasks.push_back(task); - } - file.close(); -} - -void RTA_test(vector& tasks) -{ - // Sort tasks by priority (lower number means higher priority) - sort(tasks.begin(), tasks.end(), [](const Task& a, const Task& b) { - return a.priority < b.priority; // Ensure lower priority number = higher priority - }); - - for (size_t task = 0; task < tasks.size(); task++) - { - int R = tasks[task].WCET; - int last_R = -1; - bool schedulable = true; - int I = 0; // Reset interference for each iteration - - while (R != last_R) - { - last_R = R; - - // Compute interference from higher-priority tasks - for (size_t j = 0; j < task; j++) - { - I += ceil((double)R / tasks[j].period) * tasks[j].WCET; - } - - R = I + tasks[task].WCET; - - if (R > tasks[task].deadline) - { - cout << "Task " << tasks[task].id << " is not schedulable." << endl; - schedulable = false; - break; - } - } - - if (schedulable) - { - cout << "Task " << tasks[task].id << " is schedulable with WCRT = " << R << endl; - } - } -} - -int main(int argc, char* argv[]) -{ - if (argc != 2) { - cerr << "Usage: " << argv[0] << " " << endl; - return 1; - } - - string filename = argv[1]; - vector tasks; - readTasksCSV(filename, tasks); - - RTA_test(tasks); - - return 0; -} \ No newline at end of file diff --git a/Exercises/ResponseTimeAnalysis/src/real_time_analysis.py b/Exercises/ResponseTimeAnalysis/src/real_time_analysis.py deleted file mode 100644 index 021e3ac..0000000 --- a/Exercises/ResponseTimeAnalysis/src/real_time_analysis.py +++ /dev/null @@ -1,88 +0,0 @@ -import pandas as pd -import math - - -def read_csv(file): - """ - Read tasks from a CSV file and convert to a list of task dictionaries. - """ - df = pd.read_csv(file) - req_columns = ['Task', 'BCET', 'WCET', 'Period', 'Deadline', 'Priority'] - - if not all(col in df.columns for col in req_columns): - raise ValueError(f"Missing required column(s): {req_columns}") - - tasks = [] - for _, row in df.iterrows(): - task = { - "name": row['Task'], - "bcet": row['BCET'], - "wcet": row['WCET'], - "period": row['Period'], - "deadline": row['Deadline'], - "priority": row['Priority'] - } - tasks.append(task) - - return tasks - - -def response_time_analysis(tasks): - """ - Perform Response-Time Analysis. - """ - # Sort tasks by priority (lower number means higher priority) - sorted_tasks = sorted(tasks, key=lambda x: x['priority']) - - results = [] - - for i, task in enumerate(sorted_tasks): - R = task['wcet'] # Initial response time - last_R = -1 - schedulable = True - - while R != last_R: - last_R = R - interference = 0 - - # Calculate interference from higher-priority tasks - for j in range(i): - higher_task = sorted_tasks[j] - interference += math.ceil(R / higher_task['period']) * higher_task['wcet'] - - R = task['wcet'] + interference - - # Check if the task is schedulable - if R > task['deadline']: - schedulable = False - break - - # Store results - result = { - 'Task': task['name'], - 'WCRT': R, - 'Deadline': task['deadline'], - 'Status': 'Schedulable' if schedulable else 'Not Schedulable' - } - results.append(result) - - return results - - -def run_rta(path_file): - """ - Main function to read tasks and perform response time analysis. - """ - # Read tasks from CSV - tasks = read_csv(path_file) - print(tasks) - # Perform response time analysis - analysis_results = response_time_analysis(tasks) - - # Print results - for result in analysis_results: - if result['Status'] == 'Schedulable': - print(f"Task {result['Task']} is schedulable with WCRT = {result['WCRT']:.1f}") - else: - print(f"Task {result['Task']} is not schedulable with WCRT.") - return analysis_results diff --git a/Exercises/ResponseTimeAnalysis/src/response_time_analysis.cpp b/Exercises/ResponseTimeAnalysis/src/response_time_analysis.cpp deleted file mode 100644 index 5651015..0000000 --- a/Exercises/ResponseTimeAnalysis/src/response_time_analysis.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#include -#include -#include -#include - -using namespace std; - -struct Task { - string id; - int BCET; - int WCET; - int period; - int deadline; - int priority; // Lower number => higher priority for RMS, if you wish -}; - - -void readTasksCSV(const string& filename, vector& tasks) -{ - ifstream file(filename); - if (!file.is_open()) { - cerr << "Error: Could not open file " << filename << endl; - return; - } - - string line; - getline(file, line); // Skip header - - while (getline(file, line)) - { - stringstream ss(line); - Task task; - string token; - - getline(ss, token, ','); // Task ID - task.id = token; - getline(ss, token, ','); // BCET - task.BCET = stoi(token); - getline(ss, token, ','); // WCET - task.WCET = stoi(token); - getline(ss, token, ','); // Period - task.period = stoi(token); - getline(ss, token, ','); // Deadline - task.deadline = stoi(token); - getline(ss, token, ','); // Priority - task.priority = stoi(token); - - tasks.push_back(task); - } - file.close(); -} - -void RTA_test(vector& tasks) -{ - // Sort tasks by priority (lower number means higher priority) - sort(tasks.begin(), tasks.end(), [](const Task& a, const Task& b) { - return a.priority < b.priority; - }); - - for (size_t i = 0; i < tasks.size(); i++) - { - int R = tasks[i].WCET; - int last_R = -1; - bool schedulable = true; - - while (R != last_R) - { - last_R = R; - int I = 0; - for (size_t j = 0; j < i; j++) - { - I += ceil((double)R / tasks[j].period) * tasks[j].WCET; - } - R = tasks[i].WCET + I; - - if (R > tasks[i].deadline) - { - cout << "Task " << tasks[i].id << " is not schedulable with WCRT." << endl; - schedulable = false; - break; - } - } - - if (schedulable) - { - cout << "Task " << tasks[i].id << " is schedulable with WCRT = " << R << endl; - } - } -} - - -int main(int argc, char* argv[]) -{ - if (argc != 2) { - cerr << "Usage: " << argv[0] << " " << endl; - return 1; - } - - string filename = argv[1]; - vector tasks; - readTasksCSV(filename, tasks); - - RTA_test(tasks); - - return 0; -} diff --git a/Exercises/VerySimpleSimulator/02225_Exercise.pdf b/Exercises/VerySimpleSimulator/02225_Exercise.pdf deleted file mode 100644 index f49c082..0000000 Binary files a/Exercises/VerySimpleSimulator/02225_Exercise.pdf and /dev/null differ diff --git a/Exercises/VerySimpleSimulator/README.txt b/Exercises/VerySimpleSimulator/README.txt deleted file mode 100644 index 294350d..0000000 --- a/Exercises/VerySimpleSimulator/README.txt +++ /dev/null @@ -1,14 +0,0 @@ -README.txt - -The files in the Exerercise/Content tab are test cases are provided as a starting point for the 02225 DRTS exercise. - -They are in CSV (Comma-Separated Values) format and contain the model parameters for periodic tasks: - - - Task: Task name - - BCET: Best-case execution time - - WCET: Worst-case execution time - - Period: Task period - - Deadline: Task deadline (equal to the period) - - Priority: Task priority (assigned by Rate Monotonic scheduling, with lower period yielding higher priority) - -These examples illustrate one possible format. Students may use a different format and create additional test cases. diff --git a/Exercises/VerySimpleSimulator/build/very_simple_simulator b/Exercises/VerySimpleSimulator/build/very_simple_simulator deleted file mode 100755 index 12e9167..0000000 Binary files a/Exercises/VerySimpleSimulator/build/very_simple_simulator and /dev/null differ diff --git a/Exercises/VerySimpleSimulator/exercise-TC1.csv b/Exercises/VerySimpleSimulator/exercise-TC1.csv deleted file mode 100644 index 03e6cf2..0000000 --- a/Exercises/VerySimpleSimulator/exercise-TC1.csv +++ /dev/null @@ -1,8 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,0,1,6,6,1 -T2,3,4,60,60,7 -T3,1,1,10,10,2 -T4,1,2,12,12,3 -T5,1,2,15,15,4 -T6,1,3,20,20,5 -T7,1,4,30,30,6 diff --git a/Exercises/VerySimpleSimulator/exercise-TC1_s.csv b/Exercises/VerySimpleSimulator/exercise-TC1_s.csv deleted file mode 100644 index 6183855..0000000 --- a/Exercises/VerySimpleSimulator/exercise-TC1_s.csv +++ /dev/null @@ -1,8 +0,0 @@ -Task,WCRT,Deadline,Status -T1,1,6,true -T2,54,60,true -T3,2,10,true -T4,4,12,true -T5,6,15,true -T6,10,20,true -T7,28,30,true diff --git a/Exercises/VerySimpleSimulator/exercise-TC2.csv b/Exercises/VerySimpleSimulator/exercise-TC2.csv deleted file mode 100644 index 407f27f..0000000 --- a/Exercises/VerySimpleSimulator/exercise-TC2.csv +++ /dev/null @@ -1,12 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,0,1,15,15,1 -T2,1,2,20,20,2 -T3,2,3,25,25,3 -T4,2,4,30,30,4 -T5,3,5,50,50,5 -T6,3,5,60,60,6 -T7,4,6,75,75,7 -T8,5,9,100,100,8 -T9,3,12,120,120,9 -T10,5,11,150,150,10 -T11,6,15,300,300,11 diff --git a/Exercises/VerySimpleSimulator/exercise-TC3.csv b/Exercises/VerySimpleSimulator/exercise-TC3.csv deleted file mode 100644 index 2330943..0000000 --- a/Exercises/VerySimpleSimulator/exercise-TC3.csv +++ /dev/null @@ -1,10 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,1,3,40,40,1 -T2,2,7,80,80,2 -T3,1,13,100,100,3 -T4,3,18,160,160,4 -T5,1,22,200,200,5 -T6,5,27,300,300,6 -T7,8,29,320,320,7 -T8,10,34,400,400,8 -T9,22,35,480,480,9 diff --git a/Exercises/VerySimpleSimulator/src/jobs.py b/Exercises/VerySimpleSimulator/src/jobs.py deleted file mode 100644 index d984372..0000000 --- a/Exercises/VerySimpleSimulator/src/jobs.py +++ /dev/null @@ -1,43 +0,0 @@ -from dataclasses import dataclass -import numpy as np - - -# struct to keep track of the jobs -@dataclass -class Jobs: - task: np.array - release_time: int - remaining_time: int - response_time: int - - -# function to check if every job is done -def check_remaining_jobs(jobs: np.array) -> bool: - """ - Checks if there are any jobs remaining to be executed. - Parameters: - jobs (np.array): The list of jobs to check. - Returns: - bool: True if there are jobs remaining, False otherwise. - """ - for job in jobs: - if job.remaining_time > 0: - return True - return False - - -# function to check if the job is ready to be executed -def get_ready_list(jobs: np.array, current_time: int) -> np.array: - """ - Get the list of jobs that are ready to be executed. - Args: - jobs (np.array): An array of job objects. Each job object is expected to have 'release_time' and 'remaining_time' attributes. - current_time (int): The current time against which the jobs' readiness is evaluated. - Returns: - np.array: An array of job objects that are ready to be executed. A job is considered ready if its release_time is less than or equal to the current_time and its remaining_time is greater than 0. - """ - ready_job: np.array = [] - for job in jobs: - if job.release_time <= current_time and job.remaining_time > 0: - ready_job.append(job) - return ready_job diff --git a/Exercises/VerySimpleSimulator/src/real_time_analysis.py b/Exercises/VerySimpleSimulator/src/real_time_analysis.py deleted file mode 100644 index 021e3ac..0000000 --- a/Exercises/VerySimpleSimulator/src/real_time_analysis.py +++ /dev/null @@ -1,88 +0,0 @@ -import pandas as pd -import math - - -def read_csv(file): - """ - Read tasks from a CSV file and convert to a list of task dictionaries. - """ - df = pd.read_csv(file) - req_columns = ['Task', 'BCET', 'WCET', 'Period', 'Deadline', 'Priority'] - - if not all(col in df.columns for col in req_columns): - raise ValueError(f"Missing required column(s): {req_columns}") - - tasks = [] - for _, row in df.iterrows(): - task = { - "name": row['Task'], - "bcet": row['BCET'], - "wcet": row['WCET'], - "period": row['Period'], - "deadline": row['Deadline'], - "priority": row['Priority'] - } - tasks.append(task) - - return tasks - - -def response_time_analysis(tasks): - """ - Perform Response-Time Analysis. - """ - # Sort tasks by priority (lower number means higher priority) - sorted_tasks = sorted(tasks, key=lambda x: x['priority']) - - results = [] - - for i, task in enumerate(sorted_tasks): - R = task['wcet'] # Initial response time - last_R = -1 - schedulable = True - - while R != last_R: - last_R = R - interference = 0 - - # Calculate interference from higher-priority tasks - for j in range(i): - higher_task = sorted_tasks[j] - interference += math.ceil(R / higher_task['period']) * higher_task['wcet'] - - R = task['wcet'] + interference - - # Check if the task is schedulable - if R > task['deadline']: - schedulable = False - break - - # Store results - result = { - 'Task': task['name'], - 'WCRT': R, - 'Deadline': task['deadline'], - 'Status': 'Schedulable' if schedulable else 'Not Schedulable' - } - results.append(result) - - return results - - -def run_rta(path_file): - """ - Main function to read tasks and perform response time analysis. - """ - # Read tasks from CSV - tasks = read_csv(path_file) - print(tasks) - # Perform response time analysis - analysis_results = response_time_analysis(tasks) - - # Print results - for result in analysis_results: - if result['Status'] == 'Schedulable': - print(f"Task {result['Task']} is schedulable with WCRT = {result['WCRT']:.1f}") - else: - print(f"Task {result['Task']} is not schedulable with WCRT.") - return analysis_results diff --git a/Exercises/VerySimpleSimulator/src/task_handler.py b/Exercises/VerySimpleSimulator/src/task_handler.py deleted file mode 100644 index 35f5818..0000000 --- a/Exercises/VerySimpleSimulator/src/task_handler.py +++ /dev/null @@ -1,26 +0,0 @@ -import pandas as pd -import numpy as np - - -def output_result_csv(ouput_path: str, wcrt_dict: dict, tasks: np.array, rta: dict) -> None: - """ - Writes the worst-case response time dictionary to a CSV file. - Parameters: - output_path (str): The file path to write the CSV file to. - wcrt_dict (dict): The dictionary containing the worst-case response times for each task. - """ - # Create a list to store the results - results = [] - - for i, job in enumerate(tasks): - task = job["Task"] - wcrt = wcrt_dict[task] - deadline = job["Deadline"] - status = "true" if rta[i]['Status'] == 'Schedulable' else "false" - results.append([task, wcrt, deadline, status]) - - # Create a DataFrame from the results - results_df = pd.DataFrame(results, columns=["Task", "WCRT", "Deadline", "Status"]) - - # Save the DataFrame to a CSV file - results_df.to_csv(ouput_path.removesuffix(".csv") + "_s.csv", index=False) diff --git a/Exercises/VerySimpleSimulator/src/very_simple_simulator.cpp b/Exercises/VerySimpleSimulator/src/very_simple_simulator.cpp deleted file mode 100644 index 9235b30..0000000 --- a/Exercises/VerySimpleSimulator/src/very_simple_simulator.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include -#include -#include -#include - -using namespace std; - -// Define the Task structure -struct Task { - string id; - int BCET; - int WCET; - int period; - int deadline; - int priority; // Lower number => higher priority for RMS -}; - -// Define the Job structure -struct Job { - Task task; - int releaseTime; - int remainingTime; - int responseTime; -}; - -// Function to read tasks from a CSV file -void readTasksCSV(const string& filename, vector& tasks) -{ - ifstream file(filename); - if (!file.is_open()) - { - cerr << "Error: Could not open file " << filename << endl; - return; - } - - string line; - getline(file, line); // Skip header - - while (getline(file, line)) - { - stringstream ss(line); - Task task; - string token; - - getline(ss, token, ','); // Task ID - task.id = token; - getline(ss, token, ','); // BCET - task.BCET = stoi(token); - getline(ss, token, ','); // WCET - task.WCET = stoi(token); - getline(ss, token, ','); // Period - task.period = stoi(token); - getline(ss, token, ','); // Deadline - task.deadline = stoi(token); - getline(ss, token, ','); // Priority - task.priority = stoi(token); - - tasks.push_back(task); - } - file.close(); - - sort(tasks.begin(), tasks.end(), [](const Task& a, const Task& b) { - return a.id < b.id; - }); -} - -// Function to find the job with the highest priority -Job *highest_priority(vector& readyList) -{ - if (readyList.empty()) - { - return nullptr; - } - - return *min_element( - readyList.begin(), - readyList.end(), - [](Job* a, Job* b) { - return a->task.priority < b->task.priority; - } - ); -} - -// Function to get the list of ready jobs -vector get_ready(vector& jobs, int currentTime) -{ - vector readyList; - for (auto& j : jobs) { - if (j.releaseTime <= currentTime && j.remainingTime > 0) { - readyList.push_back(&j); - } - } - return readyList; -} - -int advanceTime() -{ - return 1; -} - -int main(int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "Usage: " << argv[0] << " " << endl; - return 1; - } - - string filename = argv[1]; - vector tasks; - readTasksCSV(filename, tasks); - - // Simulation time (n cycles) - int n = 1000; - int currentTime = 0; - - // List of all jobs that are in the system - vector jobs; - - // Initialize next release time for each task (all tasks start at time 0) - vector nextReleaseTimes(tasks.size(), 0); - - // We also maintain worst-case response times (WCRT) for each task. - vector worstCaseResponseTimes(tasks.size(), 0); - - // Simulation loop - while (currentTime <= n) - { - // For each task, if it is time to release a new job, create it. - for (size_t i = 0; i < tasks.size(); ++i) - { - if (currentTime >= nextReleaseTimes[i]) - { - Job newJob { tasks[i], currentTime, tasks[i].WCET, 0 }; - jobs.push_back(newJob); - nextReleaseTimes[i] += tasks[i].period; - } - } - - vector readyList = get_ready(jobs, currentTime); - Job* currentJob = highest_priority(readyList); - - if (currentJob != nullptr) - { - int delta = advanceTime(); - currentTime += delta; - currentJob->remainingTime -= delta; - - // If the job has completed execution, calculate its response time and update WCRT - if (currentJob->remainingTime <= 0) - { - currentJob->responseTime = currentTime - currentJob->releaseTime; - - // Find the corresponding task index - auto it = find_if(tasks.begin(), tasks.end(), [&](const Task& t) { - return t.id == currentJob->task.id; - }); - - if (it != tasks.end()) - { - size_t taskIndex = distance(tasks.begin(), it); - worstCaseResponseTimes[taskIndex] = max( - worstCaseResponseTimes[taskIndex], - currentJob->responseTime - ); - } - } - } - else - { - // If no job is ready, just advance time - int delta = advanceTime(); - currentTime += delta; - } - } - - // Output the worst-case response times for each task - cout << "Task\tWCRT\tDeadline\tStatus" << endl; - cout << "---------------------------------" << endl; - for (size_t i = 0; i < tasks.size(); ++i) - { - string status = (worstCaseResponseTimes[i] <= tasks[i].deadline) ? "✓" : "✗"; - cout << " " << tasks[i].id << "\t" - << worstCaseResponseTimes[i] << "\t" - << tasks[i].deadline << "\t\t" - << status << endl; - } - - return 0; -} diff --git a/Exercises/VerySimpleSimulator/src/very_simple_simulator.py b/Exercises/VerySimpleSimulator/src/very_simple_simulator.py deleted file mode 100644 index ed7696f..0000000 --- a/Exercises/VerySimpleSimulator/src/very_simple_simulator.py +++ /dev/null @@ -1,75 +0,0 @@ -import pandas as pd -import numpy as np -from jobs import ( - Jobs, - check_remaining_jobs, - get_ready_list, -) -from task_handler import output_result_csv -import typer -from real_time_analysis import ( - run_rta -) -from typing import Annotated - -app = typer.Typer() - -@app.command(name="run_cycle") -def run_cycle(input_path: Annotated[str, typer.Option("--path", "-p")]) -> None: - # Print the contents of the CSV file - # Task BCET(best case execution time) WCET(worst case execution time) Period Deadline Priority - rta = run_rta(input_path) - tasks = pd.read_csv(input_path) - tasks_dict = tasks.to_dict(orient="records") - - # init number of cycles and current time - num_cycles: int = 1000 - current_time: int = 0 - - # init the tasks - jobs_queue: np.array = [] - for task in tasks_dict: - jobs_queue.append(Jobs(task, 0, task["WCET"], 0)) - - # init the worst case dictionary example[T0, 0; T1,0; ...] - # wcrt_dict = {tasks.values[i][0]: 0 for i in range(len(tasks))} - wcrt_dict = {task: 0.0 for task in tasks["Task"]} - - while current_time <= num_cycles and check_remaining_jobs(jobs_queue): - # release job at the start of the period - for task in tasks_dict: - if current_time % task["Period"] == 0 and current_time != 0: - jobs_queue.append(Jobs(task, current_time, task["WCET"], 0)) - - ready_job = get_ready_list(jobs_queue, current_time) - highest_priority_job = None - if ready_job: - highest_priority_job = min(ready_job, key=lambda job: job.task["Priority"]) - - if highest_priority_job: - # advance by 1 - current_time += 1 - # compute the task - highest_priority_job.remaining_time -= 1 - # check if the task is done - if highest_priority_job.remaining_time <= 0: - highest_priority_job.response_time = ( - current_time - highest_priority_job.release_time - ) - wcrt_dict[highest_priority_job.task["Task"]] = max( - wcrt_dict[highest_priority_job.task["Task"]], - highest_priority_job.response_time, - ) - for i, job in enumerate(jobs_queue): - if job.task["Priority"] == highest_priority_job.task["Priority"]: - jobs_queue.pop(i) - break - else: - current_time += 1 - - # Convert wcrt_dict values to float - wcrt_dict = {k: float(v) for k, v in wcrt_dict.items()} - output_result_csv(input_path, wcrt_dict, tasks_dict, rta) - -if __name__ == "__main__": - app() \ No newline at end of file diff --git a/readme.md b/README.md similarity index 100% rename from readme.md rename to README.md diff --git a/Assignment/02225_Project.pdf b/assignment/docs/02225_Project.pdf similarity index 100% rename from Assignment/02225_Project.pdf rename to assignment/docs/02225_Project.pdf diff --git a/Assignment/README.md b/assignment/docs/README.md similarity index 100% rename from Assignment/README.md rename to assignment/docs/README.md diff --git a/docs/w5-project intro.pdf b/assignment/docs/w5-project intro.pdf similarity index 100% rename from docs/w5-project intro.pdf rename to assignment/docs/w5-project intro.pdf diff --git a/docs/exercise/README.md b/docs/exercise/README.md deleted file mode 100644 index 6b488a4..0000000 --- a/docs/exercise/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# Exercise - -## Update March 10th: - -### Exercise Report Guidelines: - -For the exercise report, please upload a PDF focusing on VSS and RTA implementation results and their comparison. Include discussion on how simulation results compare to theoretical analysis. There are no specific formatting or length requirements — just document your results. - -In addition, submit the source code and the test cases with the results in a ZIP file with a clear README on how to run it. - -**Solution examples:** -We will add by next Friday in the GitHub repo below a few example solutions for the RTA so you can check your analysis code. (The simulation will give different results depending on how long you run it and what assumptions you make, so it does not make sense to provide a solution for that.) - -**Note:** A small mistake in the three small exercise test cases provided on DTU Learn has been fixed: the columns WCET and BCET were swapped compared to the test cases in the GitHub repo. - ---- - -## Update March 7th: - -You may use this tool to generate test cases for the exercise: - -[Taskset Generator Exercise](https://github.com/Plyncesilva/Taskset-Generator-Exercise) - -We have already shared three simple test cases. The TAs will generate extra test cases with the tool and share them via the GitHub repo above. - -Please see the exercise description on Overleaf. - ---- - -## If you have questions: - -Start by asking Google Gemini as follows: - -1. Login to [Google AI Studio](https://aistudio.google.com) (you will need a Google account). -2. At the bottom, click on "+" and then select "My Drive." -3. Add this Google Drive shared folder link (with materials about the exercise): - [Exercise Materials Folder](https://drive.google.com/drive/folders/1hcgpKI-Kizq82VjRzAQ5-0xyGE9hCMOB?usp=share_link) -4. Select "Gemini 2.0 Flash Thinking Experimental 01-21" in the panel to the right. -5. Ask your question and hit "Run." - -The files in the Exerercise/Content tab are test cases are provided as a starting point for the 02225 DRTS exercise. - -They are in CSV (Comma-Separated Values) format and contain the model parameters for periodic tasks: - - - Task: Task name - - BCET: Best-case execution time - - WCET: Worst-case execution time - - Period: Task period - - Deadline: Task deadline (equal to the period) - - Priority: Task priority (assigned by Rate Monotonic scheduling, with lower period yielding higher priority) - -These examples illustrate one possible format. Students may use a different format and create additional test cases. diff --git a/docs/exercise/exercise-TC1.csv b/docs/exercise/exercise-TC1.csv deleted file mode 100644 index 89e3ebe..0000000 --- a/docs/exercise/exercise-TC1.csv +++ /dev/null @@ -1,8 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,0,1,6,6,1 -T2,3,4,60,60,7 -T3,1,1,10,10,2 -T4,1,2,12,12,3 -T5,1,2,15,15,4 -T6,1,3,20,20,5 -T7,1,4,30,30,6 \ No newline at end of file diff --git a/docs/exercise/exercise-TC2.csv b/docs/exercise/exercise-TC2.csv deleted file mode 100644 index 2427ced..0000000 --- a/docs/exercise/exercise-TC2.csv +++ /dev/null @@ -1,12 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,0,1,15,15,1 -T2,1,2,20,20,2 -T3,2,3,25,25,3 -T4,2,4,30,30,4 -T5,3,5,50,50,5 -T6,3,5,60,60,6 -T7,4,6,75,75,7 -T8,5,9,100,100,8 -T9,3,12,120,120,9 -T10,5,11,150,150,10 -T11,6,15,300,300,11 \ No newline at end of file diff --git a/docs/exercise/exercise-TC3.csv b/docs/exercise/exercise-TC3.csv deleted file mode 100644 index 8cd09de..0000000 --- a/docs/exercise/exercise-TC3.csv +++ /dev/null @@ -1,10 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,1,3,40,40,1 -T2,2,7,80,80,2 -T3,1,13,100,100,3 -T4,3,18,160,160,4 -T5,1,22,200,200,5 -T6,5,27,300,300,6 -T7,8,29,320,320,7 -T8,10,34,400,400,8 -T9,22,35,480,480,9 \ No newline at end of file diff --git a/tests/res/files/ex1.csv b/tests/res/files/ex1.csv deleted file mode 100644 index a9aed26..0000000 --- a/tests/res/files/ex1.csv +++ /dev/null @@ -1,8 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,0,1,6,6,1 -T2,3,4,60,60,7 -T3,1,1,10,10,2 -T4,1,2,12,12,3 -T5,1,2,15,15,4 -T6,1,3,20,20,5 -T7,1,4,30,30,6 diff --git a/tests/res/files/ex1_s.csv b/tests/res/files/ex1_s.csv deleted file mode 100644 index 82d76d8..0000000 --- a/tests/res/files/ex1_s.csv +++ /dev/null @@ -1,8 +0,0 @@ -Task,WCRT,Deadline,Status -T1,1.0,6,true -T2,54.0,60,true -T3,2.0,10,true -T4,4.0,12,true -T5,6.0,15,true -T6,10.0,20,true -T7,28.0,30,true diff --git a/tests/res/files/ex2.csv b/tests/res/files/ex2.csv deleted file mode 100644 index be4deef..0000000 --- a/tests/res/files/ex2.csv +++ /dev/null @@ -1,12 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,0,1,15,15,1 -T2,1,2,20,20,2 -T3,2,3,25,25,3 -T4,2,4,30,30,4 -T5,3,5,50,50,5 -T6,3,5,60,60,6 -T7,4,6,75,75,7 -T8,5,9,100,100,8 -T9,3,12,120,120,9 -T10,5,11,150,150,10 -T11,6,15,300,300,11 diff --git a/tests/res/files/ex2_s.csv b/tests/res/files/ex2_s.csv deleted file mode 100644 index 27cee2c..0000000 --- a/tests/res/files/ex2_s.csv +++ /dev/null @@ -1,12 +0,0 @@ -Task,WCRT,Deadline,Status -T1,1.0,15,true -T2,3.0,20,true -T3,6.0,25,true -T4,10.0,30,true -T5,15.0,50,true -T6,23.0,60,true -T7,37.0,75,true -T8,49.0,100,true -T9,98.0,120,true -T10,197.0,150,false -T11,580.0,300,false diff --git a/tests/res/files/ex3.csv b/tests/res/files/ex3.csv deleted file mode 100644 index 7bfe7f1..0000000 --- a/tests/res/files/ex3.csv +++ /dev/null @@ -1,10 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,1,3,40,40,1 -T2,2,7,80,80,2 -T3,1,13,100,100,3 -T4,3,18,160,160,4 -T5,1,22,200,200,5 -T6,5,27,300,300,6 -T7,8,29,320,320,7 -T8,10,34,400,400,8 -T9,22,35,480,480,9 diff --git a/tests/res/files/ex3_s.csv b/tests/res/files/ex3_s.csv deleted file mode 100644 index bd4875b..0000000 --- a/tests/res/files/ex3_s.csv +++ /dev/null @@ -1,10 +0,0 @@ -Task,WCRT,Deadline,Status -T1,3.0,40,true -T2,10.0,80,true -T3,23.0,100,true -T4,44.0,160,true -T5,66.0,200,true -T6,116.0,300,true -T7,148.0,320,true -T8,258.0,400,true -T9,296.0,480,true diff --git a/tests/res/inputs/ex1.csv b/tests/res/inputs/ex1.csv deleted file mode 100644 index a9aed26..0000000 --- a/tests/res/inputs/ex1.csv +++ /dev/null @@ -1,8 +0,0 @@ -Task,BCET,WCET,Period,Deadline,Priority -T1,0,1,6,6,1 -T2,3,4,60,60,7 -T3,1,1,10,10,2 -T4,1,2,12,12,3 -T5,1,2,15,15,4 -T6,1,3,20,20,5 -T7,1,4,30,30,6 diff --git a/tests/res/inputs/ex2.csv b/tests/res/inputs/ex2.csv deleted file mode 100644 index 8b13789..0000000 --- a/tests/res/inputs/ex2.csv +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/res/inputs/ex3.csv b/tests/res/inputs/ex3.csv deleted file mode 100644 index e69de29..0000000 diff --git a/tests/res/solutions/ex1_s.csv b/tests/res/solutions/ex1_s.csv deleted file mode 100644 index 82d76d8..0000000 --- a/tests/res/solutions/ex1_s.csv +++ /dev/null @@ -1,8 +0,0 @@ -Task,WCRT,Deadline,Status -T1,1.0,6,true -T2,54.0,60,true -T3,2.0,10,true -T4,4.0,12,true -T5,6.0,15,true -T6,10.0,20,true -T7,28.0,30,true diff --git a/tests/res/solutions/ex2_s.csv b/tests/res/solutions/ex2_s.csv deleted file mode 100644 index 27cee2c..0000000 --- a/tests/res/solutions/ex2_s.csv +++ /dev/null @@ -1,12 +0,0 @@ -Task,WCRT,Deadline,Status -T1,1.0,15,true -T2,3.0,20,true -T3,6.0,25,true -T4,10.0,30,true -T5,15.0,50,true -T6,23.0,60,true -T7,37.0,75,true -T8,49.0,100,true -T9,98.0,120,true -T10,197.0,150,false -T11,580.0,300,false diff --git a/tests/res/solutions/ex3_s.csv b/tests/res/solutions/ex3_s.csv deleted file mode 100644 index bd4875b..0000000 --- a/tests/res/solutions/ex3_s.csv +++ /dev/null @@ -1,10 +0,0 @@ -Task,WCRT,Deadline,Status -T1,3.0,40,true -T2,10.0,80,true -T3,23.0,100,true -T4,44.0,160,true -T5,66.0,200,true -T6,116.0,300,true -T7,148.0,320,true -T8,258.0,400,true -T9,296.0,480,true diff --git a/tests/test_exercises.py b/tests/test_exercises.py deleted file mode 100644 index c9fe4a3..0000000 --- a/tests/test_exercises.py +++ /dev/null @@ -1,67 +0,0 @@ -import os -import pandas as pd -from Exercises.VerySimpleSimulator.src.very_simple_simulator import run_cycle - - -def test_exercise_1(): - run_test("ex1") - - -def test_exercise_2(): - run_test("ex2") - - -def test_exercise_3(): - run_test("ex3") - - -def run_test(filename: str): - solution_file = os.path.join(get_res_path(), "solutions", f"{filename}_s.csv") - - input_file = os.path.join(get_res_path(), "files", f"{filename}.csv") - output_file = os.path.join(get_res_path(), "files", f"{filename}_s.csv") - - run_cycle(input_file) - - output_df = pd.read_csv(output_file) - solution_df = pd.read_csv(solution_file) - - print(f"Output dataframe shape: {output_df.shape}") - print(f"Solution dataframe shape: {solution_df.shape}") - if not output_df.shape == solution_df.shape: - print("Error: dataframe shape are different") - assert False - - print("Output dataframe:") - print(output_df) - print("==============================") - - print("Solution dataframe:") - print(solution_df) - print("==============================") - assert output_df.equals(solution_df) - - -def get_root(): - """ - Get the project root - """ - return os.path.dirname(os.path.dirname(__file__)) - - -def get_res_path(): - """ - Get the absoulte path of the tests/res folder - """ - return os.path.join(get_root(), "tests", "res") - - -def get_tmp_path(): - """ - Get the absoulte path of the tests/.tmp folder. - If it doesn't exist it creates it - """ - tmp_path = os.path.join(get_root(), "tests", ".tmp") - if not os.path.exists(tmp_path): - os.makedirs(tmp_path) - return tmp_path