Re: [Sablevm-developer] java.lang.Thread.yield()
Brought to you by:
egagnon
From: Prof. E. M. G. <eti...@uq...> - 2003-02-20 02:18:57
|
On Wed, Feb 19, 2003 at 08:36:58PM -0500, Chris Pickett wrote: > I don't know what JNI_OK is defined to be (I couldn't find it with > grep), but if it's zero then that's: > > if (sched_yield() != JNI_OK) > _svmf_error_InternalError (env); No!!!! JNI_OK is used by _svmf_* functions to indicate success. You should never make any relation between the actual integer value JNI_OK is defined as, and the accidental value it matches in another context! If I decided to change JNI_OK to be defined as 36, the code above would start misbehaving (assuming JNI_OK was originally defined as zero). Also, you should *ALWAYS* check return values of non-void functions. I had not double-checked if sched_yield returned a value. I guess I should never trust submitted code and review thoroughly every line of code and the documentation of every called library function... This means I should probably double-check whether sched_yield is actually a POSIX compliant function? (No GNU specific code allowed; SableVM makes portability claims). Etienne -- Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/ |