Skip to content
Miro Kropacek edited this page Jan 19, 2017 · 2 revisions

Syield()

VOID Syield( VOID )

'''Syield '''surrenders the remainder of the callers' current process timeslice.

Opcode

255 (0x00ff)

Availability

If the MiNT cookie is present.

Parameters

none.

Binding

move.w  #$00ff,-(sp)
trap    #1
addq.l  #2,sp

Return Value

none.

Comments

This functions is for gentle processes which don't want to hog the CPU. FreeMiNT give time slices to each running process (that's basics of preemptive multitasking). A process may not need all the CPU time it is allocated. For instance, imagine that a process is waiting for a condition to become true. To detect when the condition comes true, it keeps polling it (performing a test in a loop). But as a test doesn't take too much CPU time, there will be a lot of loops in a time slice. 
If the response time is not critical, the process may afford to do one test per time slice (a time slice is typically 10 or 20ms), and if the condition has still not changed, yield the rest of its time slice to other processes so that they can use it to do more useful things than polling a variable. It does that by calling Syield
A kind process that calls Syield is rewarded (it keeps the same priority for the next time slice) wheras a process polling like mad will be punished (lower priority) so it's worth being nice.

See Also

Supexec()

Clone this wiki locally