Skip to content
Snippets Groups Projects
Commit b9f66d93 authored by a33-rogers's avatar a33-rogers
Browse files

Merge branch 'main' of https://gitlab.uwe.ac.uk/j2-seechurn/asp_assignment into main

parents ba001ed6 12d27d25
Branches
No related tags found
No related merge requests found
......@@ -5,6 +5,14 @@ Contributors:
- Alex Rogers - 22018703
- Jevhan Seechurn - 21038410
## Table of Contents
1. [Introduction](#1-introduction)
2. [Task 1 - Part One](#2-task-1---fiber-class-design-and-implementation-part-1)
3. [Task 1 - Part Two](#2-task-1---fiber-class-design-and-implementation-part-2)
4. [Task 2](#3-task-2---implementing-a-scheduler-for-fiber-execution)
5. [Task 3 ](#4-task-3---fiber-yielding-and-cooperative-multitasking)
## 1. Introduction
### 1.1 About the Assignment
......@@ -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
volatile int x = 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:
```g++ -o task1.1 task1.1.cpp ../context/context.s -std=c++0```
- Once compiled, we run the next command:
``` ./task1.1 ```
#### 2.3.1 Screenshot 1 Task 1 Part 1 Output
As shown in the screenshot, the program works as intended.
![Task 1 Output](Screenshots/task1_p1.png)
---
<br>
## 2. Task 1 - Fiber Class design and implementation (Part 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment