*** empty log message ***
This commit is contained in:
parent
5486c1c180
commit
1580be12cd
3 changed files with 13 additions and 8 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
*/
|
||||
|
||||
/* TODO: prevoir le cas des négatifs dans la taille ... */
|
||||
|
||||
void * msgAllocate(msgSpace *space,
|
||||
int pool,
|
||||
|
@ -24,7 +25,7 @@ void * msgAllocate(msgSpace *space,
|
|||
sem_t * poolDataTabSemFd=NULL;
|
||||
msgPoolDataTabSemId ressourceSemId;
|
||||
sem_t * ressourceSemFd=NULL;
|
||||
int * ressourceSemVal=NULL;
|
||||
int ressourceSemVal;
|
||||
float minPoolCoef;
|
||||
int selectedPoolIndex;
|
||||
int bufferFreeIndex;
|
||||
|
@ -63,9 +64,12 @@ void * msgAllocate(msgSpace *space,
|
|||
|
||||
int nbLockedSem=0;
|
||||
if ( pool == ANYPOOL){
|
||||
fprintf(stderr,">>>> ANYPOOL selection <<<<\n");
|
||||
// choisir le pool au hasard (ou presque)
|
||||
for(i=0; i<(space->poolNb); i++) {
|
||||
printf("ERRORDETECT boucle %d\n",i); fflush(stdout);
|
||||
if(mSPoolDataTabAddr[i].bufferSize >= taille) {
|
||||
printf("ERRORDETECT buffS > taill %d\n",i); fflush(stdout);
|
||||
/* choisir le numero du semaphore
|
||||
en fonction du nombre de lock poses / nombre de buffer */
|
||||
msgPoolSemIdIntern(ressourceSemId,space->id,i);
|
||||
|
@ -76,18 +80,18 @@ void * msgAllocate(msgSpace *space,
|
|||
}
|
||||
/* on remplit le tableau avec les valeurs des semaphores */
|
||||
|
||||
if (sem_getvalue(ressourceSemFd, ressourceSemVal) < 0){
|
||||
if (sem_getvalue(ressourceSemFd, &ressourceSemVal) < 0){
|
||||
NZG_ERROR("sem_getvalue",ressourceSemId);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((*ressourceSemVal) < 0){
|
||||
if ((ressourceSemVal) < 0){
|
||||
/* il y a ressourceSemVal processus qui attendent déja... */
|
||||
semPoolCoef[nbLockedSem] =
|
||||
(float) (- (*ressourceSemVal) / mSPoolDataTabAddr[i].bufferNb);
|
||||
(float) (- (ressourceSemVal) / mSPoolDataTabAddr[i].bufferNb);
|
||||
nbLockedSem++;
|
||||
}
|
||||
if(sem_trywait(ressourceSemFd)) {
|
||||
if(sem_trywait(ressourceSemFd)==0) {
|
||||
/* choisir la 1ere pool de taille plus grande
|
||||
* libre si possible */
|
||||
gotRessourceSem=true;
|
||||
|
@ -101,6 +105,8 @@ void * msgAllocate(msgSpace *space,
|
|||
} // if buffSize > taille
|
||||
} // for
|
||||
|
||||
printf("ERRORDETECT\n"); fflush(stdout);
|
||||
|
||||
if (!gotRessourceSem) {
|
||||
minPoolCoef= semPoolCoef[0];
|
||||
idxPoolOptimum = 0;
|
||||
|
|
|
@ -20,7 +20,6 @@ int bufferInfoNb;
|
|||
bufferInfoNb=poolDataTabAddr[poolIndex].bufferNb;
|
||||
bufferInfoTabAddr=mmap(NULL,bufferInfoNb*sizeof(msgBufferInfo),
|
||||
PROT_WRITE|PROT_READ,MAP_SHARED,bufferInfoTabFd,(off_t)0);
|
||||
printf("fd ?\n"); fflush(stdout);
|
||||
|
||||
int i;
|
||||
for (i=0;i<bufferInfoNb;i++){
|
||||
|
|
|
@ -15,14 +15,14 @@ int main(void) {
|
|||
poolInfos[1].bufferSize=250;
|
||||
|
||||
poolInfos[2].bufferNb=3;
|
||||
poolInfos[2].bufferSize=250;
|
||||
poolInfos[2].bufferSize=280;
|
||||
|
||||
strcpy(testId,"test");
|
||||
printf("RequestedId: %s\n",testId);
|
||||
|
||||
mSPAC=msgSpaceCreate(testId,0,3,poolInfos);
|
||||
|
||||
montext=msgAllocate(mSPAC,2,180,0);
|
||||
montext=msgAllocate(mSPAC,ANYPOOL,-300,0);
|
||||
// msgFree(mSPAC,(void *)montext);
|
||||
msgSpaceDelete(testId);
|
||||
|
||||
|
|
Loading…
Reference in a new issue