From owner-p4-projects Wed Mar 5 12:55:15 2003 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0424337B405; Wed, 5 Mar 2003 12:55:13 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A6E6C37B401 for ; Wed, 5 Mar 2003 12:55:12 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5396943FBF for ; Wed, 5 Mar 2003 12:55:12 -0800 (PST) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h25KtC0U098171 for ; Wed, 5 Mar 2003 12:55:12 -0800 (PST) (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h25KtB2Y098168 for perforce@freebsd.org; Wed, 5 Mar 2003 12:55:11 -0800 (PST) Date: Wed, 5 Mar 2003 12:55:11 -0800 (PST) Message-Id: <200303052055.h25KtB2Y098168@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 26393 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=26393 Change 26393 by jhb@jhb_laptop on 2003/03/05 12:54:38 Teach mtx_trylock() to recurse. No hope of inlining this thing in the future now. Too much of a pig. Affected files ... .. //depot/projects/smpng/sys/kern/kern_mutex.c#61 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_mutex.c#61 (text+ko) ==== @@ -454,10 +454,8 @@ /* * The important part of mtx_trylock{,_flags}() - * Tries to acquire lock `m.' We do NOT handle recursion here. If this - * function is called on a recursed mutex, it will return failure and - * will not recursively acquire the lock. You are expected to know what - * you are doing. + * Tries to acquire lock `m.' If this function is called on a mutex that + * is already owned, it will recursively acquire the lock. */ int _mtx_trylock(struct mtx *m, int opts, const char *file, int line) @@ -466,7 +464,12 @@ MPASS(curthread != NULL); - rval = _obtain_lock(m, curthread); + if (mtx_owned(m)) { + m->mtx_recurse++; + atomic_set_ptr(&m->mtx_lock, MTX_RECURSED); + rval = 1; + } else + rval = _obtain_lock(m, curthread); LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line); if (rval) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message