//=-------------------------------------------------------------------------=// // 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 . // //=-------------------------------------------------------------------------=// #include "../include/base.h" #include "../include/server.h" #include "../include/scheduler.h" #define ARROW_NUMBER 150 #define MAX_CYCLES 40000 #define SPACE_SIZE 10000 #define MAX_THREAD 0 void SchedulerCrashTest(void) { const int maxthread = 16; Scheduler_t *scheduler0 = (Scheduler_t*) calloc(1, sizeof(Scheduler_t)); pthread_t **schedThread = (pthread_t**) malloc(sizeof(pthread_t*) * maxthread); for (int i=0; i < maxthread; i++) { schedThread[i] = SchedInit(scheduler0); } for (int i=0; i < maxthread; i++) { SchedWait(schedThread[i]); SchedDestroy(schedThread[i]); } free(scheduler0); } int main(int argc, char **argv) { time_t t; Scheduler_t *scheduler0; // Go! printLog("Starting gem-graph-server...\n"); // // random generator // t = time(&t); srand((unsigned) t); // // Creating structure for the Scheduler // scheduler0 = (Scheduler_t*) malloc(sizeof(Scheduler_t)); scheduler0->globalPreemptionSpace = (BoolArray_t*) malloc(sizeof(BoolArray_t)); scheduler0->globalPreemptionSpace->space = (bool*) malloc(sizeof(bool)*SPACE_SIZE); scheduler0->globalPreemptionSpace->size = SPACE_SIZE; scheduler0->globalDrawingSpace = (IntArray_t*) malloc(sizeof(IntArray_t)); scheduler0->globalDrawingSpace->space = (int*) malloc(sizeof(int)*SPACE_SIZE); scheduler0->globalDrawingSpace->size = SPACE_SIZE; scheduler0->arrowList = (IntArray_t*) malloc(sizeof(IntArray_t)); scheduler0->arrowList->space = (int*) malloc(sizeof(int)*ARROW_NUMBER); scheduler0->arrowList->size = ARROW_NUMBER; scheduler0->nmaxThread = MAX_THREAD; scheduler0->nmaxCycles = MAX_CYCLES; // // Creating the Scheduler thread // SchedInit(scheduler0); SchedWait(scheduler0->id); SchedDestroy(scheduler0->id); free(scheduler0->globalDrawingSpace->space); free(scheduler0->globalDrawingSpace); free(scheduler0->globalPreemptionSpace->space); free(scheduler0->globalPreemptionSpace); free(scheduler0->arrowList->space); free(scheduler0->arrowList); free(scheduler0); return 0; }