[comp.sys.amiga] The dropped Yield

dale@amiga.UUCP (Dale Luck) (08/11/87)

A long time ago, before exec became as elegant as it is now there existed
a Yield() function.  As signals/semaphores/ports etc became the right
way to do things, this function became unnecessary. And it is unnecessary
in a perfect world where everybody does the correct Wait() type programming.
I however had some cpu intensive demos that just sank the machine when
they were all running without this Yield function so for tasks that were
running at the same priority in a round robin fashion, i wrote.
As long as all the competing tasks used Yield or Waited.

Yield()
{
	struct Task *t = FindTask(0);
	/* Say bye bye */
	oldpri = SetTaskPri(t,t->tc_Node.ln_Pri - 1);
	/* Oh, we are back again, restore priority */
	SetTaskPri(t,oldpri);
}

This has the affect of lowering all competing tasks priority down one
notch. The current running task runs at it's normal priority.
In the case of a task setting it's own task priority, a reschedule is
called and if there are any ready tasks of equal or same priority, then
put this one to sleep and start up the first one waiting. Note, the
fact that it may start up the next task without waiting for the quantum
to expire may actually be me misunderstanding what it is actually doing
though.
Dale Luck