diff --git a/include/base.h b/include/base.h index cf3829b..200b67e 100644 --- a/include/base.h +++ b/include/base.h @@ -37,6 +37,10 @@ struct { int *space; } typedef IntArray_t; +// +// Scheduler +// + struct { BoolArray_t *globalPreemptionSpace; IntArray_t *globalDrawingSpace; @@ -45,3 +49,17 @@ struct { int nmaxThread; int nmaxCycles; } typedef SchedulerParams_t; + +// +// Local threads +// +struct { + int x; + int y; + int z; +} typedef Center_t; + +struct { + pthread_t *id; + Center_t *localWorkAreaCenter; +} typedef Thread_t; diff --git a/src/main.c b/src/main.c index a20a721..f9d9f6d 100644 --- a/src/main.c +++ b/src/main.c @@ -35,14 +35,18 @@ int main(int argc, char **argv) // // Creating parameters structure for the Scheduler // - SchedulerParams_t *parameters = NULL; + SchedulerParams_t *parameters = + (SchedulerParams_t*) malloc(sizeof(SchedulerParams_t)); - parameters->globalPreemptionSpace = (BoolArray_t*) malloc(sizeof(BoolArray_t)); - parameters->globalPreemptionSpace->space = (bool*) malloc(sizeof(bool)*SPACE_SIZE); + parameters->globalPreemptionSpace = + (BoolArray_t*) malloc(sizeof(BoolArray_t)); + parameters->globalPreemptionSpace->space = + (bool*) malloc(sizeof(bool)*SPACE_SIZE); parameters->globalPreemptionSpace->size = SPACE_SIZE; parameters->globalDrawingSpace = (IntArray_t*) malloc(sizeof(IntArray_t)); - parameters->globalDrawingSpace->space = (int*) malloc(sizeof(int)*SPACE_SIZE); + parameters->globalDrawingSpace->space = + (int*) malloc(sizeof(int)*SPACE_SIZE); parameters->globalDrawingSpace->size = SPACE_SIZE; parameters->arrowList = (IntArray_t*) malloc(sizeof(IntArray_t)); @@ -70,5 +74,25 @@ int main(int argc, char **argv) free(parameters->arrowList->space); free(parameters->arrowList); + free(parameters); + return 0; } + + +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); +} diff --git a/src/scheduler.c b/src/scheduler.c index 2d0f3a9..c58c21b 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -58,7 +58,7 @@ void SchedWait(pthread_t *schedThread) // -------------------------------------------------------------------------- // static void *GreatScheduler(void *parameters) { - sleep(1); printf("Printing from thread \n"); + sleep(1); return NULL; }