diff --git a/Exercises/Response-Time Analysis/.vscode/c_cpp_properties.json b/Exercises/Response-Time Analysis/.vscode/c_cpp_properties.json deleted file mode 100644 index 8f6a31f..0000000 --- a/Exercises/Response-Time Analysis/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [], - "compilerPath": "/usr/bin/g++", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "gcc-x64" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/Exercises/Response-Time Analysis/.vscode/launch.json b/Exercises/Response-Time Analysis/.vscode/launch.json deleted file mode 100644 index 38b9d19..0000000 --- a/Exercises/Response-Time Analysis/.vscode/launch.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Debug C++", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/response_time_analysis", - "args": ["${workspaceFolder}/exercise-TC2.csv"], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], - "preLaunchTask": "build" - } - ] -} \ No newline at end of file diff --git a/Exercises/Response-Time Analysis/.vscode/settings.json b/Exercises/Response-Time Analysis/.vscode/settings.json deleted file mode 100644 index 0cba2e6..0000000 --- a/Exercises/Response-Time Analysis/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files.associations": { - "iostream": "cpp" - } -} \ No newline at end of file diff --git a/Exercises/Response-Time Analysis/.vscode/tasks.json b/Exercises/Response-Time Analysis/.vscode/tasks.json deleted file mode 100644 index 96a19f5..0000000 --- a/Exercises/Response-Time Analysis/.vscode/tasks.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "type": "shell", - "command": "g++", - "args": [ - "-g", - "${workspaceFolder}/src/response_time_analysis.cpp", - "-o", - "${workspaceFolder}/build/response_time_analysis" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": ["$gcc"] - } - ] -} diff --git a/Exercises/Response-Time Analysis/02225_Exercise.pdf b/Exercises/ResponseTimeAnalysis/02225_Exercise.pdf similarity index 100% rename from Exercises/Response-Time Analysis/02225_Exercise.pdf rename to Exercises/ResponseTimeAnalysis/02225_Exercise.pdf diff --git a/Exercises/Response-Time Analysis/README.txt b/Exercises/ResponseTimeAnalysis/README.txt similarity index 100% rename from Exercises/Response-Time Analysis/README.txt rename to Exercises/ResponseTimeAnalysis/README.txt diff --git a/Exercises/Response-Time Analysis/build/real_time_analysis b/Exercises/ResponseTimeAnalysis/build/real_time_analysis similarity index 100% rename from Exercises/Response-Time Analysis/build/real_time_analysis rename to Exercises/ResponseTimeAnalysis/build/real_time_analysis diff --git a/Exercises/Response-Time Analysis/build/response_time_analysis b/Exercises/ResponseTimeAnalysis/build/response_time_analysis similarity index 100% rename from Exercises/Response-Time Analysis/build/response_time_analysis rename to Exercises/ResponseTimeAnalysis/build/response_time_analysis diff --git a/Exercises/Response-Time Analysis/exercise-TC1.csv b/Exercises/ResponseTimeAnalysis/exercise-TC1.csv similarity index 100% rename from Exercises/Response-Time Analysis/exercise-TC1.csv rename to Exercises/ResponseTimeAnalysis/exercise-TC1.csv diff --git a/Exercises/Response-Time Analysis/exercise-TC2.csv b/Exercises/ResponseTimeAnalysis/exercise-TC2.csv similarity index 100% rename from Exercises/Response-Time Analysis/exercise-TC2.csv rename to Exercises/ResponseTimeAnalysis/exercise-TC2.csv diff --git a/Exercises/Response-Time Analysis/exercise-TC3.csv b/Exercises/ResponseTimeAnalysis/exercise-TC3.csv similarity index 100% rename from Exercises/Response-Time Analysis/exercise-TC3.csv rename to Exercises/ResponseTimeAnalysis/exercise-TC3.csv diff --git a/Exercises/Response-Time Analysis/src/real_time_analysis.cpp b/Exercises/ResponseTimeAnalysis/src/real_time_analysis.cpp similarity index 100% rename from Exercises/Response-Time Analysis/src/real_time_analysis.cpp rename to Exercises/ResponseTimeAnalysis/src/real_time_analysis.cpp diff --git a/Exercises/Response-Time Analysis/src/real_time_analysis copy.py b/Exercises/ResponseTimeAnalysis/src/real_time_analysis.py similarity index 99% rename from Exercises/Response-Time Analysis/src/real_time_analysis copy.py rename to Exercises/ResponseTimeAnalysis/src/real_time_analysis.py index 8bac94c..021e3ac 100644 --- a/Exercises/Response-Time Analysis/src/real_time_analysis copy.py +++ b/Exercises/ResponseTimeAnalysis/src/real_time_analysis.py @@ -75,7 +75,7 @@ def run_rta(path_file): """ # Read tasks from CSV tasks = read_csv(path_file) - + print(tasks) # Perform response time analysis analysis_results = response_time_analysis(tasks) diff --git a/Exercises/Response-Time Analysis/src/response_time_analysis.cpp b/Exercises/ResponseTimeAnalysis/src/response_time_analysis.cpp similarity index 100% rename from Exercises/Response-Time Analysis/src/response_time_analysis.cpp rename to Exercises/ResponseTimeAnalysis/src/response_time_analysis.cpp diff --git a/Exercises/Very Simple Simulator/.vscode/c_cpp_properties.json b/Exercises/Very Simple Simulator/.vscode/c_cpp_properties.json deleted file mode 100644 index 8f6a31f..0000000 --- a/Exercises/Very Simple Simulator/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [], - "compilerPath": "/usr/bin/g++", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "gcc-x64" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/Exercises/Very Simple Simulator/.vscode/launch.json b/Exercises/Very Simple Simulator/.vscode/launch.json deleted file mode 100644 index 204b3a0..0000000 --- a/Exercises/Very Simple Simulator/.vscode/launch.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Debug C++", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/very_simple_simulator", - "args": ["${workspaceFolder}/exercise-TC2.csv"], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], - "preLaunchTask": "build" - } - ] -} \ No newline at end of file diff --git a/Exercises/Very Simple Simulator/.vscode/settings.json b/Exercises/Very Simple Simulator/.vscode/settings.json deleted file mode 100644 index 0cba2e6..0000000 --- a/Exercises/Very Simple Simulator/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files.associations": { - "iostream": "cpp" - } -} \ No newline at end of file diff --git a/Exercises/Very Simple Simulator/.vscode/tasks.json b/Exercises/Very Simple Simulator/.vscode/tasks.json deleted file mode 100644 index 11023fd..0000000 --- a/Exercises/Very Simple Simulator/.vscode/tasks.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "type": "shell", - "command": "g++", - "args": [ - "-g", - "${workspaceFolder}/src/very_simple_simulator.cpp", - "-o", - "${workspaceFolder}/build/very_simple_simulator" - ], - "group": "build", - "problemMatcher": [ - "$gcc" - ] - }, - { - "type": "cppbuild", - "label": "C/C++: g++ build active file", - "command": "/usr/bin/g++", - "args": [ - "-fdiagnostics-color=always", - "-g", - "${file}", - "-o", - "${fileDirname}/${fileBasenameNoExtension}" - ], - "options": { - "cwd": "${fileDirname}" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "detail": "Task generated by Debugger." - } - ] -} \ No newline at end of file diff --git a/Exercises/Very Simple Simulator/02225_Exercise.pdf b/Exercises/Very Simple Simulator/02225_Exercise.pdf deleted file mode 100644 index f49c082..0000000 Binary files a/Exercises/Very Simple Simulator/02225_Exercise.pdf and /dev/null differ diff --git a/Exercises/Very Simple Simulator/README.txt b/Exercises/Very Simple Simulator/README.txt deleted file mode 100644 index f028b24..0000000 --- a/Exercises/Very Simple Simulator/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/Very Simple Simulator/build/very_simple_simulator b/Exercises/Very Simple Simulator/build/very_simple_simulator deleted file mode 100644 index e41076a..0000000 Binary files a/Exercises/Very Simple Simulator/build/very_simple_simulator and /dev/null differ diff --git a/Exercises/Very Simple Simulator/exercise-TC1.csv b/Exercises/Very Simple Simulator/exercise-TC1.csv deleted file mode 100644 index 89e3ebe..0000000 --- a/Exercises/Very Simple Simulator/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/Very Simple Simulator/exercise-TC2.csv b/Exercises/Very Simple Simulator/exercise-TC2.csv deleted file mode 100644 index 2427ced..0000000 --- a/Exercises/Very Simple Simulator/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/Very Simple Simulator/exercise-TC3.csv b/Exercises/Very Simple Simulator/exercise-TC3.csv deleted file mode 100644 index 8cd09de..0000000 --- a/Exercises/Very Simple Simulator/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/Very Simple Simulator/src/very_simple_simulator.cpp b/Exercises/Very Simple Simulator/src/very_simple_simulator.cpp deleted file mode 100644 index 399bd1e..0000000 --- a/Exercises/Very Simple Simulator/src/very_simple_simulator.cpp +++ /dev/null @@ -1,181 +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, if you wish -}; - -// 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, ','); // 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(); -} - -// Function to check if all jobs are completed -bool allJobsCompleted(const vector& jobs) -{ - for (const auto& job : jobs) { - if (job.remainingTime > 0) { - return false; - } - } - return true; -} - -// Function to find the job with the highest priority -Job *highest_priority(vector& readyList) -{ - 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 main(int argc, char* argv[]) -{ - if (argc != 2) { - cerr << "Usage: " << argv[0] << " " << endl; - return 1; - } - - string filename = argv[1]; - vector tasks; - readTasksCSV(filename, tasks); - - int n = 1000; - int currentTime = 0; - - vector jobs; - jobs.reserve(tasks.size()); - for (const auto& t : tasks) { - jobs.push_back({t, 0, t.WCET, 0}); - } - - vector worstCaseResponseTimes(tasks.size(), 0); - - while (currentTime < n && !allJobsCompleted(jobs)) - { - // Release new jobs at the start of each period - for (const auto& t : tasks) - { - if (currentTime != 0 && currentTime % t.period == 0) { - jobs.push_back({t, currentTime, t.WCET, 0}); - } - } - - // Get the list of ready jobs - vector readyList = get_ready(jobs, currentTime); - - // If no jobs are ready, increment the current time - if (readyList.empty()) - { - currentTime++; - continue; - } - - // Get the job with the highest priority - Job* currentJob = highest_priority(readyList); - - if (currentJob != nullptr) - { - // Execute the job for one time unit - currentJob->remainingTime--; - currentTime++; - - // If the job is completed, update its response time - if (currentJob->remainingTime <= 0) - { - currentJob->responseTime = currentTime - currentJob->releaseTime; - int taskIndex = distance( - tasks.begin(), - find_if(tasks.begin(), tasks.end(), [&](const Task& tk){ - return tk.id == currentJob->task.id; - }) - ); - worstCaseResponseTimes[taskIndex] = max( - worstCaseResponseTimes[taskIndex], - currentJob->responseTime - ); - } - } - else - { - currentJob->remainingTime--; - currentTime++; - } - } - - // Output the worst-case response times for each task - for (size_t i = 0; i < tasks.size(); ++i) - { - cout << "Task " << tasks[i].id - << " WCRT: " << worstCaseResponseTimes[i] << endl; - } - - return 0; -} \ No newline at end of file diff --git a/Exercises/VerySimpleSimulator/src/task_handler.py b/Exercises/VerySimpleSimulator/src/task_handler.py index d4dbbaf..35f5818 100644 --- a/Exercises/VerySimpleSimulator/src/task_handler.py +++ b/Exercises/VerySimpleSimulator/src/task_handler.py @@ -2,7 +2,7 @@ import numpy as np -def output_result_csv(ouput_path: str, wcrt_dict: dict, tasks: np.array) -> None: +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: @@ -12,11 +12,11 @@ def output_result_csv(ouput_path: str, wcrt_dict: dict, tasks: np.array) -> None # Create a list to store the results results = [] - for job in tasks: + for i, job in enumerate(tasks): task = job["Task"] wcrt = wcrt_dict[task] deadline = job["Deadline"] - status = "true" if wcrt <= deadline else "false" + status = "true" if rta[i]['Status'] == 'Schedulable' else "false" results.append([task, wcrt, deadline, status]) # Create a DataFrame from the results diff --git a/Exercises/VerySimpleSimulator/src/very_simple_simulator.py b/Exercises/VerySimpleSimulator/src/very_simple_simulator.py index 4fcef44..4b141a4 100644 --- a/Exercises/VerySimpleSimulator/src/very_simple_simulator.py +++ b/Exercises/VerySimpleSimulator/src/very_simple_simulator.py @@ -6,11 +6,15 @@ get_ready_list, ) from Exercises.VerySimpleSimulator.src.task_handler import output_result_csv - +from Exercises.ResponseTimeAnalysis.src.real_time_analysis import ( + response_time_analysis, + run_rta +) def run_cycle(input_path: str) -> 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") @@ -61,4 +65,4 @@ def run_cycle(input_path: str) -> None: # 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) + output_result_csv(input_path, wcrt_dict, tasks_dict, rta) \ No newline at end of file