*fonction msgListLock

This commit is contained in:
rivka_zan 2004-02-22 18:43:20 +00:00 committed by Glenn Y. Rolland
parent 6e55ca4e6d
commit 6272f135ed

View file

@ -29,39 +29,86 @@ int msgSpaceListElemLinkNext(msgSpaceListElemId current,msgSpaceListElemId next)
int msgSpaceListAdd(msgSpaceListElemId ); int msgSpaceListAdd(msgSpaceListElemId );
int msgSpaceListRem(msgSpaceListElemId spaceId); int msgSpaceListRem(msgSpaceListElemId spaceId);
char *spaceList;
void *add(char * idAncien, char *idNouveau); int msgSpaceListLock(){
int descMemory; char *spaceList;
/*Pose d'un semafore*/
sem_t * sem;
void * add(char * idAncien, char *idNouveau){ if((int)sem=sem_open(spaceList,O_CREAT|O_EXCL, 0666,10) ==-1){
descMemory=shm_open("/titi", printf("erreur de semaphore");
O_RDWR|O_CREAT|O_EXCL|O_TRUNC, return -1;
0600);
if (descMemory== -1){
printf("erreur de sh_open\n");
return NULL;
};
if (ftruncate(descMemory,1024)== -1 ){
printf("erreur ftruncate");
} }
/* memory= mmap(0, 1024,
PROT_READ | PROT_WRITE,
if(sem_wait(sem)==-1){
MAP_SHARED, mSFd, 0)*/ printf("erreur pour l'ajout d'un semaphore");
return -1;
/* if( Strcpy(idAncien, idNouveau) ==-1){ }
printf("erreur de strcpy"); return 0;
};*/
strcpy(idAncien, idNouveau);
return NULL;
} }
/*int msgSpaceListUnlock(){
Ferme le semaphore
int semClose;
if(semClose=sem_close(spaceList) )==-1{
printf("erreur");
return -1;
}
return 0;
};
*/
/*void *add(char * idAncien, char *idNouveau);
int descMemory;
void * add(char * idAncien, char *idNouveau){
descMemory=shm_open("/titi",
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
0600);
if (descMemory== -1){
printf("erreur de sh_open\n");
return NULL;
};
if (ftruncate(descMemory,1024)== -1 ){
printf("erreur ftruncate");
}
memory= mmap(0, 1024,
PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0)*/
/*typedef struct MsgSpaceListElem {
void * id;
int ownerPid;
msgSpaceListElemId next;
} * msgSpaceList, msgSpaceListElem;
msgSpaceListElemId *mslist;
if( Strcpy(idAncien, idNouveau) ==-1){
printf("erreur de strcpy");
};
strcpy(idAncien, idNouveau);
return NULL;
}
*/