Test
This commit is contained in:
parent
ca1e959861
commit
093c3cc0ea
|
@ -0,0 +1,37 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Server supported commands definition //
|
||||
// //
|
||||
// Copyright © 2021 The Gem-graph Project //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero General Public License as //
|
||||
// published by the Free Software Foundation, either version 3 of the //
|
||||
// License, or (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#ifndef BASE_H
|
||||
#include "../include/base.h"
|
||||
#endif
|
||||
|
||||
void *loadServer(void*);
|
||||
|
||||
struct {
|
||||
const char *name;
|
||||
void* (*execute)(void*);
|
||||
const char *help;
|
||||
} typedef Command_t;
|
||||
|
||||
Command_t cmdList[] =
|
||||
{
|
||||
{"launch scheduler", loadServer, "Launches a scheduler instance"},
|
||||
};
|
|
@ -0,0 +1,84 @@
|
|||
//=-------------------------------------------------------------------------=//
|
||||
// Server management module //
|
||||
// //
|
||||
// Copyright © 2021 The Gem-graph Project //
|
||||
// //
|
||||
// This file is part of gem-graph. //
|
||||
// //
|
||||
// This program is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Affero General Public License as //
|
||||
// published by the Free Software Foundation, either version 3 of the //
|
||||
// License, or (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU Affero General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU Affero General Public License //
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//=-------------------------------------------------------------------------=//
|
||||
|
||||
#include "../include/base.h"
|
||||
#include "../include/scheduler.h"
|
||||
|
||||
#define ARROW_NUMBER 150
|
||||
#define MAX_CYCLES 15
|
||||
#define MAX_THREAD 0
|
||||
#define XMAX 1000
|
||||
#define YMAX 1000
|
||||
#define ZMAX 0
|
||||
#define SPACE_SIZE (XMAX+1) * (YMAX+1) * (ZMAX+1)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void *loadServer(void *args)
|
||||
{
|
||||
Scheduler_t *scheduler0;
|
||||
|
||||
//
|
||||
// Creating structure for the Scheduler
|
||||
//
|
||||
scheduler0 = (Scheduler_t*) calloc(1, sizeof(Scheduler_t));
|
||||
|
||||
scheduler0->globalDrawingSpace =
|
||||
(Space_t*) calloc(1, sizeof(Space_t));
|
||||
scheduler0->globalDrawingSpace->space =
|
||||
(SpaceUnit_t*) calloc(SPACE_SIZE, sizeof(SpaceUnit_t));
|
||||
scheduler0->globalDrawingSpace->size = SPACE_SIZE;
|
||||
scheduler0->globalDrawingSpace->xmax = SPACE_SIZE;
|
||||
scheduler0->globalDrawingSpace->ymax = SPACE_SIZE;
|
||||
scheduler0->globalDrawingSpace->zmax = SPACE_SIZE;
|
||||
|
||||
scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t));
|
||||
scheduler0->arrowList->array =
|
||||
(Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t));
|
||||
scheduler0->arrowList->size = ARROW_NUMBER;
|
||||
|
||||
printLog("Populating a random arrow list...\n");
|
||||
|
||||
for (int i = 0; i < ARROW_NUMBER; i++) {
|
||||
|
||||
if (scheduler0->globalDrawingSpace->xmax)
|
||||
scheduler0->arrowList->array[i].x =
|
||||
rand() % (scheduler0->globalDrawingSpace->xmax + 1);
|
||||
|
||||
if (scheduler0->globalDrawingSpace->ymax)
|
||||
scheduler0->arrowList->array[i].y =
|
||||
rand() % (scheduler0->globalDrawingSpace->ymax + 1);
|
||||
|
||||
if (scheduler0->globalDrawingSpace->zmax)
|
||||
scheduler0->arrowList->array[i].z =
|
||||
rand() % (scheduler0->globalDrawingSpace->zmax + 1);
|
||||
}
|
||||
|
||||
scheduler0->nmaxThread = MAX_THREAD;
|
||||
scheduler0->nmaxCycles = MAX_CYCLES;
|
||||
|
||||
//
|
||||
// Creating the Scheduler thread
|
||||
//
|
||||
SchedInit(scheduler0);
|
||||
|
||||
return scheduler0;
|
||||
}
|
Loading…
Reference in New Issue