© Thomas Kunz 2000
SCE 574
186
   Co-routines (cont.)
äA routine gives up control explicitly by branching to another routine
äIn the example:
äEach routine is only aware of one entry point for each other routine
äThere could be more
äThe scheduler decides on the order of execution
äCould describe the scheduler using a finite state machine/state transition diagram
äThese details could be hard-coded into the routines
äAdvantage: faster execution
äDisadvantage: more difficult to maintain
äCommunication can take place via variables in a data segment
äCo-routines of this nature are usually written in assembler
äNeed access to registers to save context and do branching
äA single stack used in a high level language would get in the way
äWhy? We have not explicitly distinguished threads of control