Skip to content
Tcl Source Code Artifact [8c7dda4a65]
Login

Artifact [8c7dda4a65]

Artifact 8c7dda4a65d96f59bd08f70cbc81a42dccf1f6da09233c05f76938f2e1719a6e:

Ticket change [8c7dda4a65] - Ticket [893f8cc5db3ba8bd|893f8cc5db] <i>Nested mutexes following TIP 509</i> status still Open with 3 other changes by apnadkarni on 2025-09-18 15:15:57.
D 2025-09-18T15:15:57.385
J icomment >\sI\sdon't\sthink\sso,\sand\seven\swith\saggressive\soptimization\slevel\sthe\scompiler\swouldn't\sgenerate\sthe\scode\sdoing\sthat.\r\n\r\nMy\sconcerns\shad\snothing\sto\sdo\swith\scompilers\sor\soptimization\slevels,\swith\sor\swithout\svolatile\sattributes.\sThey\shave\sto\sdo\swith\scache\scoherency\sin\smultiprocessor\ssystems.\sThinking\sabout\sit\sfurther,\sI'm\seven\smore\sconvinced\sthere\sis\sa\srace\scondition.\sScenario:\r\n\r\n1.\sThread\sA\son\sprocessor\sX\ssuccessfully\stakes\sout\sthe\slock.\r\n2.\sIt\supdates\sthe\sthread\sid\sand\scount\sfields\sin\sthe\smutex\swrapper\sstruct.\sHowever,\s**until\sthere\sis\sa\smemory\sbarrier\sor\ssimilar\sinstruction,\sgenerally\seffected\sby\ssynchronization\sprimitives\sthere\sis\sno\sguaranteed\sthat\sthose\smemory\slocations\sare\swritten\sback\sinto\smain\smemory\sor\ssynchronized\swith\sother\scaches.**\r\n3.\sThread\sB\son\sprocessor\sY\schecks\sthe\svalue\sof\sthe\scount\sand\sthread\sid\sBEFORE\sthread\sA\sreleases\sthe\slock\s(which\swould\shave\scaused\sthe\sprocessor\scache\sflush).\sHowever,\sthe\svalues\sB\ssees\sare\sstale\sbecause\sneither\smain\smemory\snot\sprocessor\sY\scache\shave\sbeen\supdated\swith\sthe\snew\svalues\sfrom\sprocessor\sX\scache.\r\n4.\sWhat\shappens\snext\sdepends\son\sthe\sstale\svalues.\sIf\sthe\sstale\sthread\sid\sis\sX\sand\sthread\scount\sis\snot\s0,\sB\swill\sthink\sit\salready\sowns\sthe\smutex\sand\sproceed\swithout\strying\sto\slock\sit.\r\n5.\sThus\sboth\sA\sand\sB\sthink\sthey\sown\sthe\slock\sand\shave\sa\srace\scondition.
J login apnadkarni
J mimetype text/x-markdown
K 893f8cc5db3ba8bd6bed80ce89a0a75c6088a37c
U apnadkarni
Z 35db45e867d35fc9de592b0e8631492e