include examples/sthread/pthread-mutex-simple.c
include examples/sthread/pthread-mutex-simple.tesh
include examples/sthread/sthread-mutex-simple.c
+include examples/sthread/sthread-mutex-simple.tesh
include src/include/catch_simgrid.hpp
include teshsuite/java/semaphoregc/SemaphoreGC.java
include teshsuite/java/semaphoregc/semaphoregc.tesh
set_target_properties(sthread-${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(sthread-${x} sthread)
set_property(TARGET sthread-${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
+
add_dependencies(tests sthread-${x})
+ ADD_TESH_FACTORIES(sthread-${x} "^thread" --cd ${CMAKE_BINARY_DIR}/examples/sthread ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.tesh)
endif()
-# set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.tesh)
+ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.tesh)
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/sthread-${x}.c)
endforeach()
sthread_mutex_t mutex;
-static void* thread_fun(void* ignore)
+static void* thread_fun(void* val)
{
sthread_mutex_lock(&mutex);
sthread_mutex_unlock(&mutex);
+ fprintf(stderr, "The thread %d is terminating.\n", *(int*)val);
return NULL;
}
{
sthread_mutex_init(&mutex, NULL);
+ int id[2] = {0, 1};
sthread_t thread1;
sthread_t thread2;
- sthread_create(&thread1, NULL, thread_fun, NULL);
- sthread_create(&thread2, NULL, thread_fun, NULL);
+ sthread_create(&thread1, NULL, thread_fun, (void*)&id[0]);
+ sthread_create(&thread2, NULL, thread_fun, (void*)&id[1]);
+ fprintf(stderr, "All threads are started.\n");
sthread_join(thread1, NULL);
sthread_join(thread2, NULL);
sthread_mutex_destroy(&mutex);
- fprintf(stderr, "done\n");
+ fprintf(stderr, "User's main is terminating.\n");
return 0;
}
--- /dev/null
+$ ./sthread-mutex-simple
+> [0.000000] [sthread/INFO] Starting the simulation.
+> All threads are started.
+> The thread 0 is terminating.
+> The thread 1 is terminating.
+> User's main is terminating.
+> [0.000000] [sthread/INFO] All threads exited. Terminating the simulation.