Add pool allocate (squash)

This commit is contained in:
Glenn Y. Rolland 2019-09-17 14:16:29 +02:00
parent 37b871297f
commit 665cb90dd6
2 changed files with 25 additions and 2 deletions

View file

@ -32,7 +32,7 @@ typedef struct MsgSpace {
msgSpaceId id; msgSpaceId id;
int poolNb; int poolNb;
int queueNb; int queueNb;
int pid; int pid;
msgSpacePoolDataId poolDataId; msgSpacePoolDataId poolDataId;
} msgSpace; } msgSpace;
@ -42,7 +42,7 @@ typedef struct MsgSpace {
typedef struct MsgSpaceListElem { typedef struct MsgSpaceListElem {
void * id; void * id;
int ownerPid; int ownerPid;
msgSpaceListElemId next; msgSpaceListElemId next;
} * msgSpaceList, msgSpaceListElem; } * msgSpaceList, msgSpaceListElem;

View file

@ -55,3 +55,26 @@ int msgSpacePoolId2nzgPoolId(msgSpacePoolId dest,msgSpacePoolId src, int num){
// //donne l'adr en mappant in the memory // //donne l'adr en mappant in the memory
//poolAddr = mmap(NULL, sizeof(*msgPool), PROT_NONE, MAP_SHARED, poolFd, 0); //poolAddr = mmap(NULL, sizeof(*msgPool), PROT_NONE, MAP_SHARED, poolFd, 0);
msgPool * msgPoolAllocate(int poolFd, msgSpace *msg) {
msgPool * poolAddr;
int dataId;
//msgSpacePoolData spoolData;
//dataId = msg->poolDataId;
//spoolData[dataId];
//donne l'adr en mappant in the memory
poolAddr = mmap(NULL, sizeof(*msgPool), PROT_NONE, MAP_SHARED, poolFd, 0);
if(poolAddr == MAP_FAILED) {
fprintf( stderr, "mmap failed: %s\n",
strerror( errno ) );
return NULL;
}
// on renvoie le pointeur sur le bon pool
return poolAddr;
}