1 /* Copyright (c) 2002-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 /* Simple test code with no bug */
11 pthread_mutex_t mutex;
13 static void* thread_fun(void* val)
15 pthread_mutex_lock(&mutex);
16 pthread_mutex_unlock(&mutex);
18 fprintf(stderr, "The thread %d is terminating.\n", *(int*)val);
22 int main(int argc, char* argv[])
24 pthread_mutex_init(&mutex, NULL);
29 pthread_create(&thread1, NULL, thread_fun, &id[0]);
30 pthread_create(&thread2, NULL, thread_fun, &id[1]);
31 fprintf(stderr, "All threads are started.\n");
32 pthread_join(thread1, NULL);
33 pthread_join(thread2, NULL);
35 pthread_mutex_destroy(&mutex);
37 fprintf(stderr, "User's main is terminating.\n");