Some quotes & renaming
This commit is contained in:
parent
4f54f3030b
commit
ab64d8f557
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "../include/base.h"
|
#include "../include/base.h"
|
||||||
|
|
||||||
static void *LittleWorker(void *worker);
|
static void *workerMain(void *worker);
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -31,8 +31,9 @@ static void *LittleWorker(void *worker);
|
||||||
pthread_t *WorkerInit(Worker_t *worker)
|
pthread_t *WorkerInit(Worker_t *worker)
|
||||||
{
|
{
|
||||||
worker->id = (pthread_t*) malloc(sizeof(pthread_t));
|
worker->id = (pthread_t*) malloc(sizeof(pthread_t));
|
||||||
if (pthread_create(worker->id, NULL, LittleWorker, worker)) {
|
if (pthread_create(worker->id, NULL, workerMain, worker)) {
|
||||||
printLog("Worker #%lu can't be initialized!\n", *(worker->id));
|
printLog("Worker #%lu can't be initialized!\n", *(worker->id));
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return worker->id;
|
return worker->id;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +41,7 @@ pthread_t *WorkerInit(Worker_t *worker)
|
||||||
// -------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------- //
|
||||||
// Scheduler thread main function //
|
// Scheduler thread main function //
|
||||||
// -------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------- //
|
||||||
static void *LittleWorker(void *worker)
|
static void *workerMain(void *worker)
|
||||||
{
|
{
|
||||||
Worker_t *args;
|
Worker_t *args;
|
||||||
int a = rand()%__INT_MAX__;
|
int a = rand()%__INT_MAX__;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
|
|
||||||
static void *GreatScheduler(void *parameters);
|
static void *schedulerMain(void *parameters);
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ static void *GreatScheduler(void *parameters);
|
||||||
pthread_t *SchedInit(Scheduler_t *scheduler)
|
pthread_t *SchedInit(Scheduler_t *scheduler)
|
||||||
{
|
{
|
||||||
scheduler->id = (pthread_t*) malloc(sizeof(pthread_t));
|
scheduler->id = (pthread_t*) malloc(sizeof(pthread_t));
|
||||||
pthread_create(scheduler->id, NULL, GreatScheduler, scheduler);
|
pthread_create(scheduler->id, NULL, schedulerMain, scheduler);
|
||||||
return scheduler->id;
|
return scheduler->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ static Center_t *findWorkArea(Center_t *centersList, Arrow_t *electedArrow,
|
||||||
newCenter = (Center_t*) malloc(sizeof(Center_t));
|
newCenter = (Center_t*) malloc(sizeof(Center_t));
|
||||||
|
|
||||||
while (currentCenter){
|
while (currentCenter){
|
||||||
//printLog("Center : %d\n", currentCenter->x);
|
|
||||||
if ( abs(electedArrow->x - currentCenter->x) <= ruleRadius
|
if ( abs(electedArrow->x - currentCenter->x) <= ruleRadius
|
||||||
|| abs(electedArrow->y - currentCenter->y) <= ruleRadius
|
|| abs(electedArrow->y - currentCenter->y) <= ruleRadius
|
||||||
|| abs(electedArrow->z - currentCenter->z) <= ruleRadius
|
|| abs(electedArrow->z - currentCenter->z) <= ruleRadius
|
||||||
|
@ -75,25 +74,29 @@ static Center_t *findWorkArea(Center_t *centersList, Arrow_t *electedArrow,
|
||||||
// -------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------- //
|
||||||
// Scheduler thread main function //
|
// Scheduler thread main function //
|
||||||
// -------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------- //
|
||||||
static void *GreatScheduler(void *scheduler)
|
static void *schedulerMain(void *scheduler)
|
||||||
{
|
{
|
||||||
Scheduler_t *args;
|
Scheduler_t *args;
|
||||||
Worker_t *workerArray;
|
Worker_t *workerArray;
|
||||||
|
// A center is a structure that defines, with a radius, a cubic preempted
|
||||||
|
// area for a worker to operate on (as an approximation of a spheric one)
|
||||||
Center_t *centersList, *workArea;
|
Center_t *centersList, *workArea;
|
||||||
Arrow_t *electedArrow;
|
Arrow_t *electedArrow;
|
||||||
int nPartialCycles; // 1 cycle = thread * partial cycle
|
// A cycle is defined as the total renew of all allocated workers.
|
||||||
|
// 1 cycle = thread * partial cycle.
|
||||||
|
int nPartialCycles;
|
||||||
int ncpu, nworker;
|
int ncpu, nworker;
|
||||||
|
|
||||||
// Getting scheduler argument structure
|
// Getting scheduler argument structure
|
||||||
args = (Scheduler_t*) scheduler;
|
args = (Scheduler_t*) scheduler;
|
||||||
printLog("Scheduler #%lu online\n", *args->id);
|
printLog("Scheduler #%lu online\n", *args->id);
|
||||||
|
|
||||||
if (!args->nmaxThread) {
|
if (!args->nmaxThread) { // nmaxthread = 0 => no minimum
|
||||||
ncpu = get_nprocs();
|
ncpu = get_nprocs(); // allocating all the cpus available
|
||||||
} else {
|
} else { // n thread = min(cpu, nmaxthread)
|
||||||
ncpu = MIN(get_nprocs(), args->nmaxThread);
|
ncpu = MIN(get_nprocs(), args->nmaxThread);
|
||||||
}
|
}
|
||||||
printLog("%d CPUs available.\n", ncpu);
|
printLog("%d threads available.\n", ncpu);
|
||||||
|
|
||||||
// Data structures
|
// Data structures
|
||||||
workerArray = (Worker_t*) calloc(ncpu, sizeof(Worker_t));
|
workerArray = (Worker_t*) calloc(ncpu, sizeof(Worker_t));
|
||||||
|
|
Loading…
Reference in New Issue