switch-threads.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* A minimal multi-threaded test case.
  2. Copyright 2003-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include <pthread.h>
  15. void foo (void)
  16. {
  17. }
  18. void *thread_func (void *arg)
  19. {
  20. int x;
  21. for (x = 0; x < 10; x++)
  22. foo ();
  23. return 0;
  24. }
  25. int main()
  26. {
  27. pthread_t thr;
  28. void *ret;
  29. int x;
  30. pthread_create (&thr, NULL, thread_func, NULL);
  31. pthread_join (thr, &ret);
  32. for (x = 0; x < 10; x++)
  33. foo ();
  34. }