* Renamed xsi_ipc_init() to xsi_sem_init() as there will be a xsi_msg_init()
for message queue * Removed unnecessary header Vector.h * Removed HasSemaphoreSet method: since there will be an IPC table for each subsystem, if a key exist, it already has a semaphore set associated with it git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27256 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
extern void xsi_ipc_init();
|
extern void xsi_sem_init();
|
||||||
extern void xsi_sem_undo(struct team *team);
|
extern void xsi_sem_undo(struct team *team);
|
||||||
|
|
||||||
/* user calls */
|
/* user calls */
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ _start(kernel_args *bootKernelArgs, int currentCPU)
|
|||||||
arch_platform_init_post_thread(&sKernelArgs);
|
arch_platform_init_post_thread(&sKernelArgs);
|
||||||
TRACE("init POSIX semaphores\n");
|
TRACE("init POSIX semaphores\n");
|
||||||
realtime_sem_init();
|
realtime_sem_init();
|
||||||
xsi_ipc_init();
|
xsi_sem_init();
|
||||||
|
|
||||||
TRACE("init VM threads\n");
|
TRACE("init VM threads\n");
|
||||||
vm_init_post_thread(&sKernelArgs);
|
vm_init_post_thread(&sKernelArgs);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include <util/AutoLock.h>
|
#include <util/AutoLock.h>
|
||||||
#include <util/DoublyLinkedList.h>
|
#include <util/DoublyLinkedList.h>
|
||||||
#include <util/OpenHashTable.h>
|
#include <util/OpenHashTable.h>
|
||||||
#include <util/Vector.h>
|
|
||||||
|
|
||||||
|
|
||||||
//#define TRACE_XSI_SEM
|
//#define TRACE_XSI_SEM
|
||||||
@@ -581,13 +580,6 @@ public:
|
|||||||
fSemaphoreSetId = semaphoreSet->ID();
|
fSemaphoreSetId = semaphoreSet->ID();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasSemaphoreSet()
|
|
||||||
{
|
|
||||||
if (fSemaphoreSetId != -1)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashTableLink<Ipc>* Link()
|
HashTableLink<Ipc>* Link()
|
||||||
{
|
{
|
||||||
return &fLink;
|
return &fLink;
|
||||||
@@ -626,7 +618,7 @@ struct IpcHashTableDefinition {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Arbitrary limit
|
// Arbitrary limit
|
||||||
#define MAX_XSI_SEMAPHORE 512
|
#define MAX_XSI_SEMAPHORE 2048
|
||||||
static OpenHashTable<IpcHashTableDefinition> sIpcHashTable;
|
static OpenHashTable<IpcHashTableDefinition> sIpcHashTable;
|
||||||
static OpenHashTable<SemaphoreHashTableDefinition> sSemaphoreHashTable;
|
static OpenHashTable<SemaphoreHashTableDefinition> sSemaphoreHashTable;
|
||||||
|
|
||||||
@@ -664,18 +656,18 @@ XsiSemaphoreSet::UnsetID()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xsi_ipc_init()
|
xsi_sem_init()
|
||||||
{
|
{
|
||||||
// Initialize hash tables
|
// Initialize hash tables
|
||||||
status_t status = sIpcHashTable.Init();
|
status_t status = sIpcHashTable.Init();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
panic("xsi_ipc_init() failed to initialized ipc hash table\n");
|
panic("xsi_sem_init() failed to initialize ipc hash table\n");
|
||||||
status = sSemaphoreHashTable.Init();
|
status = sSemaphoreHashTable.Init();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
panic("xsi_ipc_init() failed to initialized semaphore hash table\n");
|
panic("xsi_sem_init() failed to initialize semaphore hash table\n");
|
||||||
|
|
||||||
mutex_init(&sIpcLock, "global Posix IPC table");
|
mutex_init(&sIpcLock, "global POSIX semaphore IPC table");
|
||||||
mutex_init(&sXsiSemaphoreSetLock, "global Posix xsi sem table");
|
mutex_init(&sXsiSemaphoreSetLock, "global POSIX xsi sem table");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -738,11 +730,11 @@ _user_xsi_semget(key_t key, int numberOfSemaphores, int flags)
|
|||||||
MutexLocker _(sIpcLock);
|
MutexLocker _(sIpcLock);
|
||||||
if (key != IPC_PRIVATE) {
|
if (key != IPC_PRIVATE) {
|
||||||
isPrivate = false;
|
isPrivate = false;
|
||||||
// Check if key already has a semaphore associated with it
|
// Check if key already exist, if it does it already has a semaphore
|
||||||
|
// set associated with it
|
||||||
ipcKey = sIpcHashTable.Lookup(key);
|
ipcKey = sIpcHashTable.Lookup(key);
|
||||||
if (ipcKey == NULL) {
|
if (ipcKey == NULL) {
|
||||||
// The ipc key have probably just been created
|
// The ipc key does not exist. Create it and add it to the system
|
||||||
// by the caller, add it to the system
|
|
||||||
if (!(flags & IPC_CREAT)) {
|
if (!(flags & IPC_CREAT)) {
|
||||||
TRACE_ERROR(("xsi_semget: key %d does not exist, but the "
|
TRACE_ERROR(("xsi_semget: key %d does not exist, but the "
|
||||||
"caller did not ask for creation\n",(int)key));
|
"caller did not ask for creation\n",(int)key));
|
||||||
@@ -755,7 +747,7 @@ _user_xsi_semget(key_t key, int numberOfSemaphores, int flags)
|
|||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
sIpcHashTable.Insert(ipcKey);
|
sIpcHashTable.Insert(ipcKey);
|
||||||
} else if (ipcKey->HasSemaphoreSet()) {
|
} else {
|
||||||
// The IPC key exist and it already has a semaphore
|
// The IPC key exist and it already has a semaphore
|
||||||
if ((flags & IPC_CREAT) && (flags & IPC_EXCL)) {
|
if ((flags & IPC_CREAT) && (flags & IPC_EXCL)) {
|
||||||
TRACE_ERROR(("xsi_semget: key %d already exist\n", (int)key));
|
TRACE_ERROR(("xsi_semget: key %d already exist\n", (int)key));
|
||||||
@@ -768,27 +760,18 @@ _user_xsi_semget(key_t key, int numberOfSemaphores, int flags)
|
|||||||
if (!semaphoreSet->HasPermission()) {
|
if (!semaphoreSet->HasPermission()) {
|
||||||
TRACE_ERROR(("xsi_semget: calling process has not permission "
|
TRACE_ERROR(("xsi_semget: calling process has not permission "
|
||||||
"on semaphore %d, key %d\n", semaphoreSet->ID(),
|
"on semaphore %d, key %d\n", semaphoreSet->ID(),
|
||||||
(int)semaphoreSet->IpcKey()));
|
(int)key));
|
||||||
return EACCES;
|
return EACCES;
|
||||||
}
|
}
|
||||||
if (numberOfSemaphores > semaphoreSet->NumberOfSemaphores()
|
if (numberOfSemaphores > semaphoreSet->NumberOfSemaphores()
|
||||||
&& numberOfSemaphores != 0) {
|
&& numberOfSemaphores != 0) {
|
||||||
TRACE_ERROR(("xsi_semget: numberOfSemaphores greater than the "
|
TRACE_ERROR(("xsi_semget: numberOfSemaphores greater than the "
|
||||||
"one associated with semaphore %d, key %d\n",
|
"one associated with semaphore %d, key %d\n",
|
||||||
semaphoreSet->ID(), (int)semaphoreSet->IpcKey()));
|
semaphoreSet->ID(), (int)key));
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
create = false;
|
create = false;
|
||||||
} else {
|
|
||||||
// The IPC key exist but it has not semaphore associated with it
|
|
||||||
if (!(flags & IPC_CREAT)) {
|
|
||||||
TRACE_ERROR(("xsi_semget: key %d has not semaphore associated "
|
|
||||||
"with it and caller did not ask for creation\n",(int)key));
|
|
||||||
return ENOENT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// TODO: Handle case of private key
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (create) {
|
if (create) {
|
||||||
|
|||||||
Reference in New Issue
Block a user