diff --git a/README.md b/README.md index 7be164086999c6819e5cc8eec79bd4813996b155..3b16c19b31a8eb687ea818ef18aae0f31be55f71 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ In this assignment, we are given the task of the implementing a simple runtime t ### 1.2 What is a Fiber ? -Fibers +Provide an explanation on fibers ### 1.2 What is a Thread ? - +Provide an explanation on threads --- @@ -25,11 +25,41 @@ Fibers ### 2.1 Explanation -Task 1 involves the implementation of a context switching system for fibers in C++ and focuses on saving and storing the execution state of a program, which enables the switching between alternate execution paths. The process will involves the manipulations of stacks as well as CPU registers and instructions pointer which will be execcuted via assembly functions. The objective is to create an implementaton that will allow the user to switch manually in between functons (fibers), which will simulate cooperative multitasking on a single thread. +Task 1 involves the implementation of a context switching system for fibers in C++ and focuses on saving and storing the execution state of a program, which enables the switching between alternate execution paths. + +The process will involves the manipulations of stacks as well as CPU registers and instructions pointer which will be execcuted via assembly functions. The objective is to create an implementaton that will allow the user to switch manually in between functons (fibers), which will simulate cooperative multitasking on a single thread. + +### 2.2 Part 1 - Basic Context Switching + +The first part of task 1 explores the basics and implementation of context switching, which focuses on saving and restoring the program's execution state. We implement a simple mechanicsm in order to pause and continue execution by using a context library. + +#### Implementation + +``` cpp +volatile int x = 0; + +int main() { + + x = 0; + + Context c; + get_context(&c); + + std::cout << "a message" << std::endl; + + if (x == 0) { + x = x + 1; + set_context(&c); + } + + return 0; +} ``` + +#### Testing -### 2.1 Implementation +screenshot here -### 2.1 Testing +### 2.3 Part 2 ---