Task 4

[ Class Overview ] [ Assembler Crash Course ]

Task 4: Context switching for OOStuBS

Learning objectives

Task description

The goal of this task is to implement simple process management, where the user processes control the processor release following the coroutine concept.

This will require the implementation of some functions to access struct toc, classes Coroutine, Dispatcher, Entrant and Scheduler, as well as the kickoff function. In addition, OOStuBS will now get an Application.
We provide struct toc as well as the Chain and Queue classes in the template code.

In order to be able to access process switching everywhere in OOStuBS, you should create a global instance of the dispatcher in part b and replace it by a global instance scheduler of the Scheduler in part c.

You should demonstrate each class's functionality with a meaningful test program. For this purpose, extend main.cc to create a global instance scheduler of the Scheduler class and a first user process application (an Application object), which in turn creates further user processes. Also make sure to test the methods Scheduler::exit() and Scheduler::kill(Entrant& item). (What happens if your application kills itself?)

Implementation notes

For testing, we recommend to divide the overall task into three parts and to start with part b and c only after part a (or b) has been implemented and tested sufficiently.

Part a

Realize the coroutine switch here. Initially only the access functions to the struct toc and the class Coroutine have to be implemented. To test the solution, create several user processes (which must be derived from Coroutine) in Application (which must also be derived from Coroutine), each of which passes the processor to the next coroutine after a few instructions.

Part b

Next, you should implement the Dispatcher. In the test program, the coroutine switch should now be able to run via the dispatcher.

Part c

Finally, add the Scheduler, which requires the Entrant process abstraction. In the test program, the application and user processes (now as specializations of the Entrant class) must be registered at the scheduler. Accordingly, they no longer need to know each other, because the selection of the next process can now be done by the scheduler.

Template code

We have already done the implementation of the Chain and Queue classes for you, and we also provide a part of toc.

Additional information