mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-29 04:54:27 +01:00
pthread_self: allow multiple waves
Original motivation: determine if gem5's join releases CPU cores. It does.
This commit is contained in:
@@ -57,7 +57,7 @@ void* main_thread(void *arg) {
|
|||||||
|
|
||||||
int main(int argc, char**argv) {
|
int main(int argc, char**argv) {
|
||||||
pthread_t *threads;
|
pthread_t *threads;
|
||||||
unsigned int nthreads, i, *thread_args;
|
unsigned int nthreads, nwaves, i, *thread_args, wave;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* CLI arguments. */
|
/* CLI arguments. */
|
||||||
@@ -66,9 +66,15 @@ int main(int argc, char**argv) {
|
|||||||
} else {
|
} else {
|
||||||
nthreads = 1;
|
nthreads = 1;
|
||||||
}
|
}
|
||||||
|
if (argc > 2) {
|
||||||
|
nwaves = strtoll(argv[2], NULL, 0);
|
||||||
|
} else {
|
||||||
|
nwaves = 1;
|
||||||
|
}
|
||||||
threads = malloc(nthreads * sizeof(*threads));
|
threads = malloc(nthreads * sizeof(*threads));
|
||||||
thread_args = malloc(nthreads * sizeof(*thread_args));
|
thread_args = malloc(nthreads * sizeof(*thread_args));
|
||||||
|
|
||||||
|
for (wave = 0; wave < nwaves; wave++) {
|
||||||
/* main thread for comparison. */
|
/* main thread for comparison. */
|
||||||
printf(
|
printf(
|
||||||
"tid, getpid(), pthread_self() = "
|
"tid, getpid(), pthread_self() = "
|
||||||
@@ -103,6 +109,7 @@ int main(int argc, char**argv) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Cleanup. */
|
/* Cleanup. */
|
||||||
free(thread_args);
|
free(thread_args);
|
||||||
|
|||||||
Reference in New Issue
Block a user