PERFORCE change 65530 for review

David Xu davidxu at FreeBSD.org
Fri Nov 19 21:08:46 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=65530

Change 65530 by davidxu at davidxu_alona on 2004/11/20 05:08:07

	Use rwlock for rtld, current it is not used.

Affected files ...

.. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_rtld.c#2 edit

Differences ...

==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_rtld.c#2 (text+ko) ====

@@ -41,7 +41,6 @@
 static int	_thr_rtld_set_flag(int);
 static void	_thr_rtld_wlock_acquire(void *);
 
-#ifdef NOTYET
 static void *
 _thr_rtld_lock_create(void)
 {
@@ -145,156 +144,3 @@
 {
 	_rtld_thread_init(NULL);
 }
-#endif
-
-struct rtld_kse_lock {
-	struct lock	lck;
-	struct kse	*owner;
-	kse_critical_t	crit;
-	int		count;
-	int		write;
-};
-
-static void *
-_thr_rtld_lock_create(void)
-{
-	struct rtld_kse_lock *l;
-
-	l = malloc(sizeof(struct rtld_kse_lock));
-	_lock_init(&l->lck, LCK_ADAPTIVE, _kse_lock_wait, _kse_lock_wakeup);
-	l->owner = NULL;
-	l->count = 0;
-	l->write = 0;
-	return (l);
-}
-
-static void
-_thr_rtld_lock_destroy(void *lock)
-{
-	/* XXX We really can not free memory after a fork() */
-#if 0
-	struct rtld_kse_lock *l;
-
-	l = (struct rtld_kse_lock *)lock;
-	_lock_destroy(&l->lck);
-	free(l);
-#endif
-	return;
-}
-
-static void
-_thr_rtld_rlock_acquire(void *lock)
-{
-	struct rtld_kse_lock *l;
-	kse_critical_t crit;
-	struct kse *curkse;
-
-	l  = (struct rtld_kse_lock *)lock;
-	crit = _kse_critical_enter();
-	curkse = _get_curkse();
-	if (l->owner == curkse) {
-		l->count++;
-		_kse_critical_leave(crit);	/* probably not necessary */
-	} else {
-		KSE_LOCK_ACQUIRE(curkse, &l->lck);
-		l->crit = crit;
-		l->owner = curkse;
-		l->count = 1;
-		l->write = 0;
-	}
-}
-
-static void
-_thr_rtld_wlock_acquire(void *lock)
-{
-	struct rtld_kse_lock *l;
-	kse_critical_t crit;
-	struct kse *curkse;
-
-	l = (struct rtld_kse_lock *)lock;
-	crit = _kse_critical_enter();
-	curkse = _get_curkse();
-	if (l->owner == curkse) {
-		_kse_critical_leave(crit);
-		PANIC("Recursive write lock attempt on rtld lock");
-	} else {
-		KSE_LOCK_ACQUIRE(curkse, &l->lck);
-		l->crit = crit;
-		l->owner = curkse;
-		l->count = 1;
-		l->write = 1;
-	}
-}
-
-static void
-_thr_rtld_lock_release(void *lock)
-{
-	struct rtld_kse_lock *l;
-	kse_critical_t crit;
-	struct kse *curkse;
-
-	l = (struct rtld_kse_lock *)lock;
-	crit = _kse_critical_enter();
-	curkse = _get_curkse();
-	if (l->owner != curkse) {
-		/*
-		 * We might want to forcibly unlock the rtld lock
-		 * and/or disable threaded mode so there is better
-		 * chance that the panic will work.  Otherwise,
-		 * we could end up trying to take the rtld lock
-		 * again.
-		 */
-		_kse_critical_leave(crit);
-		PANIC("Attempt to unlock rtld lock when not owner.");
-	} else {
-		l->count--;
-		if (l->count == 0) {
-			/*
-			 * If there ever is a count associated with
-			 * _kse_critical_leave(), we'll need to add
-			 * another call to it here with the crit
-			 * value from above.
-			 */
-			crit  = l->crit;
-			l->owner = NULL;
-			l->write = 0;
-			KSE_LOCK_RELEASE(curkse, &l->lck);
-		}
-		_kse_critical_leave(crit);
-	}
-}
-
-
-static int
-_thr_rtld_set_flag(int mask)
-{
-	return (0);
-}
-
-static int
-_thr_rtld_clr_flag(int mask)
-{
-	return (0);
-}
-
-void
-_thr_rtld_init(void)
-{
-	struct RtldLockInfo li;
-
-	li.lock_create  = _thr_rtld_lock_create;
-	li.lock_destroy = _thr_rtld_lock_destroy;
-	li.rlock_acquire = _thr_rtld_rlock_acquire;
-	li.wlock_acquire = _thr_rtld_wlock_acquire;
-	li.lock_release  = _thr_rtld_lock_release;
-	li.thread_set_flag = _thr_rtld_set_flag;
-	li.thread_clr_flag = _thr_rtld_clr_flag;
-	li.at_fork = NULL;
-	_rtld_thread_init(&li);
-}
-
-void
-_thr_rtld_fini(void)
-{
-	_rtld_thread_init(NULL);
-}


More information about the p4-projects mailing list