@@ -32,15 +40,18 @@ The first part of task 1 explores the basics and implementation of context switc
#### 2.2.1 Variable declaration
This code snippet shows x declared as a volatile. This is to prevent the compiler from optimising it as ideally, we want the program to function as intended with the consideration to x in the context switching scenario.
``` cpp
volatileintx=0;
```
---
<br>
#### 2.2.2 Retrieve Context
This code snippet saves the current state of the execution as well as the instructions pointer, stack pointer and registers into c.
```cpp
Context c;
get_context(&c);
...
...
@@ -50,6 +61,8 @@ volatile int x = 0;
#### 2.2.3 Ouput
This code snippet prints a message to the screen before the context switching happens.
``` cpp
std::cout<<"a message"<<std::endl;
```
...
...
@@ -58,6 +71,8 @@ volatile int x = 0;
#### 2.2.4 Conditional Check and Context Switch
This code snippet shows the conditional and cetext switch where, if x is 0, it gets incremented, and then the execution state is restored with the use of `set_context(&c)`. In addition, `set_context` will jump back to where `get_context` was called, but instead will execute after the if statement and x will now be 1.
```cpp
if (x == 0) {
x = x + 1;
...
...
@@ -67,13 +82,29 @@ volatile int x = 0;
---
<br>
## 2. Task 1 - Fiber Class design and implementation (Part 2)
### 2.3 Testing & Results
In order to run the program there are few a pre-requisites.
- Make to move to the task 1 directory using the command `cd Task\ 1`
- Run the following command within the terminal in order to compile the classes: