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..e20c12b 100644
--- a/interrupts.cpp
+++ b/interrupts.cpp
@@ -2,7 +2,13 @@
*
* @file interrupts.cpp
* @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
@@ -20,7 +26,25 @@ int main(int argc, char** argv) {
/******************ADD YOUR VARIABLES HERE*************************/
-
+ std::string activity;
+ int eventDuration = 0;
+ int deviceNumber = 0;
+ int taskEstimate = 0;
+ std::string isrAddress;
+ int modeBit = 0;
+ std::string deviceName;
+
+ // 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 events
+ long long timeOfEvent = 0;
+ std::string eventType;
+ int traceFileLineNumber = 0;
/******************************************************************/
@@ -30,7 +54,84 @@ 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;
+
+ // This will 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;
+
+ // 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;
+
+ // This will extract ISR address
+ eventDuration = isrAddressExtractDuration;
+ execution += std::to_string(timeOfEvent) + ", "
+ + std::to_string(eventDuration) + ", obtain ISR address "
+ + isrAddress + "\n";
+ timeOfEvent += eventDuration;
+
+ 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;
+
+ // Sets it back to user mode
+ modeBit = 0;
+ continue;
+ }
/************************************************************************/
diff --git a/interrupts.hpp b/interrupts.hpp
index dacd319..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
@@ -139,4 +151,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