Some types
This commit is contained in:
parent
7829fb1457
commit
e42534dc90
|
@ -37,6 +37,10 @@ struct {
|
||||||
int *space;
|
int *space;
|
||||||
} typedef IntArray_t;
|
} typedef IntArray_t;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Scheduler
|
||||||
|
//
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
BoolArray_t *globalPreemptionSpace;
|
BoolArray_t *globalPreemptionSpace;
|
||||||
IntArray_t *globalDrawingSpace;
|
IntArray_t *globalDrawingSpace;
|
||||||
|
@ -45,3 +49,17 @@ struct {
|
||||||
int nmaxThread;
|
int nmaxThread;
|
||||||
int nmaxCycles;
|
int nmaxCycles;
|
||||||
} typedef SchedulerParams_t;
|
} 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;
|
||||||
|
|
32
src/main.c
32
src/main.c
|
@ -35,14 +35,18 @@ int main(int argc, char **argv)
|
||||||
//
|
//
|
||||||
// Creating parameters structure for the Scheduler
|
// 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 =
|
||||||
parameters->globalPreemptionSpace->space = (bool*) malloc(sizeof(bool)*SPACE_SIZE);
|
(BoolArray_t*) malloc(sizeof(BoolArray_t));
|
||||||
|
parameters->globalPreemptionSpace->space =
|
||||||
|
(bool*) malloc(sizeof(bool)*SPACE_SIZE);
|
||||||
parameters->globalPreemptionSpace->size = SPACE_SIZE;
|
parameters->globalPreemptionSpace->size = SPACE_SIZE;
|
||||||
|
|
||||||
parameters->globalDrawingSpace = (IntArray_t*) malloc(sizeof(IntArray_t));
|
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->globalDrawingSpace->size = SPACE_SIZE;
|
||||||
|
|
||||||
parameters->arrowList = (IntArray_t*) malloc(sizeof(IntArray_t));
|
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->space);
|
||||||
free(parameters->arrowList);
|
free(parameters->arrowList);
|
||||||
|
|
||||||
|
free(parameters);
|
||||||
|
|
||||||
return 0;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ void SchedWait(pthread_t *schedThread)
|
||||||
// -------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------- //
|
||||||
static void *GreatScheduler(void *parameters)
|
static void *GreatScheduler(void *parameters)
|
||||||
{
|
{
|
||||||
sleep(1);
|
|
||||||
printf("Printing from thread \n");
|
printf("Printing from thread \n");
|
||||||
|
sleep(1);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue