Function kickoff
Placement in the overall structure
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 bekickoff
.
Activation of kickoff
When a Coroutine is initialized with thetoc_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)
-
The most essential function of kickoff is of course still to make the jump from
the C to C++ by calling the
action()
method of the coroutine object found in the 7th parameter. The six dummy parameters are necessary because on x86_64 the first six parameters are passed via registers and only the seventh parameter is expected on the stack.Furthermore, kickoff allows the same initialization to be used for all coroutine objects. For example, context switches are always triggered from a critical section. Therefore, the first action of the new coroutine must be to release the critical section.