gem-graph-server/src/main.c

100 lines
3.6 KiB
C
Raw Normal View History

2021-06-09 11:35:47 +02:00
//=-------------------------------------------------------------------------=//
// Main //
// //
// 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/>. //
//=-------------------------------------------------------------------------=//
2021-06-09 14:40:23 +02:00
#include "../include/base.h"
2021-06-09 11:54:58 +02:00
#include "../include/server.h"
#include "../include/scheduler.h"
2021-06-09 11:35:47 +02:00
#define ARROW_NUMBER 150
2021-06-16 00:09:35 +02:00
#define MAX_CYCLES 15
2021-06-09 11:35:47 +02:00
#define MAX_THREAD 0
2021-06-16 13:06:23 +02:00
#define XMAX 1000
#define YMAX 1000
#define ZMAX 0
#define SPACE_SIZE (XMAX+1) * (YMAX+1) * (ZMAX+1)
2021-06-09 11:35:47 +02:00
int main(int argc, char **argv)
{
2021-06-14 18:33:13 +02:00
time_t t;
Scheduler_t *scheduler0;
// Go!
2021-06-11 15:11:06 +02:00
printLog("Starting gem-graph-server...\n");
2021-06-14 18:33:13 +02:00
//
// random generator
//
t = time(&t);
2021-06-11 17:39:34 +02:00
srand((unsigned) t);
//
2021-06-14 18:33:13 +02:00
// Creating structure for the Scheduler
//
2021-06-15 23:26:27 +02:00
scheduler0 = (Scheduler_t*) calloc(1, sizeof(Scheduler_t));
2021-06-09 11:35:47 +02:00
2021-06-16 12:01:29 +02:00
scheduler0->globalDrawingSpace =
2021-06-16 12:42:19 +02:00
(Space_t*) calloc(1, sizeof(Space_t));
2021-06-14 18:33:13 +02:00
scheduler0->globalDrawingSpace->space =
2021-06-16 12:42:19 +02:00
(SpaceUnit_t*) calloc(SPACE_SIZE, sizeof(SpaceUnit_t));
2021-06-14 18:33:13 +02:00
scheduler0->globalDrawingSpace->size = SPACE_SIZE;
2021-06-16 13:06:23 +02:00
scheduler0->globalDrawingSpace->xmax = SPACE_SIZE;
scheduler0->globalDrawingSpace->ymax = SPACE_SIZE;
scheduler0->globalDrawingSpace->zmax = SPACE_SIZE;
2021-06-09 11:35:47 +02:00
2021-06-15 23:26:27 +02:00
scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t));
2021-06-16 12:42:19 +02:00
scheduler0->arrowList->array =
2021-06-16 12:01:29 +02:00
(Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t));
2021-06-14 18:33:13 +02:00
scheduler0->arrowList->size = ARROW_NUMBER;
2021-06-09 11:35:47 +02:00
2021-06-16 00:09:35 +02:00
printLog("Populating a random arrow list...\n");
for (int i = 0; i < ARROW_NUMBER; i++) {
2021-06-16 13:06:23 +02:00
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);
2021-06-16 00:09:35 +02:00
}
2021-06-14 18:33:13 +02:00
scheduler0->nmaxThread = MAX_THREAD;
scheduler0->nmaxCycles = MAX_CYCLES;
2021-06-09 12:16:27 +02:00
2021-06-09 14:40:23 +02:00
//
// Creating the Scheduler thread
2021-06-09 14:40:23 +02:00
//
2021-06-14 18:33:13 +02:00
SchedInit(scheduler0);
2021-06-09 23:56:42 +02:00
SchedWait(scheduler0);
2021-06-09 14:40:23 +02:00
SchedDestroy(scheduler0);
2021-06-09 14:40:23 +02:00
2021-06-14 18:33:13 +02:00
free(scheduler0);
2021-06-11 12:23:16 +02:00
2021-06-11 12:52:36 +02:00
return 0;
2021-06-11 12:23:16 +02:00
}