This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] added locks around mutex and cond initialization


The actual cond and mutex initialization have a race condition when 2
threads initializes simultanous a mutex initialized with
PTHREAD_MUTEX_INITIALIZE or a cond with PTHREAD_COND_INITIALIZER.

I have added critical sections around mutex and cond creation to fix it.

2002-08-15  Thomas Pfaff  <tpfaff@gmx.net>

	* thread.cc (MTinterface::Init): Initialize critical sections.
	(MTinterface::fixup_after_fork): Ditto after fork.
	(pthread_cond::TimedWait): mutex unlock calls changed.
	(pthread_mutex::Lock): Return 0 on success.
	(__pthread_cond_init): Added critical section around cond
	creation.
	(__pthread_cond_broadcast): Modified check for initialization.
	(__pthread_cond_signal): Ditto.
	(__pthread_cond_dowait); Ditto.
	(__pthread_mutex_init): Added critical section around mutex
	creation.
	(__pthread_mutex_getprioceiling): Modified check for
	initialization.
	(__pthread_mutex_lock): Ditto.
	(__pthread_mutex_trylock): Ditto.
	(__pthread_mutex_unlock): Ditto.
	(__pthread_mutex_setprioceiling): Ditto.
	* thread.h (MUTEX_AUTOINIT_AND_CHECK): New define.
	(COND_AUTOINIT_AND_CHECK): Ditto.
	(MTinterface::mutex_lock): New member.
	(MTinterface::cond_lock): Ditto.

Attachment: pthread_locks.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]