fb11e647
vrobic
reseau statique a...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
/*
* Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup pthread
* @{
* @file
* @brief Thread creation features (attributes).
* @note Do not include this header file directly, but pthread.h.
*/
#ifndef SYS__POSIX__PTHREAD_THREADING_ATTR__H
#define SYS__POSIX__PTHREAD_THREADING_ATTR__H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief An attribute set to supply to pthread_create()
* @details A zeroed out datum is default initiliazed.
* @see pthread_create() for further information
*/
typedef struct
{
uint8_t detached; /**< Start in detached state. */
char *ss_sp; /**< Stack to use for new thread. */
size_t ss_size; /**< Size of dynamically allocated stack, or supplied stack, resp. */
} pthread_attr_t;
/**
* @brief This structure is unused right now, and only exists for POSIX compatibility.
*/
struct sched_param {
/** Todo is the greates magician in the land of RIOT */
int todo; /* TODO */
};
#define PTHREAD_CREATE_JOINABLE (0) /**< Create new pthread as joinable (default). */
#define PTHREAD_CREATE_DETACHED (1) /**< Create new pthread in detached state. */
/**
* @brief Initialize attributes for a new pthread.
* @see pthread_create()
* @details A zeroed out `attr` is initialized.
* @param[in,out] attr Structure to initialize
* @returns 0, invocation cannot fail
*/
int pthread_attr_init(pthread_attr_t *attr);
/**
* @brief Destroys an attribute set.
* @details Since pthread_attr_t does not hold dynamic data, this is a no-op.
* @returns 0, since this a no-op that cannot fail
*/
int pthread_attr_destroy(pthread_attr_t *attr);
/**
* @brief Tells whether to create a new pthread in a detached state.
* @param[in] attr Attribute set to query.
* @param[out] detachstate Either PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED.
* @returns 0, the invocation cannot fail
*/
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);
/**
* @brief Sets whether to create a new pthread in a detached state.
* @note Supplying a value different form PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED
* causes undefined behavior.
* @param[in,out] attr Attribute set to operate on.
* @param[in] detachstate Either PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED.
* @returns `0` on success.
* `-1` if you managed to supply an illegal value in `detachstate`.
*/
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in] attr Unused
* @param[out] guardsize Unused
* @returns -1, this function fails
*/
int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in,out] attr Unused
* @param[in] guardsize Unused
* @returns -1, this function fails
*/
int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in] attr Unused
* @param[out] param Unused
* @returns -1, this function fails
*/
int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in,out] attr Unused
* @param[in] param Unused
* @returns -1, this function fails
*/
int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in] attr Unused
* @param[out] policy Unused
* @returns -1, this function fails
*/
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in,out] attr Unused
* @param[in] policy Unused
* @returns -1, this function fails
*/
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in] attr Unused
* @param[out] inherit Unused
* @returns -1, this function fails
*/
int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in,out] attr Unused
* @param[in] inherit Unused
* @returns -1, this function fails
*/
int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in] attr Unused
* @param[out] scope Unused
* @returns -1, this function fails
*/
int pthread_attr_getscope(const pthread_attr_t *attr, int *scope);
/**
* @brief This function is unused right now, and only exists for POSIX compatibility.
* @param[in,out] attr Unused
* @param[in] scope Unused
* @returns -1, this function fails
*/
int pthread_attr_setscope(pthread_attr_t *attr, int scope);
/**
* @brief Query assigned stack for new pthread.
* @see pthread_attr_setstackaddr() for more information
* @param[in] attr Attribute set to query
* @param[out] stackaddr Pointer to previously assigned stack, or `NULL` for dynamic allocation.
* @returns 0, this invocation cannot fail
*/
int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr);
/**
* @brief Set address of the stack to use for the new pthread.
* @details If `*stackaddr == NULL`, then the stack is dynamically allocated with malloc().
* No two running threads may operate on the same stack.
* The stack of a zombie thread (i.e. a non-detached thread that exited but was not yet joined)
* may in theory be reused even before joining, though there might be problems
* if the stack was preempted before pthread_exit() completed.
* @param[in,out] attr Attribute set to operate on.
* @param[in] stackaddr Static stack to use, or `NULL` for dynamic allocation.
* @returns 0, this invocation cannot fail
*/
int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr);
/**
* @brief Query set stacksize for new pthread.
* @details Returns default stack size of the value is yet unset.
* @param[in] attr Attribute set to query.
* @param[out] stacksize Assigned or default stack size, resp.
* @returns 0, this invocation cannot fail
*/
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
/**
* @brief Set the stack size for the new pthread.
* @details If you use pthread_attr_getstackaddr() to assign a static stack,
* then you must use this function to set the size of the stack.
* In case of dynamic memory allocation this overrules the default value.
* @param[in,out] attr Attribute set to operate on
* @param[in] stacksize Size of the stack of the new thread.
* Supply `0` to use the default value.
* @return 0, this invocation cannot fail.
*/
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
#ifdef __cplusplus
}
#endif
#endif /* SYS__POSIX__PTHREAD_THREADING_ATTR__H */
/**
* @}
*/
|