Reimplement unnamed POSIX semaphores using user_mutex
* Fixes sharing semantics, so non-shared semaphores in non-shared memory do not become shared after a fork. * Adds two new system calls: _user_mutex_sem_acquire/release(), which reuse the user_mutex address-hashed wait mechanism. * Named semaphores continue to use traditional sem_id semaphores.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 Haiku, Inc.
|
||||
* Copyright 2008-2015 Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SEMAPHORE_H_
|
||||
@@ -13,8 +13,12 @@
|
||||
|
||||
|
||||
typedef struct _sem_t {
|
||||
int32_t id;
|
||||
int32_t _padding[3];
|
||||
int32_t type;
|
||||
union {
|
||||
int32_t named_sem_id;
|
||||
int32_t unnamed_sem;
|
||||
} u;
|
||||
int32_t padding[2];
|
||||
} sem_t;
|
||||
|
||||
#define SEM_FAILED ((sem_t*)(long)-1)
|
||||
|
||||
@@ -20,6 +20,9 @@ status_t _user_mutex_lock(int32* mutex, const char* name, uint32 flags,
|
||||
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);
|
||||
status_t _user_mutex_sem_acquire(int32* sem, const char* name, uint32 flags,
|
||||
bigtime_t timeout);
|
||||
status_t _user_mutex_sem_release(int32* sem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -79,6 +79,9 @@ extern status_t _kern_mutex_lock(int32* mutex, const char* name,
|
||||
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);
|
||||
extern status_t _kern_mutex_sem_acquire(int32* sem, const char* name,
|
||||
uint32 flags, bigtime_t timeout);
|
||||
extern status_t _kern_mutex_sem_release(int32* sem);
|
||||
|
||||
/* sem functions */
|
||||
extern sem_id _kern_create_sem(int count, const char *name);
|
||||
|
||||
Reference in New Issue
Block a user