Skip to content
Open
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
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\msys64\\ucrt64\\bin\\g++.exe"
}
],
"version": 4
}
Binary file added bin/interrupts.exe
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
57 changes: 54 additions & 3 deletions interrupts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
*/

#include<interrupts.hpp>
#include "interrupts.hpp"

int main(int argc, char** argv) {

Expand All @@ -19,8 +19,11 @@ int main(int argc, char** argv) {
std::string execution; //!< string to accumulate the execution output

/******************ADD YOUR VARIABLES HERE*************************/


int current_time = 0;
int context_save = 10;
int switch_time = 1; // Switch from user to kernal mode
int find_vector_time = 1; // Find ISR address or Vector address
int isr_body_time = 40; // execute ISR

/******************************************************************/

Expand All @@ -29,8 +32,56 @@ int main(int argc, char** argv) {
auto [activity, duration_intr] = parse_trace(trace);

/******************ADD YOUR SIMULATION CODE HERE*************************/
int device_delay;
if (duration_intr < (int)delays.size()) {
device_delay = delays[duration_intr];
} else {
device_delay = isr_body_time;
}

if (activity == "CPU") {
execution += std::to_string(current_time) + ", " + std::to_string(duration_intr) + ", CPU bursts\n";
current_time += duration_intr;
} else if (activity == "SYSCALL") {
auto [interrupt_log, updated_time] = intr_boilerplate(current_time, duration_intr, context_save, vectors);
execution += interrupt_log;
current_time = updated_time;

execution += std::to_string(current_time) + ", " + std::to_string(device_delay) + ", SYSCALL: run the ISR (device driver)\n";
current_time += device_delay;

execution += std::to_string(current_time) + ", " + std::to_string(isr_body_time) + ", transfer data from device to memory\n";
current_time += 40;

execution += std::to_string(current_time) + ", 376, check for errors\n";
current_time += 376;

execution += std::to_string(current_time) + ", " + std::to_string(switch_time) + ", IRET\n";
current_time += switch_time;

execution += std::to_string(current_time) + ", " + std::to_string(switch_time) + ", switch to user mode\n";
current_time += switch_time;
} else if (activity == "END_IO") {
auto [interrupt_log, updated_time] = intr_boilerplate(current_time, duration_intr, context_save, vectors);
execution += interrupt_log;
current_time = updated_time;


execution += std::to_string(current_time) + ", " + std::to_string(device_delay) + ", END_IO: run the ISR (device driver)\n";
current_time += device_delay;


execution += std::to_string(current_time) + ", 416, check device status\n";
current_time += 416;


execution += std::to_string(current_time) + ", " + std::to_string(switch_time) + ", IRET\n";
current_time += switch_time;


execution += std::to_string(current_time) + ", " + std::to_string(switch_time) + ", switch to user mode\n";
current_time += switch_time;
}

/************************************************************************/

Expand Down
Loading