Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
.DS_Store
.DS_Store
tests/.tmp
.pytest_cache
.vscode
__pycache__
.vscode
.ruff_cache
4 changes: 2 additions & 2 deletions Exercises/Response-Time Analysis/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Debug C++",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/real_time_analysis",
"program": "${workspaceFolder}/build/response_time_analysis",
"args": ["${workspaceFolder}/exercise-TC2.csv"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
Expand All @@ -22,4 +22,4 @@
"preLaunchTask": "build"
}
]
}
}
6 changes: 3 additions & 3 deletions Exercises/Response-Time Analysis/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"command": "g++",
"args": [
"-g",
"${workspaceFolder}/src/real_time_analysis.cpp",
"${workspaceFolder}/src/response_time_analysis.cpp",
"-o",
"${workspaceFolder}/build/real_time_analysis"
"${workspaceFolder}/build/response_time_analysis"
],
"group": {
"kind": "build",
Expand All @@ -18,4 +18,4 @@
"problemMatcher": ["$gcc"]
}
]
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ struct Task {
string id;
int BCET;
int WCET;
int period;
int deadline;
int period;
int deadline;
int priority; // Lower number => higher priority for RMS, if you wish
};

Expand All @@ -36,10 +36,10 @@ void readTasksCSV(const string& filename, vector<Task>& tasks)

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, ','); // WCET
task.WCET = stoi(token);
getline(ss, token, ','); // Period
task.period = stoi(token);
getline(ss, token, ','); // Deadline
Expand All @@ -56,43 +56,41 @@ void RTA_test(vector<Task>& 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
return a.priority < b.priority;
});

for (size_t task = 0; task < tasks.size(); task++)
for (size_t i = 0; i < tasks.size(); i++)
{
int R = tasks[task].WCET;
int R = tasks[i].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++)
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;

R = I + tasks[task].WCET;

if (R > tasks[task].deadline)
if (R > tasks[i].deadline)
{
cout << "Task " << tasks[task].id << " is not schedulable." << endl;
cout << "Task " << tasks[i].id << " is not schedulable with WCRT." << endl;
schedulable = false;
break;
}
}

if (schedulable)
{
cout << "Task " << tasks[task].id << " is schedulable with WCRT = " << R << endl;
cout << "Task " << tasks[i].id << " is schedulable with WCRT = " << R << endl;
}
}
}


int main(int argc, char* argv[])
{
if (argc != 2) {
Expand All @@ -107,4 +105,4 @@ int main(int argc, char* argv[])
RTA_test(tasks);

return 0;
}
}
16 changes: 0 additions & 16 deletions Exercises/Very Simple Simulator/.vscode/c_cpp_properties.json

This file was deleted.

25 changes: 0 additions & 25 deletions Exercises/Very Simple Simulator/.vscode/launch.json

This file was deleted.

5 changes: 0 additions & 5 deletions Exercises/Very Simple Simulator/.vscode/settings.json

This file was deleted.

43 changes: 0 additions & 43 deletions Exercises/Very Simple Simulator/.vscode/tasks.json

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ 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
T7,1,4,30,30,6
8 changes: 8 additions & 0 deletions Exercises/VerySimpleSimulator/exercise-TC1_s.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ 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
T11,6,15,300,300,11
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,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
T9,22,35,480,480,9
43 changes: 43 additions & 0 deletions Exercises/VerySimpleSimulator/src/jobs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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
26 changes: 26 additions & 0 deletions Exercises/VerySimpleSimulator/src/task_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pandas as pd
import numpy as np


def output_result_csv(ouput_path: str, wcrt_dict: dict, tasks: np.array) -> 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 job in tasks:
task = job["Task"]
wcrt = wcrt_dict[task]
deadline = job["Deadline"]
status = "true" if wcrt <= deadline 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)
Loading
Loading