Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5fde2e7c8b0c67a2b4581a72033b6f10fa070cba
Ticket: 992108ffffffffffffffffffffffffffffffffff
TclFinalizeLock on Unix not correct.
User & Date: andreas_kupries on 2004-07-17 01:18:24
Changes

  1. assignee changed to: "vasiljevic"
  2. icomment:
    Logged In: YES 
    user_id=75003
    
    The macro PTHREAD_MUTEX_INITIALIZER does not seem to use
    'pthread_mutex_create' (Linux). ... Googling. I found this
    
    http://nf.apac.edu.au/facilities/sc/compaq_mirror/HTML/ARH9RBTE/DOCU0022.HTM
    Docs for "True64 Unix". In the description of
    'pthread_mutex_init' I find:
    
    <quote>
    Use the PTHREAD_MUTEX_INITIALIZER  macro to statically
    initialize a mutex without calling this routine. Statically
    initialized mutexes need not be destroyed using
    pthread_mutex_destroy()
    </quote>
    
    The opengroup has
    http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_mutex_init.html
    which says
    
    <quote>
    In cases where default mutex attributes are appropriate, the
    macro PTHREAD_MUTEX_INITIALIZER can be used to initialise
    mutexes that are statically allocated. The effect is
    equivalent to dynamic initialisation by a call to
    pthread_mutex_init() with parameter attr specified as NULL,
    except that no error checks are performed.
    </quote>
    
    For Java
    http://java.icmc.sc.usp.br/library/books/ibm_pthreads/users-61.htm
    
    <quote>
    Mutex initialization using the PTHREAD_MUTEX_INITIALIZER
    does not immediately initialize the mutex. Instead, on first
    use, the pthread_mutex_lock() or pthread_mutex_trylock()
    functions branch into a slow path and cause the
    initialization of the mutex. Because a mutex isn't just a
    simple memory object, and requires that some resources be
    allocated by the system, an attempt to call
    pthread_mutex_destroy() or pthread_mutex_unlock() on a mutex
    that has was statically initialized using
    PTHREAD_MUTEX_INITIALER and was not yet locked will result
    in an EINVAL error.
    </quote>
    
    
    So for at least some platforms this is publically documented
    behaviour, and for others the interaction is not really
    talked about, more implicit. And for some you have to call
    the destroy(), it seems.
    
    Confusing. 
    
    Reassigning to Zoran for his opinion. David Gravereaux's
    opinion is important as welll IMHO.
    
    
  3. login: "andreas_kupries"
  4. mimetype: "text/plain"
  5. username: "andreas_kupries"