Benaphores are nice and fast, but they aren't useful for debugging at
all. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23820 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3037952b5f
commit
5ccd99565d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
@ -81,20 +81,28 @@ benaphore_lock_etc(benaphore *ben, uint32 flags, bigtime_t timeout)
|
||||
static inline status_t
|
||||
benaphore_lock(benaphore *ben)
|
||||
{
|
||||
#ifdef KDEBUG
|
||||
return acquire_sem(ben->sem);
|
||||
#else
|
||||
if (atomic_add(&ben->count, -1) <= 0)
|
||||
return acquire_sem(ben->sem);
|
||||
|
||||
return B_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static inline status_t
|
||||
benaphore_unlock(benaphore *ben)
|
||||
{
|
||||
#ifdef KDEBUG
|
||||
release_sem(ben->sem);
|
||||
#else
|
||||
if (atomic_add(&ben->count, 1) < 0)
|
||||
return release_sem(ben->sem);
|
||||
|
||||
return B_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern status_t rw_lock_init(rw_lock *lock, const char *name);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
@ -202,7 +202,11 @@ benaphore_init(benaphore *ben, const char *name)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
ben->count = 1;
|
||||
#ifdef KDEBUG
|
||||
ben->sem = create_sem(1, name);
|
||||
#else
|
||||
ben->sem = create_sem(0, name);
|
||||
#endif
|
||||
if (ben->sem >= B_OK)
|
||||
return B_OK;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user