The ROme OpTimistic Simulator  3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
thread.h
Go to the documentation of this file.
1 
17 #pragma once
18 
19 #include <arch/platform.h>
20 
21 #if defined(__POSIX)
22 #define _GNU_SOURCE
23 #include <pthread.h>
24 
25 #define THREAD_CALL_CONV
26 typedef void * thr_ret_t;
27 typedef pthread_t thr_id_t;
28 
29 #define THREAD_RET_FAILURE ((void *) 1)
30 #define THREAD_RET_SUCCESS ((void *) 0)
31 
32 #elif defined(__WINDOWS)
33 
34 #define WIN32_LEAN_AND_MEAN
35 #include <windows.h>
36 #undef WIN32_LEAN_AND_MEAN
37 
38 #define THREAD_CALL_CONV WINAPI
39 typedef DWORD arch_thr_ret_t;
40 typedef HANDLE arch_thr_t;
41 
42 #define THREAD_RET_FAILURE (1)
43 #define THREAD_RET_SUCCESS (0)
44 
45 #endif
46 
48 typedef thr_ret_t THREAD_CALL_CONV (*thr_run_fnc)(void *);
49 
50 extern int thread_start(thr_id_t *thr_p, thr_run_fnc t_fnc, void *t_fnc_arg);
51 extern int thread_affinity_set(thr_id_t thr, unsigned core);
52 extern int thread_wait(thr_id_t thr, thr_ret_t *ret);
53 extern unsigned thread_cores_count(void);
thr_run_fnc
thr_ret_t THREAD_CALL_CONV(* thr_run_fnc)(void *)
The function type of a new thread entry point.
Definition: thread.h:48
thread_wait
int thread_wait(thr_id_t thr, thr_ret_t *ret)
Wait for specified thread to complete execution.
thread_affinity_set
int thread_affinity_set(thr_id_t thr, unsigned core)
Sets a core affinity for a thread.
platform.h
Determine on what OS we are compiling.
thread_cores_count
unsigned thread_cores_count(void)
Computes the count of available cores on the machine.
Definition: init_test.c:23
thread_start
int thread_start(thr_id_t *thr_p, thr_run_fnc t_fnc, void *t_fnc_arg)
Creates a thread.