diff --git a/include/scheduler.h b/include/scheduler.h index 27a43ed..8d3f488 100644 --- a/include/scheduler.h +++ b/include/scheduler.h @@ -26,4 +26,6 @@ pthread_t *SchedInit(BoolArray_t *globalPreemptionSpace, IntArray_t *transitionsTree, IntArray_t *arrowList, int nmaxThread, int nmaxCycles); -int SchedLaunch(pthread_t *schedThread); +int SchedWait(pthread_t *schedThread); + +int SchedDestroy(pthread_t *schedThread); diff --git a/src/main.c b/src/main.c index 79eee01..9f97911 100644 --- a/src/main.c +++ b/src/main.c @@ -61,7 +61,9 @@ int main(int argc, char **argv) pthread_t *schedThread = SchedInit(globalPreemptionSpace, transitionsTree, arrowList, MAX_THREAD, MAX_CYCLES); - int res = SchedLaunch(schedThread); + SchedWait(schedThread); + + SchedDestroy(schedThread); free(globalDrawingSpace->space); free(globalDrawingSpace); @@ -72,5 +74,5 @@ int main(int argc, char **argv) free(arrowList->space); free(arrowList); - return res; + return 0; } diff --git a/src/scheduler.c b/src/scheduler.c index 975047d..f6d4bc8 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -37,12 +37,26 @@ pthread_t *SchedInit(BoolArray_t *globalePreemptionSpace, IntArray_t *transition return schedThread; } -int SchedLaunch(pthread_t *schedThread) +// -------------------------------------------------------------------------- // +// Scheduler destructor function // +// -------------------------------------------------------------------------- // +int SchedDestroy(pthread_t *schedThread) { - pthread_join(*schedThread, NULL); + free(schedThread); return 0; } +// -------------------------------------------------------------------------- // +// Scheduler wait function // +// -------------------------------------------------------------------------- // +void SchedWait(pthread_t *schedThread) +{ + pthread_join(*schedThread, NULL); +} + +// -------------------------------------------------------------------------- // +// Scheduler thread main function // +// -------------------------------------------------------------------------- // static void *GreatScheduler(void *vargp) { sleep(1);