Task switching and state information
- Posted by Cuvier Christian <christian.cuvier at insee.fr> Sep 27, 2005
- 441 views
Wrapping task_yield() in order to perform a library-wide context switch is a thing to do. However, this can lead to performing a task switch when it isis not needed, as the new active task may not use the library at all, or may not use any state information in it. Hence some iverhead. Another solution is for each routine which uses state information to check whether the state information iss relative to the current task, and perform the switch whenever they are different. This is probably good performance-wise, but requires all the programmer's attention, as s/he should put this code on entry to every routine which uses state information. Perhaps a simpler way would be to define a new keyword, sat "task", used as a prefix when declaring variables. A task variable would be local, and any change to it would be reflected in the task's context. For instance: <eucide> task integer fontSize </eucode> {{{ defines a local integer variable whose value depends on the active task. As it is possible to tell at interpretation time which tasks will use which libraries, the interpreter can optimise things so as to perform a context switch for state information only when there's a chance for it to be relevant. Any thoughts? CChris