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