[PATCH] Implement pthread_rwlocks

Thomas Pfaff tpfaff@gmx.net
Thu Feb 27 12:28:00 GMT 2003


This patch adds support for pthread_rwlocks. Attached are testcases from
the pthreads-win32 project.

The rwlock implementation follows the opengroup spec that it will
prefer writers among readers and check for deadlock conditions.

2003-02-27  Thomas Pfaff  <tpfaff@gmx.net>

	* cygwin.din: Add pthread_rwlock_destroy, pthread_rwlock_init,
	pthread_rwlock_rdlock, pthread_rwlock_tryrdlock,
	pthread_rwlock_wrlock, pthread_rwlock_trywrlock,
	pthread_rwlock_unlock, pthread_rwlockattr_init,
	pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared,
	and pthread_rwlockattr_destroy.
	* include/cygwin/version.h: Bump API minor number.
	* include/pthread.h (PTHREAD_RWLOCK_INITIALIZER): Define a
	reasonable value.
	Add prototypes for pthread_rwlock_destroy, pthread_rwlock_init,
	pthread_rwlock_rdlock, pthread_rwlock_tryrdlock,
	pthread_rwlock_wrlock, pthread_rwlock_trywrlock,
	pthread_rwlock_unlock, pthread_rwlockattr_init,
	pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared,
	and pthread_rwlockattr_destroy.
	* thread.h (PTHREAD_ONCE_MAGIC): Remove superflous semicolon.
	(PTHREAD_RWLOCK_MAGIC): New define.
	(PTHREAD_RWLOCKATTR_MAGIC): Ditto.
	(pthread_rwlockattr): New class.
	(pthread_rwlock): Ditto.
	(MTinterface::rwlocks): New member.
	(MTinterface::MTinterface): Initialize rwlocks.
	Add prototypes for __pthread_rwlock_destroy,
	__pthread_rwlock_wrlock, __pthread_rwlock_trywrlock,
	__pthread_rwlock_unlock, __pthread_rwlockattr_init,
	__pthread_rwlockattr_getpshared, __pthread_rwlockattr_setpshared,
	and __pthread_rwlockattr_destroy.
	* thread.cc (MTinterface::Init): Initialize rwlock internal mutex.
	(MTinterface::fixup_after_fork): Fixup rwlocks after fork.
	(pthread_rwlockattr::isGoodObject): Implement.
	(pthread_rwlockattr::pthread_rwlockattr): Ditto.
	(pthread_rwlockattr::~pthread_rwlockattr): Ditto.
	(pthread_rwlock::initMutex): Ditto.
	(pthread_rwlock::pthread_rwlock): Ditto.
	(pthread_rwlock::~pthread_rwlock): Ditto.
	(pthread_rwlock::RdLock): Ditto.
	(pthread_rwlock::TryRdLock): Ditto.
	(pthread_rwlock::WrLock): Ditto.
	(pthread_rwlock::TryWrLock): Ditto.
	(pthread_rwlock::UnLock): Ditto.
	(pthread_rwlock::addReader): Ditto.
	(pthread_rwlock::removeReader): Ditto.
	(pthread_rwlock::lookupReader): Ditto.
	(pthread_rwlock::RdLockCleanup): Ditto.
	(pthread_rwlock::WrLockCleanup): Ditto.
	(pthread_rwlock::fixup_after_fork): Ditto.
	(pthread_rwlock::isGoodObject): Ditto.
	(pthread_rwlock::isGoodInitializer): Ditto.
	(pthread_rwlock::isGoodInitializerOrObject): Ditto.
	(pthread_rwlock::isGoodInitializerOrBadObject): Ditto.
	(__pthread_rwlock_destroy): Ditto.
	(pthread_rwlock::init): Ditto.
	(__pthread_rwlock_rdlock): Ditto.
	(__pthread_rwlock_tryrdlock): Ditto.
	(__pthread_rwlock_wrlock): Ditto.
	(__pthread_rwlock_trywrlock): Ditto.
	(__pthread_rwlock_unlock): Ditto.
	(__pthread_rwlockattr_init): Ditto.
	(__pthread_rwlockattr_getpshared): Ditto.
	(__pthread_rwlockattr_setpshared): Ditto.
	(__pthread_rwlockattr_destroy): Ditto.
	* pthread.cc (pthread_rwlock_destroy): Implement:
	(pthread_rwlock_init): Ditto.
	(pthread_rwlock_rdlock): Ditto.
	(pthread_rwlock_tryrdlock): Ditto.
	(pthread_rwlock_wrlock): Ditto.
	(pthread_rwlock_trywrlock): Ditto.
	(pthread_rwlock_unlock): Ditto.
	(pthread_rwlockattr_init): Ditto.
	(pthread_rwlockattr_getpshared): Ditto.
	(pthread_rwlockattr_getpshared): Ditto.
	(pthread_rwlockattr_destroy): Ditto.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rwlock.tar.gz
Type: application/x-gzip
Size: 3013 bytes
Desc: 
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20030227/13d69d2b/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pthread_rwlock.patch
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20030227/13d69d2b/attachment.ksh>


More information about the Cygwin-patches mailing list