stdlib: Implement mbrtoc8, c8rtomb, and the char8_t typedef.
[glibc.git] / benchtests / thread_create-source.c
blob4a72168224a7348a3dcfa9a4f2d545d1e87eb74e
1 /* Measure pthread_create thread creation with different stack
2 and guard sizes.
4 Copyright (C) 2017-2022 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <https://www.gnu.org/licenses/>. */
21 #include <stdio.h>
22 #include <unistd.h>
23 #include <support/xthread.h>
25 static size_t pgsize;
27 static void
28 thread_create_init (void)
30 pgsize = sysconf (_SC_PAGESIZE);
33 static void *
34 thread_dummy (void *arg)
36 return NULL;
39 static void
40 thread_create (int nthreads, size_t stacksize, size_t guardsize)
42 pthread_attr_t attr;
43 xpthread_attr_init (&attr);
45 stacksize = stacksize * pgsize;
46 guardsize = guardsize * pgsize;
48 xpthread_attr_setstacksize (&attr, stacksize);
49 xpthread_attr_setguardsize (&attr, guardsize);
51 pthread_t ts[nthreads];
53 for (int i = 0; i < nthreads; i++)
54 ts[i] = xpthread_create (&attr, thread_dummy, NULL);
56 for (int i = 0; i < nthreads; i++)
57 xpthread_join (ts[i]);