That is a *terrible* disgusting way to use yield. Better options:
(1) inotify/dnotify
(2) create a "foo.lock" file and put the mutex in that
(3) just start with the check-file-and-sleep loop.
It works better than doing the wait-loop from the start? What
evidence do you provide to support this assertion? Specifically, in
the first case you tell the kernel "I'm waiting for something but I
don't know what it is or how long it will take"; while in the second
case you tell the kernel "I'm waiting for something that will take
exactly X milliseconds, even though I don't know what it is. If you
really want something similar to the old behavior then just replace
the "sched_yield()" call with a proper sleep for the estimated time
it will take the program to create the file.
We weren't looking for "actual uses", especially not in binary-only
apps. What we are looking for is optimal uses of sched_yield(); ones
where that is the best alternative. This... certainly isn't.
Cheers,
Kyle Moffett
--