| * Unlike testthread which is mainly concerned about testing thread |
| * semantics this test is used to exercise the thread creation and |
| * accounting. A version of this test found a problem with clashing |
| * cpu_indexes which caused a break in plugin handling. |
| * Based on the original test case by Nikolay Igotti. |
| * Copyright (c) 2020 Linaro Ltd |
| * SPDX-License-Identifier: GPL-2.0-or-later |
| static void *thread_fn(void* varg) |
| int main(int argc, char **argv) |
| max_threads = atoi(argv[1]); |
| threads = calloc(sizeof(pthread_t), max_threads); |
| for (i = 0; i < max_threads; i++) { |
| ThreadArg *arg = calloc(sizeof(ThreadArg), 1); |
| pthread_create(threads + i, NULL, thread_fn, arg); |
| printf("Created %d threads\n", max_threads); |
| /* sleep until roughly half the threads have "finished" */ |
| usleep(max_threads * 50); |
| for (i = 0; i < max_threads; i++) { |
| pthread_join(threads[i], NULL); |