@@ -106,7 +106,7 @@ clang++ -std=c++11 -o example example_last_pseudo_code.cpp context.o
These commands compile the assembly code for context manipulation and the C++ code, linking them together to create an executable that demonstrates advanced systems programming techniques in action.
### Results
#### Example
![]Screenshot_2024-01-06_at_01.43.09.png

#### Unit Testing
## Task 2
...
...
@@ -251,6 +251,7 @@ The main function does following:
- Starts the execution of fibers using `globalScheduler.do_it()`.
### Results
#### Example

#### Unit Testing
## Task 3
This solution extends our fiber-based system by introducing the capability for fibers to yield control back to the scheduler before completion. This addition is particularly useful in scenarios like the producer-consumer pattern and other use cases where cooperative multitasking is required. The implementation demonstrates the use of yield in conjunction with get_data to share data between fibers.
...
...
@@ -332,4 +333,33 @@ void do_it() {
- Resuming Fiber Execution: When a fiber that has yielded is resumed, it continues to have access to the shared data. Any changes made to the data by other fibers while it was yielded will be reflected.
globalScheduler.fiber_exit(); // Yield control back to the scheduler
}
```
foo and goo are two fiber functions. foo uses yield to pause its execution, demonstrating how fibers can cooperatively multitask.
main sets up the fibers and shared data, and then starts the fiber execution using `globalScheduler.do_it()`.
**This implementation effectively demonstrates how fibers can be used in a cooperative multitasking environment, especially useful in scenarios where fibers need to yield control back to the scheduler before completing their execution. The addition of yield adds flexibility and enhances the functionality of our fiber-based system.**