A real init/destroy
This commit is contained in:
parent
10ab0d01cd
commit
0d796ff599
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue