D 2004-07-17T01:18:24 J assignee vasiljevic J icomment Logged\sIn:\sYES\s\nuser_id=75003\n\nThe\smacro\sPTHREAD_MUTEX_INITIALIZER\sdoes\snot\sseem\sto\suse\n'pthread_mutex_create'\s(Linux).\s...\sGoogling.\sI\sfound\sthis\n\nhttp://nf.apac.edu.au/facilities/sc/compaq_mirror/HTML/ARH9RBTE/DOCU0022.HTM\nDocs\sfor\s"True64\sUnix".\sIn\sthe\sdescription\sof\n'pthread_mutex_init'\sI\sfind:\n\n\nUse\sthe\sPTHREAD_MUTEX_INITIALIZER\s\smacro\sto\sstatically\ninitialize\sa\smutex\swithout\scalling\sthis\sroutine.\sStatically\ninitialized\smutexes\sneed\snot\sbe\sdestroyed\susing\npthread_mutex_destroy()\n\n\nThe\sopengroup\shas\nhttp://www.opengroup.org/onlinepubs/007908799/xsh/pthread_mutex_init.html\nwhich\ssays\n\n\nIn\scases\swhere\sdefault\smutex\sattributes\sare\sappropriate,\sthe\nmacro\sPTHREAD_MUTEX_INITIALIZER\scan\sbe\sused\sto\sinitialise\nmutexes\sthat\sare\sstatically\sallocated.\sThe\seffect\sis\nequivalent\sto\sdynamic\sinitialisation\sby\sa\scall\sto\npthread_mutex_init()\swith\sparameter\sattr\sspecified\sas\sNULL,\nexcept\sthat\sno\serror\schecks\sare\sperformed.\n\n\nFor\sJava\nhttp://java.icmc.sc.usp.br/library/books/ibm_pthreads/users-61.htm\n\n\nMutex\sinitialization\susing\sthe\sPTHREAD_MUTEX_INITIALIZER\ndoes\snot\simmediately\sinitialize\sthe\smutex.\sInstead,\son\sfirst\nuse,\sthe\spthread_mutex_lock()\sor\spthread_mutex_trylock()\nfunctions\sbranch\sinto\sa\sslow\spath\sand\scause\sthe\ninitialization\sof\sthe\smutex.\sBecause\sa\smutex\sisn't\sjust\sa\nsimple\smemory\sobject,\sand\srequires\sthat\ssome\sresources\sbe\nallocated\sby\sthe\ssystem,\san\sattempt\sto\scall\npthread_mutex_destroy()\sor\spthread_mutex_unlock()\son\sa\smutex\nthat\shas\swas\sstatically\sinitialized\susing\nPTHREAD_MUTEX_INITIALER\sand\swas\snot\syet\slocked\swill\sresult\nin\san\sEINVAL\serror.\n\n\n\nSo\sfor\sat\sleast\ssome\splatforms\sthis\sis\spublically\sdocumented\nbehaviour,\sand\sfor\sothers\sthe\sinteraction\sis\snot\sreally\ntalked\sabout,\smore\simplicit.\sAnd\sfor\ssome\syou\shave\sto\scall\nthe\sdestroy(),\sit\sseems.\n\nConfusing.\s\n\nReassigning\sto\sZoran\sfor\shis\sopinion.\sDavid\sGravereaux's\nopinion\sis\simportant\sas\swelll\sIMHO.\n J login andreas_kupries J mimetype text/plain J username andreas_kupries K 992108ffffffffffffffffffffffffffffffffff U andreas_kupries Z b93c20300c8b24d0af3a51839bbd1b88