Implemented geist's recent change to mutexes - they are now no longer
benaphores; benaphores aren't that beneficial in kernel land, the benaphores are a way to reduce the number of kernel calls. They can now only be released by the same thread who originally acquired it. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@312 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,11 +6,12 @@
|
||||
#define _KERNEL_LOCK_H
|
||||
|
||||
#include <kernel.h>
|
||||
#include <debug.h>
|
||||
|
||||
typedef struct recursive_lock {
|
||||
sem_id sem;
|
||||
thread_id holder;
|
||||
int recursion;
|
||||
sem_id sem;
|
||||
} recursive_lock;
|
||||
|
||||
int recursive_lock_create(recursive_lock *lock);
|
||||
@@ -19,9 +20,11 @@ bool recursive_lock_lock(recursive_lock *lock);
|
||||
bool recursive_lock_unlock(recursive_lock *lock);
|
||||
int recursive_lock_get_recursion(recursive_lock *lock);
|
||||
|
||||
#define ASSERT_LOCKED_RECURSIVE(r) { ASSERT(thread_get_current_thread_id() == (r)->holder); }
|
||||
|
||||
typedef struct mutex {
|
||||
int count;
|
||||
sem_id sem;
|
||||
thread_id holder;
|
||||
} mutex;
|
||||
|
||||
int mutex_init(mutex *m, const char *name);
|
||||
@@ -29,6 +32,8 @@ void mutex_destroy(mutex *m);
|
||||
void mutex_lock(mutex *m);
|
||||
void mutex_unlock(mutex *m);
|
||||
|
||||
#define ASSERT_LOCKED_MUTEX(m) { ASSERT(thread_get_current_thread_id() == (m)->holder); }
|
||||
|
||||
// for read/write locks
|
||||
#define MAX_READERS 100000
|
||||
|
||||
@@ -42,6 +47,13 @@ typedef struct benaphore benaphore;
|
||||
// it may make sense to add a status field to the rw_lock to
|
||||
// be able to check if the semaphore could be locked
|
||||
|
||||
// Note: using rw_lock in this way probably doesn't make too much sense
|
||||
// for use in the kernel, we may change this in the near future.
|
||||
// It basically uses 2 benaphores to create the rw_lock which is not
|
||||
// necessary in the kernel -- axeld, 2002/07/18.
|
||||
// Furthermore, those should probably be __inlines - I didn't know about
|
||||
// them earlier... :-)
|
||||
|
||||
struct rw_lock {
|
||||
sem_id sem;
|
||||
int32 count;
|
||||
@@ -119,5 +131,4 @@ typedef struct rw_lock rw_lock;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL_LOCK_H */
|
||||
|
||||
Reference in New Issue
Block a user