*** empty log message ***

This commit is contained in:
glenux 2004-02-22 11:19:08 +00:00
parent 53d08b99df
commit b6f07d0e1e
3 changed files with 47 additions and 2 deletions

36
src/nzg_bufferInit.c Normal file
View file

@ -0,0 +1,36 @@
#include "libnazgul.h"
int msgBufferInit(msgPoolData * poolDataTabAddr,int poolIndex){
msgBufferInfoTabId bufferInfoTabId;
int bufferInfoTabFd;
msgBufferInfo * bufferInfoTabAddr;
int bufferInfoNb;
int bufferFreeIndex;
//récuperer l'ID du BufferInfoTab;
strcpy(bufferInfoTabId, poolDataTabAddr[poolIndex].bufferInfoTabId);
bufferInfoTabFd=shm_open(bufferInfoTabId,O_RDWR,SHM_DEFAULT_MODE);
if (bufferInfoTabFd<0){
perror("shm_open");
return -1;
}
/** on regarde dans le tableau d'infos de buffer **/
bufferInfoNb=poolDataTabAddr[poolIndex].bufferNb;
bufferInfoTabAddr=mmap(NULL,bufferInfoNb*sizeof(msgBufferInfo),
PROT_READ,MAP_SHARED,bufferInfoTabFd,(off_t)0);
int i=0;
while ((i<bufferInfoNb)
&& (bufferInfoTabAddr[i].ownerPid != (pid_t)-1)){ i++; }
if (i == bufferInfoNb){ return -1; }
bufferFreeIndex=i;
if (munmap(bufferInfoTabAddr,bufferInfoNb*sizeof(msgBufferInfo))< 0)
{ perror("munmap"); return -1; }
return -1;
}

View file

@ -13,6 +13,8 @@ typedef char msgSpaceListElemId[4*MSGSPACE_ID_LEN];
typedef char msgPoolDataTabId[4*MSGSPACE_ID_LEN]; typedef char msgPoolDataTabId[4*MSGSPACE_ID_LEN];
typedef char msgPoolDataTabSemId[4*MSGSPACE_ID_LEN]; typedef char msgPoolDataTabSemId[4*MSGSPACE_ID_LEN];
typedef char msgBufferInfoTabId[4*MSGSPACE_ID_LEN];
typedef char msgPoolId[4*MSGSPACE_ID_LEN]; typedef char msgPoolId[4*MSGSPACE_ID_LEN];
typedef char msgPoolSemId[4*MSGSPACE_ID_LEN]; typedef char msgPoolSemId[4*MSGSPACE_ID_LEN];
@ -26,12 +28,17 @@ typedef struct MsgPool {
int bufferNb; int bufferNb;
} msgPool; } msgPool;
typedef struct MsgBufferInfo {
pid_t ownerPid;
void * addr;
} msgBufferInfo;
typedef struct MsgPoolData { typedef struct MsgPoolData {
msgPoolId id; msgPoolId id;
msgBufferInfoTabId bufferInfoTabId;
int bufferNb; int bufferNb;
int bufferSize; int bufferSize;
int allocDispBuffer; int allocDispBuffer;
sem_t * allocOverload;
} msgPoolData; } msgPoolData;
/* TODO: queueId */ /* TODO: queueId */

View file

@ -12,7 +12,9 @@ int msgPoolCreate(msgSpaceId spaceId, int poolIdx, int buffNb, int buffSize);
msgSpace *msgSpaceCreate(msgSpaceId spaceId, int queueNb, int poolNb, msgPool *poolInfos); msgSpace *msgSpaceCreate(msgSpaceId spaceId, int queueNb, int poolNb, msgPool *poolInfos);
msgSpace *msgSpaceOpen(msgSpaceId spaceId); msgSpace *msgSpaceOpen(msgSpaceId spaceId);
int msgSpaceDelete(msgSpaceId spaceId); int msgSpaceDelete(msgSpaceId spaceId);
/* src/nzg_state.c */ /* src/nzg_buffer.c */
int msgBufferGetFreeIndex(msgPoolData * poolDataTab, int poolIndex);
int msgBufferAttachProc(msgPoolData * poolDataTab, int poolIndex, void *addr);
#endif #endif