* Moved created subdirectory src/system/kernel/lock.cpp to new subdirectory
locks. * Added syscalls for a new kind of mutex. A mutex consists only of an int32 and doesn't require any kernel resources. So it's initialization cannot fail (it consists only of setting the mutex value to 0). An uncontended lock or unlock operation can basically consist of an atomic_*() in userland. The syscalls (when the mutex is contended) are a bit more expensive than semaphore operations, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36158 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_USER_MUTEX_H
|
||||
#define _KERNEL_USER_MUTEX_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void user_mutex_init();
|
||||
|
||||
status_t _user_mutex_lock(int32* mutex, const char* name, uint32 flags,
|
||||
bigtime_t timeout);
|
||||
status_t _user_mutex_unlock(int32* mutex, uint32 flags);
|
||||
status_t _user_mutex_switch_lock(int32* fromMutex, int32* toMutex,
|
||||
const char* name, uint32 flags, bigtime_t timeout);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _KERNEL_USER_MUTEX_H */
|
||||
@@ -71,6 +71,13 @@ extern status_t _kern_get_safemode_option(const char *parameter,
|
||||
extern ssize_t _kern_wait_for_objects(object_wait_info* infos, int numInfos,
|
||||
uint32 flags, bigtime_t timeout);
|
||||
|
||||
/* user mutex functions */
|
||||
extern status_t _kern_mutex_lock(int32* mutex, const char* name,
|
||||
uint32 flags, bigtime_t timeout);
|
||||
extern status_t _kern_mutex_unlock(int32* mutex, uint32 flags);
|
||||
extern status_t _kern_mutex_switch_lock(int32* fromMutex, int32* toMutex,
|
||||
const char* name, uint32 flags, bigtime_t timeout);
|
||||
|
||||
/* sem functions */
|
||||
extern sem_id _kern_create_sem(int count, const char *name);
|
||||
extern status_t _kern_delete_sem(sem_id id);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SYSTEM_USER_MUTEX_DEFS_H
|
||||
#define _SYSTEM_USER_MUTEX_DEFS_H
|
||||
|
||||
|
||||
// user mutex specific flags passed to _kern_user_mutex_unlock()
|
||||
#define B_USER_MUTEX_UNBLOCK_ALL 0x80000000
|
||||
// All threads currently waiting on the mutex will be unblocked. The mutex
|
||||
// state will be locked.
|
||||
|
||||
|
||||
// mutex value flags
|
||||
#define B_USER_MUTEX_LOCKED 0x01
|
||||
#define B_USER_MUTEX_WAITING 0x02
|
||||
#define B_USER_MUTEX_DISABLED 0x04
|
||||
|
||||
|
||||
#endif /* _SYSTEM_USER_MUTEX_DEFS_H */
|
||||
Reference in New Issue
Block a user