*** empty log message ***

This commit is contained in:
glenux 2004-02-23 11:02:15 +00:00 committed by Glenn Y. Rolland
parent 6d2950ac6b
commit 8ee07b027e
3 changed files with 28 additions and 13 deletions

View file

@ -22,9 +22,9 @@ void * msgAllocate(msgSpace *space,
float semPoolCoef[space->poolNb];
int idxPoolOptimum;
bool gotRessourceSem;
sem_t * poolDataTabSemFd=NULL;
sem_t * poolDataTabSemFd;
msgPoolDataTabSemId ressourceSemId;
sem_t * ressourceSemFd=NULL;
sem_t * ressourceSemFd;
int ressourceSemVal;
float minPoolCoef;
int selectedPoolIndex;
@ -32,6 +32,15 @@ void * msgAllocate(msgSpace *space,
selectedPoolIndex=-1;
poolDataTabSemFd=sem_open(space->poolDataTabSemId,O_CREAT,SEM_DEFAULT_MODE,1);
if (poolDataTabSemFd == SEM_FAILED){
NZG_ERROR("sem_open : ouverture de la ressource",
space->poolDataTabSemId);
return NULL;
}
sem_wait(poolDataTabSemFd);
/* TODO: verifier le premier arg du shm_open */
mSPoolDataTabFd=shm_open(space->poolDataTabId,
O_RDWR,
@ -67,9 +76,9 @@ void * msgAllocate(msgSpace *space,
fprintf(stderr,"[ ALLOCATION ANYPOOL : %d ]\n",(int)getpid());
// choisir le pool au hasard (ou presque)
for(i=0; i<(space->poolNb); i++) {
printf("ERRORDETECT boucle %d\n",i); fflush(stdout);
printf("- boucle %d\n",i); fflush(stdout);
if(mSPoolDataTabAddr[i].bufferSize >= taille) {
printf("ERRORDETECT buffS > taill %d\n",i); fflush(stdout);
printf("( buffSize > taille )\n"); fflush(stdout);
/* choisir le numero du semaphore
en fonction du nombre de lock poses / nombre de buffer */
msgPoolSemIdIntern(ressourceSemId,space->id,i);
@ -138,7 +147,6 @@ void * msgAllocate(msgSpace *space,
}
if (!gotRessourceSem){
strcpy(resultPoolId,mSPoolDataTabAddr[selectedPoolIndex].id);
msgPoolSemIdIntern(ressourceSemId,space->id,selectedPoolIndex);
ressourceSemFd=sem_open(ressourceSemId,O_CREAT,SEM_DEFAULT_MODE,0);
if(ressourceSemFd==SEM_FAILED){
@ -160,9 +168,6 @@ void * msgAllocate(msgSpace *space,
/* on a acqui un semaphore pour la ressouce */
/* on acquiert le droit de modifier les infos sur la ressource */
poolDataTabSemFd=sem_open(space->poolDataTabSemId,O_CREAT,SEM_DEFAULT_MODE,1);
printf("VOILAAA : %s\n",space->poolDataTabSemId);
//sem_wait(poolDataTabSemFd);
/* on modifie maintenant les données */
@ -174,13 +179,23 @@ void * msgAllocate(msgSpace *space,
return NULL;
}
printf("Buffer selected : %d,%d\n",selectedPoolIndex,bufferFreeIndex);
/*TODO: mapper le buffer libre dans l'esp addr du proc */
/* mapper le buffer libre dans l'esp addr du proc */
strcpy(resultPoolId,mSPoolDataTabAddr[selectedPoolIndex].poolId);
int mSPoolFd=shm_open(resultPoolId,O_RDWR,MSGSPACE_DEFAULT_MODE);
resultAddr = mmap( 0,
mSPoolDataTabAddr[selectedPoolIndex].bufferSize,
PROT_READ | PROT_WRITE,
MAP_SHARED, mSPoolFd, 0 );
//TODO:
/* - on s'enregistre aupres de ce buffer */
//TODO: msgBufferAttachProc(space,selectedPoolIndex,resultAddr);
//msgBufferAttachProc(mSPoolDataTabFd,selectedPoolIndex,resultAddr);
// sem_post(poolDataTabSemFd);
sem_post(poolDataTabSemFd);
sem_close(poolDataTabSemFd);
/* TODO: unmapper le msgPoolDataTab */

View file

@ -35,7 +35,7 @@ typedef struct MsgBufferInfo {
} msgBufferInfo;
typedef struct MsgPoolData {
msgPoolId id;
msgPoolId poolId;
msgBufferInfoTabId bufferInfoTabId;
int bufferNb;
int bufferSize;

View file

@ -151,7 +151,7 @@ msgSpace * msgSpaceCreate(
(char*)poolId );
return NULL;
}
strcpy(mSPoolDataAddr[i].id,poolId);
strcpy(mSPoolDataAddr[i].poolId,poolId);
msgPoolCreate(externId,i,poolInfos[i].bufferNb,poolInfos[i].bufferSize);
}