Scheduler Crash test
This commit is contained in:
parent
e42534dc90
commit
b21478ca46
|
@ -48,6 +48,7 @@ struct {
|
|||
IntArray_t *arrowList;
|
||||
int nmaxThread;
|
||||
int nmaxCycles;
|
||||
pthread_t *id;
|
||||
} typedef SchedulerParams_t;
|
||||
|
||||
//
|
||||
|
|
41
src/main.c
41
src/main.c
|
@ -29,6 +29,27 @@
|
|||
#define SPACE_SIZE 10000
|
||||
#define MAX_THREAD 0
|
||||
|
||||
void SchedulerCrashTest(void)
|
||||
{
|
||||
const int maxthread = 2000;
|
||||
|
||||
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 < maxthread; i++) {
|
||||
schedThread[i] = SchedInit(parameters);
|
||||
}
|
||||
|
||||
for (int i=0; i < maxthread; i++) {
|
||||
SchedWait(schedThread[i]);
|
||||
SchedDestroy(schedThread[i]);
|
||||
}
|
||||
|
||||
free(parameters);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
@ -76,23 +97,7 @@ int main(int argc, char **argv)
|
|||
|
||||
free(parameters);
|
||||
|
||||
SchedulerCrashTest();
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ static void *GreatScheduler(void *parameters);
|
|||
// -------------------------------------------------------------------------- //
|
||||
pthread_t *SchedInit(SchedulerParams_t *parameters)
|
||||
{
|
||||
pthread_t *schedThread = (pthread_t*) malloc(sizeof(pthread_t));
|
||||
pthread_create(schedThread, NULL, GreatScheduler, parameters);
|
||||
return schedThread;
|
||||
parameters->id = (pthread_t*) malloc(sizeof(pthread_t));
|
||||
pthread_create(parameters->id, NULL, GreatScheduler, parameters);
|
||||
return parameters->id;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
@ -56,9 +56,18 @@ void SchedWait(pthread_t *schedThread)
|
|||
// -------------------------------------------------------------------------- //
|
||||
// Scheduler thread main function //
|
||||
// -------------------------------------------------------------------------- //
|
||||
static void *GreatScheduler(void *parameters)
|
||||
static void *GreatScheduler(void *params)
|
||||
{
|
||||
printf("Printing from thread \n");
|
||||
sleep(1);
|
||||
SchedulerParams_t *parameters = (SchedulerParams_t*) params;
|
||||
int a = 4;
|
||||
|
||||
|
||||
for (int i = 0; i < 45000; i++) {
|
||||
for (int j = i; j < 45000; j++) {
|
||||
a = (a + (long)parameters->id) * i * j;
|
||||
}
|
||||
}
|
||||
|
||||
printf("thread %d\n", a);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue