diff --git a/Assignment/BasicContextSwitch.cpp b/Assignment/BasicContextSwitch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..25f0ad7ed02efa0c9e980ae35d3b63381ff599cf --- /dev/null +++ b/Assignment/BasicContextSwitch.cpp @@ -0,0 +1,17 @@ +#include <iostream> +#include "context.h" // Include the provided context library header + +int main() { + volatile int x = 0; + Context c; + + if (get_context(&c) == 0) { // Save the current context + std::cout << "a message" << std::endl; + + if (x == 0) { + x += 1; + set_context(&c); // Restore the saved context + } + } + return 0; // Return an integer from main +}