From a7a2f1fd6453b10cbebb57211cf394377c7d1791 Mon Sep 17 00:00:00 2001 From: Fareen Lavji Date: Fri, 3 Oct 2025 17:05:47 -0400 Subject: [PATCH 1/9] added comments to dissect problem and solution --- .idea/.gitignore | 11 + .idea/SYSC4001_A1.iml | 8 + .idea/editor.xml | 248 +++++++++++++++++++ .idea/inspectionProfiles/Project_Default.xml | 8 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + interrupts.cpp | 12 +- interrupts.hpp | 11 + 8 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/SYSC4001_A1.iml create mode 100644 .idea/editor.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..e99e292 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,11 @@ +# Default ignored files +/shelf/ +/workspace.xml + +# Editor-based HTTP Client requests +/httpRequests/ + +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml + diff --git a/.idea/SYSC4001_A1.iml b/.idea/SYSC4001_A1.iml new file mode 100644 index 0000000..bc2cd87 --- /dev/null +++ b/.idea/SYSC4001_A1.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..ead1d8a --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,248 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..ebaa316 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6a19034 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/interrupts.cpp b/interrupts.cpp index f868ce2..b040adb 100644 --- a/interrupts.cpp +++ b/interrupts.cpp @@ -2,7 +2,11 @@ * * @file interrupts.cpp * @author Sasisekhar Govind + * @author Fareen. Lavji * + * Assignment assumptions: + * --> ISR of both END/IO and SYSCALL for the same device takes the same amount of time + * --> I/O devices are always available, i.e., no delay on I/O request, immediate start */ #include @@ -20,7 +24,13 @@ int main(int argc, char** argv) { /******************ADD YOUR VARIABLES HERE*************************/ - + /* + * @todo: milestone1.issue3 --> add variables + * activity, eventDuration, deviceNumber, taskEstimate, isrAddress, + * modeBit, deviceName, switchModeDuration = 1ms, saveContextDuration = 10ms, + * isrAddressSearchDuration = 1ms, isrAddressExtractDuration = 1ms, + * iretExecuteDuration, timeOfEvent, eventType, traceFileLineNumber + */ /******************************************************************/ diff --git a/interrupts.hpp b/interrupts.hpp index dacd319..82c19e3 100644 --- a/interrupts.hpp +++ b/interrupts.hpp @@ -139,4 +139,15 @@ void write_output(std::string execution) { std::cout << "Output generated in execution.txt" << std::endl; } + +// Function to iterate through the table line by line +void iterateByLine() const { + for (const auto& row : table_) { + if (row.size() == 2) { // Ensure the row has exactly 2 columns + std::cout << "Column 1: " << row[0] << ", Column 2: " << row[1] << std::endl; + } else { + std::cerr << "Invalid row size. Skipping..." << std::endl; + } + } +} #endif From 10d1dac19500cb6e8ff6f064e94d66b7f410e20c Mon Sep 17 00:00:00 2001 From: tobenna-ezeoke Date: Sat, 4 Oct 2025 18:46:37 -0400 Subject: [PATCH 2/9] Update interrupts.cpp Signed-off-by: tobenna-ezeoke --- interrupts.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/interrupts.cpp b/interrupts.cpp index b040adb..fc318cc 100644 --- a/interrupts.cpp +++ b/interrupts.cpp @@ -31,6 +31,13 @@ int main(int argc, char** argv) { * isrAddressSearchDuration = 1ms, isrAddressExtractDuration = 1ms, * iretExecuteDuration, timeOfEvent, eventType, traceFileLineNumber */ + std::string activity; + int eventDuration = 0; + int deviceNumber = 0; + int taskEstimate = 0; + std::string isrAddress; + int modeBit = 0; + std::string deviceName; /******************************************************************/ From 0e673ec9e365c83f385d499d7036171ced88b024 Mon Sep 17 00:00:00 2001 From: tobenna-ezeoke Date: Sat, 4 Oct 2025 21:16:26 -0400 Subject: [PATCH 3/9] Update interrupts.cpp Signed-off-by: tobenna-ezeoke --- interrupts.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interrupts.cpp b/interrupts.cpp index fc318cc..66e0a88 100644 --- a/interrupts.cpp +++ b/interrupts.cpp @@ -3,6 +3,7 @@ * @file interrupts.cpp * @author Sasisekhar Govind * @author Fareen. Lavji + * @author Dearell Tobenna Ezeoke * * Assignment assumptions: * --> ISR of both END/IO and SYSCALL for the same device takes the same amount of time From 75887e50e8e3adec38fa13f3af19ab756e055c28 Mon Sep 17 00:00:00 2001 From: tobenna-ezeoke Date: Sat, 4 Oct 2025 21:33:36 -0400 Subject: [PATCH 4/9] Update interrupts.cpp Signed-off-by: tobenna-ezeoke --- interrupts.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/interrupts.cpp b/interrupts.cpp index 66e0a88..eccae19 100644 --- a/interrupts.cpp +++ b/interrupts.cpp @@ -32,13 +32,25 @@ int main(int argc, char** argv) { * isrAddressSearchDuration = 1ms, isrAddressExtractDuration = 1ms, * iretExecuteDuration, timeOfEvent, eventType, traceFileLineNumber */ - std::string activity; - int eventDuration = 0; - int deviceNumber = 0; - int taskEstimate = 0; - std::string isrAddress; - int modeBit = 0; - std::string deviceName; + std::string activity; + int eventDuration = 0; + int deviceNumber = -1; + int taskEstimate = 0; + std::string isrAddress; + int modeBit = 0; + std::string deviceName; + + // Fixed timing parameters + const int switchModeDuration = 1; + const int saveContextDuration = 10; + const int isrAddressSearchDuration = 1; + const int isrAddressExtractDuration = 1; + const int iretExecuteDuration = 1; + + // Simulation clocking and event metadata + long long timeOfEvent = 0; + std::string eventType; + int traceFileLineNumber = 0; /******************************************************************/ From 661848a5f8a7e4564065691b02d0bbd069e4d3d1 Mon Sep 17 00:00:00 2001 From: tobenna-ezeoke Date: Sat, 4 Oct 2025 21:36:21 -0400 Subject: [PATCH 5/9] Update interrupts.cpp Signed-off-by: tobenna-ezeoke --- interrupts.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interrupts.cpp b/interrupts.cpp index eccae19..52d39f6 100644 --- a/interrupts.cpp +++ b/interrupts.cpp @@ -40,14 +40,14 @@ int main(int argc, char** argv) { int modeBit = 0; std::string deviceName; - // Fixed timing parameters + // Fixed constants (all measured in ms) const int switchModeDuration = 1; const int saveContextDuration = 10; const int isrAddressSearchDuration = 1; const int isrAddressExtractDuration = 1; const int iretExecuteDuration = 1; - // Simulation clocking and event metadata + // Simulation clocking and events long long timeOfEvent = 0; std::string eventType; int traceFileLineNumber = 0; From 98dc4f4c5c7a2ea5fddcbf870d9adfce67aea945 Mon Sep 17 00:00:00 2001 From: tobenna-ezeoke Date: Sat, 4 Oct 2025 21:41:02 -0400 Subject: [PATCH 6/9] Update interrupts.cpp Signed-off-by: tobenna-ezeoke --- interrupts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interrupts.cpp b/interrupts.cpp index 52d39f6..ed120f6 100644 --- a/interrupts.cpp +++ b/interrupts.cpp @@ -34,7 +34,7 @@ int main(int argc, char** argv) { */ std::string activity; int eventDuration = 0; - int deviceNumber = -1; + int deviceNumber = 0; int taskEstimate = 0; std::string isrAddress; int modeBit = 0; From 904ddf721e28b4494bab2353224b717be2427950 Mon Sep 17 00:00:00 2001 From: tobenna-ezeoke Date: Sun, 5 Oct 2025 20:10:48 +0100 Subject: [PATCH 7/9] Update interrupts.cpp Simulation code added Signed-off-by: tobenna-ezeoke --- interrupts.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/interrupts.cpp b/interrupts.cpp index ed120f6..f305168 100644 --- a/interrupts.cpp +++ b/interrupts.cpp @@ -60,7 +60,85 @@ int main(int argc, char** argv) { /******************ADD YOUR SIMULATION CODE HERE*************************/ - + ++traceFileLineNumber; + + // Keep the parsed label as our event type for logging + eventType = activity; + + if (activity == "CPU") { + eventDuration = duration_intr; + + execution += std::to_string(timeOfEvent) + ", " + + std::to_string(eventDuration) + ", CPU burst\n"; + + timeOfEvent += eventDuration; + modeBit = 0; + continue; + } + + // For interrupts: SYSCALL or END_IO + if (activity == "SYSCALL" || activity == "END_IO") { + deviceNumber = duration_intr; + + isrAddress = vectors.at(deviceNumber); + int totalISRTime = delays.at(deviceNumber); + + int overheadBefore = + switchModeDuration + saveContextDuration + + isrAddressSearchDuration + isrAddressExtractDuration; + + int overheadAfter = iretExecuteDuration; + + // Compute remaining ISR + taskEstimate = totalISRTime - (overheadBefore + overheadAfter); + if (taskEstimate < 0) taskEstimate = 0; + + // switch to kernel mode + modeBit = 1; + eventDuration = switchModeDuration; + execution += std::to_string(timeOfEvent) + ", " + + std::to_string(eventDuration) + ", switch to kernel mode\n"; + timeOfEvent += eventDuration; + + // save context + eventDuration = saveContextDuration; + execution += std::to_string(timeOfEvent) + ", " + + std::to_string(eventDuration) + ", context saved\n"; + timeOfEvent += eventDuration; + + // search vector table entry + eventDuration = isrAddressSearchDuration; + execution += std::to_string(timeOfEvent) + ", " + + std::to_string(eventDuration) + ", find vector for device " + + std::to_string(deviceNumber) + "\n"; + timeOfEvent += eventDuration; + + // ---- extract ISR address + eventDuration = isrAddressExtractDuration; + execution += std::to_string(timeOfEvent) + ", " + + std::to_string(eventDuration) + ", obtain ISR address " + + isrAddress + "\n"; + timeOfEvent += eventDuration; + + // ---- execute ISR body (use the whole remaining budget in one activity) + if (taskEstimate > 0) { + eventDuration = taskEstimate; + execution += std::to_string(timeOfEvent) + ", " + + std::to_string(eventDuration) + ", execute ISR activity (device " + + std::to_string(deviceNumber) + ")\n"; + timeOfEvent += eventDuration; + } + + // ---- IRET + eventDuration = iretExecuteDuration; + execution += std::to_string(timeOfEvent) + ", " + + std::to_string(eventDuration) + ", IRET\n"; + timeOfEvent += eventDuration; + + // back to user mode + modeBit = 0; + continue; + } /************************************************************************/ From f560ccd3a02d01e1762ae2cdf8c05dbbcaca6bfe Mon Sep 17 00:00:00 2001 From: tobenna-ezeoke Date: Sun, 5 Oct 2025 20:39:51 -0400 Subject: [PATCH 8/9] Update interrupts.cpp Signed-off-by: tobenna-ezeoke --- interrupts.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/interrupts.cpp b/interrupts.cpp index f305168..4faee9f 100644 --- a/interrupts.cpp +++ b/interrupts.cpp @@ -93,7 +93,7 @@ int main(int argc, char** argv) { taskEstimate = totalISRTime - (overheadBefore + overheadAfter); if (taskEstimate < 0) taskEstimate = 0; - // switch to kernel mode + // This will switch to kernel mode modeBit = 1; eventDuration = switchModeDuration; execution += std::to_string(timeOfEvent) + ", " @@ -106,21 +106,20 @@ int main(int argc, char** argv) { + std::to_string(eventDuration) + ", context saved\n"; timeOfEvent += eventDuration; - // search vector table entry + // This part searches the vector table entry eventDuration = isrAddressSearchDuration; execution += std::to_string(timeOfEvent) + ", " + std::to_string(eventDuration) + ", find vector for device " + std::to_string(deviceNumber) + "\n"; timeOfEvent += eventDuration; - // ---- extract ISR address + // This will extract ISR address eventDuration = isrAddressExtractDuration; execution += std::to_string(timeOfEvent) + ", " + std::to_string(eventDuration) + ", obtain ISR address " + isrAddress + "\n"; timeOfEvent += eventDuration; - // ---- execute ISR body (use the whole remaining budget in one activity) if (taskEstimate > 0) { eventDuration = taskEstimate; execution += std::to_string(timeOfEvent) + ", " @@ -129,13 +128,13 @@ int main(int argc, char** argv) { timeOfEvent += eventDuration; } - // ---- IRET + // IRET eventDuration = iretExecuteDuration; execution += std::to_string(timeOfEvent) + ", " + std::to_string(eventDuration) + ", IRET\n"; timeOfEvent += eventDuration; - // back to user mode + // Sets it back to user mode modeBit = 0; continue; } From 97881cab593b90c03cadaee3749baf648e0e57eb Mon Sep 17 00:00:00 2001 From: Fareen Lavji Date: Sun, 5 Oct 2025 22:51:26 -0400 Subject: [PATCH 9/9] updated comments --- interrupts.cpp | 8 +------- interrupts.hpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/interrupts.cpp b/interrupts.cpp index 4faee9f..e20c12b 100644 --- a/interrupts.cpp +++ b/interrupts.cpp @@ -4,6 +4,7 @@ * @author Sasisekhar Govind * @author Fareen. Lavji * @author Dearell Tobenna Ezeoke + * @version October 05, 2025 * * Assignment assumptions: * --> ISR of both END/IO and SYSCALL for the same device takes the same amount of time @@ -25,13 +26,6 @@ int main(int argc, char** argv) { /******************ADD YOUR VARIABLES HERE*************************/ - /* - * @todo: milestone1.issue3 --> add variables - * activity, eventDuration, deviceNumber, taskEstimate, isrAddress, - * modeBit, deviceName, switchModeDuration = 1ms, saveContextDuration = 10ms, - * isrAddressSearchDuration = 1ms, isrAddressExtractDuration = 1ms, - * iretExecuteDuration, timeOfEvent, eventType, traceFileLineNumber - */ std::string activity; int eventDuration = 0; int deviceNumber = 0; diff --git a/interrupts.hpp b/interrupts.hpp index 82c19e3..57b6b2e 100644 --- a/interrupts.hpp +++ b/interrupts.hpp @@ -1,6 +1,18 @@ #ifndef INTERRUPTS_HPP_ #define INTERRUPTS_HPP_ +/** + * + * @file interrupts.hpp + * @author Sasisekhar Govind + * @author Fareen. Lavji + * @author Dearell Tobenna Ezeoke + * @version October 05, 2025 + * + * Assignment assumptions: + * --> ISR of both END/IO and SYSCALL for the same device takes the same amount of time + * --> I/O devices are always available, i.e., no delay on I/O request, immediate start + */ #include #include #include