Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill old $Id$ command dating from CVS
[simgrid.git] / src / include / xbt / xbt_os_thread.h
1 /* xbt/xbt_thread.h -- Thread portability layer                             */
2
3 /* Copyright (c) 2007 Martin Quinson. All rights reserved.                  */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8
9 #ifndef _XBT_OS_THREAD_H
10 #define _XBT_OS_THREAD_H
11
12 #include "xbt/misc.h"           /* SG_BEGIN_DECL */
13 #include "xbt/function_types.h"
14
15 SG_BEGIN_DECL()
16
17 /** @addtogroup XBT_thread
18  *  @brief Thread portability layer
19  * 
20  *  This section describes the thread portability layer. It defines types and 
21  *  functions very close to the pthread API, but it's portable to windows too.
22  * 
23  *  @{
24  */
25   /** \brief Thread data type (opaque structure) */
26      typedef struct xbt_os_thread_ *xbt_os_thread_t;
27
28 XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_create(const char *name,
29                                                  pvoid_f_pvoid_t
30                                                  start_routine, void *param);
31 XBT_PUBLIC(void) xbt_os_thread_exit(int *retcode);
32 XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_self(void);
33 XBT_PUBLIC(const char *) xbt_os_thread_self_name(void);
34 XBT_PUBLIC(const char *) xbt_os_thread_name(xbt_os_thread_t);
35   /* xbt_os_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */
36 XBT_PUBLIC(void) xbt_os_thread_join(xbt_os_thread_t thread,
37                                     void **thread_return);
38 XBT_PUBLIC(void) xbt_os_thread_yield(void);
39 XBT_PUBLIC(void) xbt_os_thread_cancel(xbt_os_thread_t thread);
40 XBT_PUBLIC(void *) xbt_os_thread_getparam(void);
41
42
43   /** \brief Thread mutex data type (opaque structure) */
44      typedef struct xbt_os_mutex_ *xbt_os_mutex_t;
45
46 XBT_PUBLIC(xbt_os_mutex_t) xbt_os_mutex_init(void);
47 XBT_PUBLIC(void) xbt_os_mutex_acquire(xbt_os_mutex_t mutex);
48 XBT_PUBLIC(void) xbt_os_mutex_timedacquire(xbt_os_mutex_t mutex,
49                                            double delay);
50 XBT_PUBLIC(void) xbt_os_mutex_release(xbt_os_mutex_t mutex);
51 XBT_PUBLIC(void) xbt_os_mutex_destroy(xbt_os_mutex_t mutex);
52
53
54   /** \brief Thread condition data type (opaque structure) */
55      typedef struct xbt_os_cond_ *xbt_os_cond_t;
56
57 XBT_PUBLIC(xbt_os_cond_t) xbt_os_cond_init(void);
58 XBT_PUBLIC(void) xbt_os_cond_wait(xbt_os_cond_t cond, xbt_os_mutex_t mutex);
59 XBT_PUBLIC(void) xbt_os_cond_timedwait(xbt_os_cond_t cond,
60                                        xbt_os_mutex_t mutex, double delay);
61 XBT_PUBLIC(void) xbt_os_cond_signal(xbt_os_cond_t cond);
62 XBT_PUBLIC(void) xbt_os_cond_broadcast(xbt_os_cond_t cond);
63 XBT_PUBLIC(void) xbt_os_cond_destroy(xbt_os_cond_t cond);
64
65    /** \brief Semaphore data type (opaque structure) */
66      typedef struct xbt_os_sem_ *xbt_os_sem_t;
67
68 XBT_PUBLIC(xbt_os_sem_t) xbt_os_sem_init(unsigned int value);
69 XBT_PUBLIC(void) xbt_os_sem_acquire(xbt_os_sem_t sem);
70 XBT_PUBLIC(void) xbt_os_sem_timedacquire(xbt_os_sem_t sem, double timeout);
71 XBT_PUBLIC(void) xbt_os_sem_release(xbt_os_sem_t sem);
72 XBT_PUBLIC(void) xbt_os_sem_destroy(xbt_os_sem_t sem);
73 XBT_PUBLIC(void) xbt_os_sem_get_value(xbt_os_sem_t sem, int *svalue);
74
75
76 /** @} */
77
78 SG_END_DECL()
79 #endif /* _XBT_OS_THREAD_H */