Merge branch 'master' of ssh://gitlab.os-k.eu:222/gem-graph-team/gem-graph-server

This commit is contained in:
Jean Sirmai 2021-06-11 12:53:49 +02:00
commit f43445f320
Signed by untrusted user who does not match committer: jean
GPG Key ID: FB3115C340E057E3
3 changed files with 39 additions and 24 deletions

View File

@ -48,6 +48,7 @@ struct {
IntArray_t *arrowList; IntArray_t *arrowList;
int nmaxThread; int nmaxThread;
int nmaxCycles; int nmaxCycles;
pthread_t *id;
} typedef SchedulerParams_t; } typedef SchedulerParams_t;
// //

View File

@ -29,6 +29,27 @@
#define SPACE_SIZE 10000 #define SPACE_SIZE 10000
#define MAX_THREAD 0 #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) int main(int argc, char **argv)
{ {
@ -76,23 +97,7 @@ int main(int argc, char **argv)
free(parameters); free(parameters);
SchedulerCrashTest();
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);
}

View File

@ -31,9 +31,9 @@ static void *GreatScheduler(void *parameters);
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
pthread_t *SchedInit(SchedulerParams_t *parameters) pthread_t *SchedInit(SchedulerParams_t *parameters)
{ {
pthread_t *schedThread = (pthread_t*) malloc(sizeof(pthread_t)); parameters->id = (pthread_t*) malloc(sizeof(pthread_t));
pthread_create(schedThread, NULL, GreatScheduler, parameters); pthread_create(parameters->id, NULL, GreatScheduler, parameters);
return schedThread; return parameters->id;
} }
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
@ -56,9 +56,18 @@ void SchedWait(pthread_t *schedThread)
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
// Scheduler thread main function // // Scheduler thread main function //
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
static void *GreatScheduler(void *parameters) static void *GreatScheduler(void *params)
{ {
printf("Printing from thread \n"); SchedulerParams_t *parameters = (SchedulerParams_t*) params;
sleep(1); 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; return NULL;
} }