Co-operative process yield/handoff syscall?

Jari Kirma kirma at cs.hut.fi
Wed Apr 14 10:35:00 PDT 2004


I have been considering implementing concurrent queues between processes
or between kernel driver and process(es) while attempting to removing
unnecessary system calls and context switches in general. There are
several good algorithms for this, FreeBSD has machine/atomic.h which
provides nice atomic operations for both kernel and userland (which
supposedly don't work nicely with MP Itanium without some help from
kernel side, though).

After reading some papers on the subject, I read one [1] which states that
sched_yield that doesn't necessarily yield CPU to other runnable process
if one exists can cause considerable performance hit on these algorithms.
Quick look at FreeBSD kernel suggested me that sched_yield really yields
CPU only if there's higher-priority process runnable. Is there any good
way to emulate the co-operative "handoff" system call suggested on the
paper? Primary feature of such a system call would be to avoid returning
to the same process after sched_yield if any other runnable processes
exist. I suppose inside a multithreaded process, pthread_yield performs
what's expected in this case.

[1] E. Unrau and O. Krieger,
    "Efficient Sleep/Wake-up Protocols for User-Level IPC",
    <http://citeseer.ist.psu.edu/295181.html>

-kirma


More information about the freebsd-threads mailing list