findWorkArea

This commit is contained in:
Jean Sirmai 2021-06-11 17:14:40 +02:00
parent dd45f7794a
commit af433e8a90
Signed by untrusted user who does not match committer: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 10 additions and 7 deletions

View File

@ -23,6 +23,7 @@
#include "../include/localworker.h"
#include <sys/sysinfo.h>
#include <stdlib.h>
static void *GreatScheduler(void *parameters);
@ -98,19 +99,21 @@ static void *GreatScheduler(void *params)
// -------------------------------------------------------------------------- //
// Scheduler thread main function //
// -------------------------------------------------------------------------- //
static Center_t *findWorkArea(Center_t *centerList, long ruleRadius)
static Center_t *findWorkArea(Center_t *centerList, int ruleRadius)
{
Center_t *myCenter = 10; /* Je suis né quelque part.(ou pas !).*/
Center_t *myCenter = (Center_t*) malloc(sizeof(Center_t));
centerAssign(myCenter, 10, 0, 0); /* Je suis né quelque part.(ou pas !).*/
int i;
for (i = 0; i < centerList.size() - 1; i ++){
if (myCenter - centerList[i] < ruleRadius){
printLog("FAIL: no work area available at %p\n", myCenter);
while (centerList != NULL){
if (abs(myCenter->x - centerList->x) < ruleRadius){
printLog("FAIL: no work area available at %d\n", myCenter->x);
free(myCenter);
return NULL;
}
centerList = centerList->next;
}
printLog("SUCCESS ! at %p: < I've find a center.\n", myCenter);
printLog("SUCCESS ! at %d: < I've find a center.\n", myCenter->x);
return myCenter;
}