Re: Task switching and state information

new topic     » goto parent     » topic index » view thread      » older message » newer message

--0-1185223281-1127862205=:72080
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

I am working on a small library that will automate wrapping task_yield to allow
multiple libraries to register procedures to be called before and after each task
switch. A library can also cancel a pending task switch. I need this in ME and
other lib authors may find it useful.
 
In summary, the lib will redefine task_yield and expose a global wrap_task_yield
procedure. The procedure will take two integer arguments: the routine id of a
library function to be called before the task switch, and the routine id of a
library procedure to be called after the task switch.
 
The before function will be passed the task ID of the task to be switched from
as a parameter and any return other than 0 will cause the cancellation of the
pending task switch.
 
The after procedure will be passed the task ID of the tasked swtiched to as a
parmeter.
 
[Perhaps these should be 0-argument routines and the library writer calls
task_self. Thoughts?]
 
Whne a program uses multiple libs that use wrap_task_yield, the before functions
will be called in the order in which the calls to wrap_task_yield occurred. The
after procedures will be called in reverse order.
 
If a before fucntion cancels task_yield, then the after procedures will be
called in reverse order beginning with the after procedure for the last library
whose befor fucntion was called prior to the cancellation.
 
An example:  let's say our program includes in order foo.e and bare.e, two
libraries which both use wrap_task_yield.
 
When the redefined task_yield is called, first foo's before function is called
then bar's before function, then the task switch occurrs, then bar's after
procedure is called, then foo's after procedue is called.
 
If bar's before function cancels the task switch, foo's after procedure will be
called but bar's won't; if foo's before function cancels the task switch, no
after procedures will be called.
 
-- Mike Nelson


--0-1185223281-1127862205=:72080
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<DIV>
<DIV>I am working on a small library that will automate wrapping&nbsp;task_yield
to allow multiple libraries to register procedures to be called before and after
each task switch. A library can also cancel a pending task switch. I need this in
ME and other lib authors may find it useful.</DIV>
<DIV>&nbsp;</DIV>
<DIV>In summary, the lib will redefine task_yield and expose a global
wrap_task_yield procedure. The procedure will take two integer arguments: the
routine id of a library function to be called before the task switch, and the
routine id of a library procedure to be called after the task switch.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The before function will be passed the task ID of the task to be switched
from as a parameter and any return other than 0 will cause the cancellation of
the pending task switch.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The after procedure will be passed the task ID of the tasked swtiched to as
a parmeter.</DIV>
<DIV>&nbsp;</DIV>
<DIV>[Perhaps these should be 0-argument routines and the library writer calls
task_self. Thoughts?]</DIV>
<DIV>&nbsp;</DIV>
<DIV>Whne a program uses multiple libs that use wrap_task_yield, the before
functions will be called in the order in which the calls to wrap_task_yield
occurred. The after procedures will be called in reverse order. </DIV>
<DIV>&nbsp;</DIV>
<DIV>If a before fucntion cancels task_yield, then the after procedures will be
called in reverse order beginning with the after procedure for the last library
whose befor fucntion was called prior to the cancellation.&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>An example:&nbsp; let's say our program includes in order foo.e and bare.e,
two libraries which both use wrap_task_yield.&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>When the redefined task_yield is called, first foo's before function is
called then bar's before function, then the task switch occurrs, then bar's after
procedure is called, then foo's after procedue is called.</DIV>
<DIV>&nbsp;</DIV>
<DIV>If bar's before function cancels the task switch, foo's after procedure
will be called but bar's won't; if foo's before function cancels the task switch,
no after procedures will be called.</DIV>
<DIV>&nbsp;</DIV>
<DIV>-- Mike Nelson</DIV></DIV>
--0-1185223281-1127862205=:72080--

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu