Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 8a609ca0f5eea7f9185662140b0fe3407cb2e914905ff8729d8eafc27fd9fd8d
Ticket: 893f8cc5db3ba8bd6bed80ce89a0a75c6088a37c
Nested mutexes following TIP 509
User & Date: chw on 2025-09-26 12:39:31
Changes

  1. closedate changed to: "2460945.02744759"
  2. closer changed to: "chw"
  3. icomment:
    > ... the reason why the double checked locking checks for the value **again**
    > after obtaining the lock and does not rely on the preceding check.
    
    Ashok, and here we are again. Let us read carefully the beginnings of
    the recursive mutexing mystery (POSIX without native recursive support):
    
      /* unlocked initial test */
      if (currentthread != owningthread || counter == 0) {
          pthread_mutex_lock(mutex)
      /* ... */
    
    owningthread can be PTHREAD_NULL or a thread identifier. If it were
    the current thread, the counter should be greater than zero, else
    the RAM and caches would be bollocks. Otherwise and all else the mutex
    *must* be locked. And memory *must* be consistent then and we initialize
    all respective memory to a well known state.
    
    My conclusion after all is that we are in the process of full spectrum
    overengineering.
    
    Moreover, this *must* be the same with Win32 CRITICIAL_SECTION, i.e.
    the mutex entry must imply some kind of memory barrier, fence or how
    it might be named in the jargon of the processor architecture.
    
    Even more did I prove with the accepted TIP#511, that recursive
    mutexen add zero value to the POSIX signals process versus threads
    dilemma. And was in the year of 2018 already strongly against those
    recursive mutexes.
    
    So please ditch it. Ultimately. And maybe keep for the boneheads some
    alternative interface. Maybe calling it even
    
     Tcl_RecursiveMutex(Unl|L)ockForTheBoneheads()
    
    with an explicit statement in the documentation that this kind of
    idiotsyncrazy is a powder keg for condition variables.
    
    Thank you for your attention to this matter.
    
  4. login: "chw"
  5. mimetype: "text/plain"