BEEP-8 SDK 1.0.0
Loading...
Searching...
No Matches
pthread.h
Go to the documentation of this file.
1
43#pragma once
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#include <b8/os.h>
50#include <b8/type.h>
51#include <b8/sched.h>
52
53#undef pthread_attr_t
54#define pthread_attr_t b8_pthread_attr_t
55
56typedef b8OsPid pthread_t;
57
58typedef void *pthread_addr_t;
59
60typedef pthread_addr_t (*pthread_startroutine_t)(pthread_addr_t);
61typedef pthread_startroutine_t pthread_func_t;
62
63typedef struct _b8_pthread_attr_t {
64 void* stackaddr; // Address of memory to be used as stack
65 size_t stacksize; // Size of the stack allocated for the pthread
66 u8 policy;
67 u8 detachstate; // Initialize to the detach state
68 s16 priority; // The actual scheduling policy is ignored and thus effectively unsupported.
69 u16 irq_no;
71
72#define PTHREAD_STACK_MIN (0x200)
73
74#undef PTHREAD_CREATE_JOINABLE
75#define PTHREAD_CREATE_JOINABLE 0
76
77#undef PTHREAD_CREATE_DETACHED
78#define PTHREAD_CREATE_DETACHED 1
79
80#define pthread_equal(t1,t2) ((t1) == (t2))
81
95extern int pthread_create(
96 pthread_t* thread,
97 const pthread_attr_t* attr,
98 pthread_startroutine_t startroutine,
99 pthread_addr_t arg
100);
101
110extern int pthread_yield(void);
111
120extern pthread_t pthread_self(void);
121
131extern int pthread_attr_init(pthread_attr_t* attr);
132
142extern int pthread_attr_destroy(pthread_attr_t *attr);
143
154extern int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
155
166extern int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
167
179extern int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, long stacksize);
180
192extern int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, long *stacksize);
193
204extern int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);
205
216extern int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
217
230extern int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param);
231
244extern int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param);
245
257extern int pthread_getschedparam(pthread_t thread, int* policy, struct sched_param* param);
258
270extern int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param* param);
271
282extern int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
283
294extern int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy);
295
306extern void pthread_exit(pthread_addr_t value);
307
318extern int pthread_detach(pthread_t thread);
319
330extern int pthread_join(pthread_t thread, pthread_addr_t *value);
331
341extern int pthread_cancel(pthread_t thread);
342
353extern int pthread_setcanceltype(int type, int *oldtype);
354
362extern void pthread_testcancel(void);
363
364/*
365Note: The following functions are not supported and are not defined in this environment.
366- pthread_attr_setinheritsched
367- pthread_attr_getinheritsched
368- pthread_attr_setaffinity_np
369- pthread_attr_getaffinity_np
370- pthread_setaffinity_np
371- pthread_getaffinity_np
372- pthread_setschedprio
373- pthread_setcancelstate(int state, int *oldstate);
374*/
375
376#ifdef __cplusplus
377}
378#endif
OS definitions and system call interfaces for the BEEP-8 system.
int pthread_attr_init(pthread_attr_t *attr)
Initializes a thread attributes object.
Definition pthread.c:62
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param)
Sets the scheduling policy and parameters of the specified thread.
Definition pthread.c:132
int pthread_join(pthread_t thread, pthread_addr_t *value)
Waits for the specified thread to terminate.
Definition pthread.c:218
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
Gets the detach state attribute from the thread attributes object.
Definition pthread.c:197
int pthread_attr_destroy(pthread_attr_t *attr)
Destroys a thread attributes object.
Definition pthread.c:75
pthread_t pthread_self(void)
Returns the thread identifier of the calling thread.
Definition pthread.c:229
int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param)
Sets the scheduling parameters in the thread attributes object.
Definition pthread.c:163
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, pthread_startroutine_t startroutine, pthread_addr_t arg)
Creates a new thread.
Definition pthread.c:24
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
Sets the scheduling policy attribute in the thread attributes object.
Definition pthread.c:144
int pthread_detach(pthread_t thread)
Detaches the specified thread.
Definition pthread.c:139
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
Sets the stack size attribute in the thread attributes object.
Definition pthread.c:83
int pthread_cancel(pthread_t thread)
Cancels the specified thread.
Definition pthread.c:213
int pthread_setcanceltype(int type, int *oldtype)
Sets the cancelability type of the calling thread.
int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param)
Retrieves the scheduling policy and parameters of the specified thread.
Definition pthread.c:125
void pthread_exit(pthread_addr_t value)
Terminates the calling thread.
Definition pthread.c:208
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
Gets the stack size attribute from the thread attributes object.
Definition pthread.c:91
int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, long *stacksize)
Gets the stack address and size attributes from the thread attributes object.
Definition pthread.c:116
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
Sets the detach state attribute in the thread attributes object.
Definition pthread.c:186
int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, long stacksize)
Sets the stack address and size attributes in the thread attributes object.
Definition pthread.c:103
int pthread_yield(void)
Yields the processor to another thread.
Definition pthread.c:224
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
Retrieves the scheduling policy from the thread attributes object.
Definition pthread.c:152
void pthread_testcancel(void)
Creates a cancellation point in the calling thread.
int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param)
Retrieves the scheduling parameters from the thread attributes object.
Definition pthread.c:174
Minimal POSIX-compliant scheduling definitions for the BEEP-8 system.
Definition pthread.h:63