|
pthread_yield() vs. pthread_yield_np()?
Hi everyone. After spending some time getting familiar with Java at my job, I decided to write a C++ class similar to Thread in Java where all the user has to do is override run() and call start(). The class uses pthreads behind the scenes.
I have used pthreads on Linux before while doing some computer graphics work and was used to using pthread_yield(). However, I originally started working on my thread class on my Mac which, as I'm sure everyone probably knows, is partially BSD-based. In the version of pthread included with OS X.4, there is no pthread_yield() but there is a pthread_yield_np(). I used it and it works on OS X but obviously won't compile on my Linux machine, which has a version of pthread with pthread_yield() but not pthread_yield_np().
So, my question is what are the differences between pthread_yield() and pthread_yield_np()? And more importantly, does anyone know of a way to get the code to compile on either system? I looked through pthread.h for something that might allow a simple #ifdef solution but didn't find anything. Any ideas?
-Brandon
|