diff options
author | rpj <rpj> | 2000-08-18 14:17:28 +0000 |
---|---|---|
committer | rpj <rpj> | 2000-08-18 14:17:28 +0000 |
commit | 170d8032b2fd55450e4533357f4de118b619a8e8 (patch) | |
tree | bb13635e1804f7570546baca70cfdbf47fc28846 /private.c | |
parent | cb1dbf17abe4884c5d8223b7606aec6b11e69a73 (diff) |
2000-08-18 Ross Johnson <rpj@special.ise.canberra.edu.au>
* mutex.c (pthread_mutex_destroy): Check that the mutex isn't
held; invalidate the mutex as early as possible to avoid
contention; not perfect - FIXME!
* rwlock.c (pthread_rwlock_init): Remove redundant assignment
to "rw".
(pthread_rwlock_destroy): Invalidate the rwlock before
freeing up any of it's resources - to avoid contention.
* private.c (ptw32_tkAssocCreate): Change assoc->lock
to use a dynamically initialised mutex - only consumes
a W32 mutex or critical section when first used,
not before.
* mutex.c (pthread_mutex_init): Remove redundant assignment
to "mx".
(pthread_mutexattr_destroy): Set attribute to NULL
before freeing it's memory - to avoid contention.
Diffstat (limited to 'private.c')
-rw-r--r-- | private.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -391,8 +391,7 @@ ptw32_tkAssocCreate (ThreadKeyAssoc ** assocP, * Have to create an association and add it * to both the key and the thread. */ - assoc = (ThreadKeyAssoc *) - calloc (1, sizeof (*assoc)); + assoc = (ThreadKeyAssoc *) calloc (1, sizeof (*assoc)); if (assoc == NULL) { @@ -400,11 +399,22 @@ ptw32_tkAssocCreate (ThreadKeyAssoc ** assocP, goto FAIL0; } +#if 0 + if ((result = pthread_mutex_init (&(assoc->lock), NULL)) != 0) { goto FAIL1; } +#else + + /* + * Initialise only when used for the first time. + */ + assoc->lock = PTHREAD_MUTEX_INITIALIZER; + +#endif + assoc->thread = thread; assoc->key = key; |