| M E M _ C O O P E R A T E ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English AMIGA - MEM_#?
----------------------------------------------------------------------------
NAME
mem_cooperate() - Turns preemption into cooperativeness
at the task level.
SYNOPSIS
mem_cooperate(pri, signal);
void mem_cooperate(LONG, ULONG);
FUNCTION
This func. changes the behaviour of a loop on a preemptive
system. This results in a loop that does not steal all the
CPU time, but grants it to others who are equally or higher
prioritised.
INPUTS
pri - Priority that the task will be set to when going
to cooperate. It should be 0 to avoid lockups that
may happen if your code executes at high priority.
Never pass anything above 0. Going lower is safe
though, but your task could not be able to recover
if there is a lot of processing going on in the
system.
signal - Signal that will be used to synchronise. This has
to be preallocated signal!
RETURNS
No output.
BASES
SysBase
NOTES
Use this function in a busy-loop event handling if there is
no other efficient way to do that. You can use SIGF_SINGLE
signal for that purpose.
Original task priority will be restored when this function
is done.
SEE ALSO
EXAMPLE
...
LONG spawnedtasks = 0;
...
spawnedtasks += spawntask();
for(;;)
{
if (spawnedtasks == 0)
{
break;
}
mem_cooperate(0, SIGF_SINGLE);
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |