
Originally Posted by
aghast
Any system call will give the OS the opportunity to force a switch. In particular, a blocking call will practically guarantee it. You might consider something like sleep(0); or a write to /dev/null.
Note that there are layers in the standard library that separate you from system calls, so you may have to do some digging. Calling sleep(0) might be intercepted since it's a no-op. (Check the linux sources). Calling printf and friends will almost certainly be buffered, so you'll have to call write or _write or something.