Function kickoff

Function kickoff

Placement in the overall structure

Module
thread
Time of creation
Task 4
Files
kickoff.cc

Description

For the very first activation of a Coroutine, a "return address" to a function must be known, from which the transition from the C to the C++ level can then be performed. This function should be kickoff.

Activation of kickoff

When a Coroutine is initialized with the toc_settle() function, not only is the toc struct prepared for the first coroutine switch, but the address of the kickoff function is also placed on the stack as the return address. The first coroutine switch with toc_switch therefore "jumps back" to the beginning of kickoff, where the execution starts.

Task description

void kickoff (void *dummy1, void *dummy2, void *dummy3, void *dummy4, void *dummy5, void *dummy6, Coroutine* object)
This method realizes the jump from the C level to the C++ level by simply calling the method action() of the coroutine object object found as parameter.

Notes

Since this function is not really called, but only jumped to by a clever initialization of the stack of the coroutine, it must never terminate. Otherwise a meaningless value would be interpreted as a return address and the computer would crash.