57 lines
1.1 KiB
C
57 lines
1.1 KiB
C
#include <wait.h>
|
|
#include "libnazgul.h"
|
|
|
|
int main(void) {
|
|
// msgSpace mS=0;
|
|
|
|
msgSpaceId testId;
|
|
msgSpace * mSPAC;
|
|
msgPool poolInfos[3];
|
|
char * montext;
|
|
|
|
poolInfos[0].bufferNb=4;
|
|
poolInfos[0].bufferSize=200;
|
|
|
|
poolInfos[1].bufferNb=5;
|
|
poolInfos[1].bufferSize=250;
|
|
|
|
poolInfos[2].bufferNb=5;
|
|
poolInfos[2].bufferSize=280;
|
|
|
|
sprintf(testId,"test%d",(int)getuid());
|
|
printf("RequestedId: %s\n",testId);
|
|
|
|
mSPAC=msgSpaceCreate(testId,0,3,poolInfos);
|
|
|
|
pid_t pid=fork();
|
|
|
|
|
|
|
|
if (pid ==0){
|
|
mSPAC=msgSpaceOpen(testId);
|
|
sleep(2);
|
|
montext=msgAllocate(mSPAC,2,180,0);
|
|
sleep(2);
|
|
montext=msgAllocate(mSPAC,2,170,0);
|
|
sleep(2);
|
|
montext=msgAllocate(mSPAC,2,270,0);
|
|
|
|
} else {
|
|
mSPAC=msgSpaceOpen(testId);
|
|
montext=msgAllocate(mSPAC,2,280,0);
|
|
*montext=42;
|
|
printf("### test Valeur0 %d ###\n",(int)*montext);
|
|
sleep(2);
|
|
montext=msgAllocate(mSPAC,2,270,0);
|
|
*montext=17;
|
|
printf("### test Valeur1 %d ###\n",(int)*montext);
|
|
sleep(2);
|
|
montext=msgAllocate(mSPAC,2,270,0);
|
|
msgFree(mSPAC,(void *)montext);
|
|
//msgFree(mSPAC,(void *)montext);
|
|
//msgFree(mSPAC,(void *)montext);
|
|
wait(NULL);
|
|
msgSpaceDelete(testId);
|
|
}
|
|
return 0;
|
|
}
|