* renommages

This commit is contained in:
glenux 2004-02-21 13:17:47 +00:00
parent 983e92b66c
commit 39dfbe3307
7 changed files with 35 additions and 19 deletions

View file

@ -18,7 +18,7 @@ void * msgAllocate(msgSpace *space,
void * resultAddr; void * resultAddr;
int i, mSPoolDataTabFd; int i, mSPoolDataTabFd;
msgSpacePoolId resultPoolID; msgPoolId resultPoolID;
/* tableau des valeurs des semPoolCoef/pool pour identifier le pool /* tableau des valeurs des semPoolCoef/pool pour identifier le pool
* qui sera libéré le plus rapidement */ * qui sera libéré le plus rapidement */
float semPoolCoef[space->poolNb]; float semPoolCoef[space->poolNb];
@ -109,6 +109,7 @@ void * msgAllocate(msgSpace *space,
} }
} }
}else { }else {
semFd=sem_open(mSPoolDataTab[i].id,0); semFd=sem_open(mSPoolDataTab[i].id,0);
if (sem_wait(semFd) < 0){ if (sem_wait(semFd) < 0){
perror("sem_wait"); perror("sem_wait");

View file

@ -17,28 +17,41 @@ int msgSpaceIdIntern(msgSpaceId dest,const msgSpaceId src ){
return 0; return 0;
} }
int msgPoolDataIdIntern(msgSpaceId dest,const msgSpaceId src ){ int msgPoolSemIdIntern(msgSemId destSemId,const msgPoolDataId srcPoolId ){
if (strlen(srcPoolId)>MSGSPACE_ID_LEN*4){
return -1;
}
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID
sprintf(destSemId,"/tmp/nzgPoolData%s",(char *)srcPoolId);
#else
sprintf(destSemId,"/nzgPoolData%s",(char *)srcPoolId);
#endif
return 0;
}
int msgPoolDataIdIntern(msgPoolDataId dest,const msgSpaceId src ){
if (strlen(src)>MSGSPACE_ID_LEN){ if (strlen(src)>MSGSPACE_ID_LEN){
return -1; return -1;
} }
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */ /* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID #ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgSpacePoolData%s",(char *)src); sprintf(dest,"/tmp/nzgPoolData%s",(char *)src);
#else #else
sprintf(dest,"/nzgSpacePoolData%s",(char *)src); sprintf(dest,"/nzgPoolData%s",(char *)src);
#endif #endif
return 0; return 0;
} }
int msgSpacePoolId2nzgPoolId(msgSpacePoolId dest,msgSpacePoolId src, int num){ int msgSpacePoolId2nzgPoolId(msgPoolId dest,msgPoolId src, int num){
if (strlen(src)>MSGSPACE_ID_LEN){ if (strlen(src)>MSGSPACE_ID_LEN){
return -1; return -1;
} }
#ifdef _NZG_REALFILEID #ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgSpacePool%s%d",(char *)src,num); sprintf(dest,"/tmp/nzgPool%s%d",(char *)src,num);
#else #else
sprintf(dest,"/nzgSpacePool%s%d",(char *)src,num); sprintf(dest,"/nzgPool%s%d",(char *)src,num);
#endif #endif
return 0; return 0;
} }

View file

@ -7,7 +7,7 @@
/* nzg_ids.c */ /* nzg_ids.c */
int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src); int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src);
int msgPoolDataIdIntern(msgSpaceId dest, const msgSpaceId src); int msgPoolDataIdIntern(msgSpaceId dest, const msgSpaceId src);
int msgSpacePoolId2nzgPoolId(msgSpacePoolId dest, msgSpacePoolId src, int num); int msgSpacePoolId2nzgPoolId(msgPoolId dest, msgPoolId src, int num);
#endif #endif

View file

@ -10,10 +10,12 @@ typedef char msgSpaceId[MSGSPACE_ID_LEN];
typedef char msgSpaceListId[4*MSGSPACE_ID_LEN]; typedef char msgSpaceListId[4*MSGSPACE_ID_LEN];
typedef char msgSpaceListElemId[4*MSGSPACE_ID_LEN]; typedef char msgSpaceListElemId[4*MSGSPACE_ID_LEN];
typedef char msgSpacePoolDataId[4*MSGSPACE_ID_LEN]; typedef char msgPoolDataId[4*MSGSPACE_ID_LEN];
typedef char msgSpacePoolId[4*MSGSPACE_ID_LEN]; typedef char msgPoolId[4*MSGSPACE_ID_LEN];
typedef char msgSpaceQueueDataId[4*MSGSPACE_ID_LEN]; typedef char msgSemId[4*MSGSPACE_ID_LEN];
typedef char msgSpaceQueueId[4*MSGSPACE_ID_LEN];
typedef char msgQueueDataId[4*MSGSPACE_ID_LEN];
typedef char msgQueueId[4*MSGSPACE_ID_LEN];
/* pid[] */ /* pid[] */
/* liste des processus demandeurs */ /* liste des processus demandeurs */
@ -23,7 +25,7 @@ typedef struct MsgPool {
} msgPool; } msgPool;
typedef struct MsgPoolData { typedef struct MsgPoolData {
msgSpacePoolId id; msgPoolId id;
int bufferNb; int bufferNb;
int bufferSize; int bufferSize;
int allocDispBuffer; int allocDispBuffer;
@ -38,7 +40,7 @@ typedef struct MsgSpace {
int poolNb; int poolNb;
int queueNb; int queueNb;
int pid; int pid;
msgSpacePoolDataId poolDataId; msgPoolDataId poolDataId;
} msgSpace; } msgSpace;

View file

@ -4,14 +4,14 @@
liste process demandeurs */ liste process demandeurs */
int msgPoolCreate( int msgPoolCreate(
msgSpacePoolId poolId, msgPoolId poolId,
int buffNb, int buffNb,
int buffSize int buffSize
) { ) {
int poolFd; int poolFd;
static int poolNb; static int poolNb;
msgSpacePoolId id; msgPoolId id;
sem_t * sem; sem_t * sem;
if (msgSpacePoolId2nzgPoolId(id,poolId,poolNb) == -1){ if (msgSpacePoolId2nzgPoolId(id,poolId,poolNb) == -1){

View file

@ -4,8 +4,8 @@
/* nzg_list.c */ /* nzg_list.c */
/* msgSpaceListId msgSpaceIdList(void); */ /* msgSpaceListId msgSpaceIdList(void); */
/* nzg_pool.c */ /* nzg_pool.c */
int msgPoolCreate(msgSpacePoolId poolId, int buffNb, int buffSize); int msgPoolCreate(msgPoolId poolId, int buffNb, int buffSize);
int msgSpacePoolId2nzgPoolId(msgSpacePoolId dest, msgSpacePoolId src, int num); int msgSpacePoolId2nzgPoolId(msgPoolId dest, msgPoolId src, int num);
/* nzg_spaces.c */ /* nzg_spaces.c */
msgSpace *msgSpaceCreate(msgSpaceId spaceId, int queueNb, int poolNb, msgPool *queueNbCar); msgSpace *msgSpaceCreate(msgSpaceId spaceId, int queueNb, int poolNb, msgPool *queueNbCar);
msgSpace *msgSpaceOpen(msgSpaceId spaceId); msgSpace *msgSpaceOpen(msgSpaceId spaceId);

View file

@ -28,7 +28,7 @@ msgSpace * msgSpaceCreate(
static int mSIdNum=-1; static int mSIdNum=-1;
msgSpace * mSAddr; msgSpace * mSAddr;
msgSpacePoolId poolDataId; msgPoolId poolDataId;
msgPoolData * mSPoolDataAddr; msgPoolData * mSPoolDataAddr;
fprintf(stderr,"Creating msgSpace with id : %s\n",spaceId); fprintf(stderr,"Creating msgSpace with id : %s\n",spaceId);