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
|
|
|
|
#define MAX_CYCLES 40000
|
|
|
|
#define SPACE_SIZE 10000
|
|
|
|
#define MAX_THREAD 0
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2021-06-11 11:39:42 +02:00
|
|
|
//
|
|
|
|
// Creating parameters structure for the Scheduler
|
|
|
|
//
|
2021-06-11 12:23:16 +02:00
|
|
|
SchedulerParams_t *parameters =
|
|
|
|
(SchedulerParams_t*) malloc(sizeof(SchedulerParams_t));
|
2021-06-09 11:35:47 +02:00
|
|
|
|
2021-06-11 12:23:16 +02:00
|
|
|
parameters->globalPreemptionSpace =
|
|
|
|
(BoolArray_t*) malloc(sizeof(BoolArray_t));
|
|
|
|
parameters->globalPreemptionSpace->space =
|
|
|
|
(bool*) malloc(sizeof(bool)*SPACE_SIZE);
|
2021-06-11 11:39:42 +02:00
|
|
|
parameters->globalPreemptionSpace->size = SPACE_SIZE;
|
2021-06-09 11:35:47 +02:00
|
|
|
|
2021-06-11 11:39:42 +02:00
|
|
|
parameters->globalDrawingSpace = (IntArray_t*) malloc(sizeof(IntArray_t));
|
2021-06-11 12:23:16 +02:00
|
|
|
parameters->globalDrawingSpace->space =
|
|
|
|
(int*) malloc(sizeof(int)*SPACE_SIZE);
|
2021-06-11 11:39:42 +02:00
|
|
|
parameters->globalDrawingSpace->size = SPACE_SIZE;
|
2021-06-09 11:35:47 +02:00
|
|
|
|
2021-06-11 11:39:42 +02:00
|
|
|
parameters->arrowList = (IntArray_t*) malloc(sizeof(IntArray_t));
|
|
|
|
parameters->arrowList->space = (int*) malloc(sizeof(int)*ARROW_NUMBER);
|
|
|
|
parameters->arrowList->size = ARROW_NUMBER;
|
2021-06-09 11:35:47 +02:00
|
|
|
|
2021-06-11 11:39:42 +02:00
|
|
|
parameters->nmaxThread = MAX_THREAD;
|
|
|
|
parameters->nmaxCycles = MAX_CYCLES;
|
2021-06-09 12:16:27 +02:00
|
|
|
|
2021-06-09 14:40:23 +02:00
|
|
|
//
|
2021-06-11 11:39:42 +02:00
|
|
|
// Creating the Scheduler thread
|
2021-06-09 14:40:23 +02:00
|
|
|
//
|
2021-06-11 11:39:42 +02:00
|
|
|
pthread_t *schedThread = SchedInit(parameters);
|
2021-06-09 14:40:23 +02:00
|
|
|
|
2021-06-09 23:56:42 +02:00
|
|
|
SchedWait(schedThread);
|
|
|
|
|
|
|
|
SchedDestroy(schedThread);
|
2021-06-09 14:40:23 +02:00
|
|
|
|
2021-06-11 11:39:42 +02:00
|
|
|
free(parameters->globalDrawingSpace->space);
|
|
|
|
free(parameters->globalDrawingSpace);
|
2021-06-09 14:40:23 +02:00
|
|
|
|
2021-06-11 11:39:42 +02:00
|
|
|
free(parameters->globalPreemptionSpace->space);
|
|
|
|
free(parameters->globalPreemptionSpace);
|
2021-06-09 14:40:23 +02:00
|
|
|
|
2021-06-11 11:39:42 +02:00
|
|
|
free(parameters->arrowList->space);
|
|
|
|
free(parameters->arrowList);
|
2021-06-09 12:23:42 +02:00
|
|
|
|
2021-06-11 12:23:16 +02:00
|
|
|
free(parameters);
|
|
|
|
|
2021-06-09 23:56:42 +02:00
|
|
|
return 0;
|
2021-06-09 11:35:47 +02:00
|
|
|
}
|
2021-06-11 12:23:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
void SchedulerCrashTest(void)
|
|
|
|
{
|
|
|
|
const int maxthread = 100;
|
|
|
|
|
|
|
|
SchedulerParams_t *parameters =
|
|
|
|
(SchedulerParams_t*) calloc(1, sizeof(SchedulerParams_t));
|
|
|
|
|
|
|
|
pthread_t **schedThread =
|
|
|
|
(pthread_t**) malloc(sizeof(pthread_t*) * maxthread);
|
|
|
|
|
|
|
|
for (int i=0; i < 16; i++) {
|
|
|
|
schedThread[i] = SchedInit(parameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(parameters);
|
|
|
|
}
|