A real init/destroy

This commit is contained in:
Adrien Bourmault 2021-06-09 23:56:42 +02:00
parent 10ab0d01cd
commit 0d796ff599
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
3 changed files with 23 additions and 5 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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);