|
Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
#include "modules/core/threads.h"#include "modules/core/threads_arch.h"#include "stdbool.h"#include <semaphore.h>#include <stdio.h>#include <stdlib.h>#include <time.h>Go to the source code of this file.
Data Structures | |
| struct | stub_arg |
Functions | |
| void | pprz_thread_init_main (void) |
| Remember the calling thread as the main thread, the one running the periodic and event functions of the modules. | |
| bool | pprz_thread_is_main (void) |
| The calling thread is the main thread (also true before pprz_thread_init_main() was called). | |
| void | pprz_thread_assert_main (const char *what, unsigned int id) |
| Stop the program (abort on Linux/NPS, halt on ChibiOS) when not called from the main thread, e.g. | |
| int | pprz_mtx_init (pprz_mutex_t *mtx) |
| int | pprz_mtx_lock (pprz_mutex_t *mtx) |
| int | pprz_mtx_trylock (pprz_mutex_t *mtx) |
| Performs a nonblocking lock on the mutex. | |
| int | pprz_mtx_unlock (pprz_mutex_t *mtx) |
| void | pprz_bsem_init (pprz_bsem_t *bsem, bool taken) |
| void | pprz_bsem_wait (pprz_bsem_t *bsem) |
| int | pprz_bsem_wait_timeout (pprz_bsem_t *bsem, float timeout) |
| Wait on semaphore no more than timeout. | |
| void | pprz_bsem_signal (pprz_bsem_t *bsem) |
| static void * | stub (void *arg) |
| int | pprz_thread_create (pprz_thread_t *thread, size_t size, const char *name, uint8_t prio, void(*func)(void *), void *arg) |
| Creates a new thread whose stack is dynamically allocated. | |
| void | pprz_thread_exit (void *retval) |
| Exit the current thread. | |
| int | pprz_thread_join (pprz_thread_t *thread, void **retval) |
| Wait for the thread to terminate. | |
| int | pprz_thread_tryjoin (pprz_thread_t *thread, void **retval) |
| Performs a nonblocking join with the thread. | |
Variables | |
| static pthread_t | main_thread |
| static bool | main_thread_set = false |
| struct stub_arg |
Definition at line 97 of file threads_arch.c.
| Data Fields | ||
|---|---|---|
| void * | arg | |
| void(*)(void *) | func | |
| void pprz_bsem_init | ( | pprz_bsem_t * | bsem, |
| bool | taken ) |
Definition at line 59 of file threads_arch.c.
References bsem.
| void pprz_bsem_signal | ( | pprz_bsem_t * | bsem | ) |
Definition at line 83 of file threads_arch.c.
| void pprz_bsem_wait | ( | pprz_bsem_t * | bsem | ) |
Definition at line 64 of file threads_arch.c.
References bsem.
| int pprz_bsem_wait_timeout | ( | pprz_bsem_t * | bsem, |
| float | timeout ) |
Wait on semaphore no more than timeout.
| timeout | in seconds |
Definition at line 68 of file threads_arch.c.
| int pprz_mtx_init | ( | pprz_mutex_t * | mtx | ) |
Definition at line 41 of file threads_arch.c.
References mtx.
| int pprz_mtx_lock | ( | pprz_mutex_t * | mtx | ) |
Definition at line 45 of file threads_arch.c.
References mtx.
| int pprz_mtx_trylock | ( | pprz_mutex_t * | mtx | ) |
Performs a nonblocking lock on the mutex.
Definition at line 49 of file threads_arch.c.
References mtx.
| int pprz_mtx_unlock | ( | pprz_mutex_t * | mtx | ) |
Definition at line 53 of file threads_arch.c.
References mtx.
| void pprz_thread_assert_main | ( | const char * | what, |
| unsigned int | id ) |
Stop the program (abort on Linux/NPS, halt on ChibiOS) when not called from the main thread, e.g.
for an ABI message sent from another thread (ABI_CHECK_MAIN_THREAD)
| what | what was done outside the main thread (printed on Linux/NPS) |
| id | its identifier (e.g. the ABI message ID) |
Definition at line 34 of file threads_arch.c.
References pprz_thread_is_main().
| int pprz_thread_create | ( | pprz_thread_t * | thread, |
| size_t | size, | ||
| const char * | name, | ||
| uint8_t | prio, | ||
| void(* | func )(void *), | ||
| void * | arg ) |
Creates a new thread whose stack is dynamically allocated.
| [in] | size | size of the stack. Unused on linux at the moment. |
| [in] | prio | the priority level for the new thread. Unused on linux at the moment. NORMALPRIO |
| [in] | pf | the thread function |
| [in] | arg | an argument passed to the thread function. It can be NULL. |
| [out] | thread | pointer to a pprz_thread_t that will be writen with the handle to the thread |
@api
Definition at line 111 of file threads_arch.c.
References stub_arg::arg, stub_arg::func, and stub().
| void pprz_thread_exit | ( | void * | retval | ) |
Exit the current thread.
| [out] | retval | The thread's return value |
Definition at line 122 of file threads_arch.c.
| void pprz_thread_init_main | ( | void | ) |
Remember the calling thread as the main thread, the one running the periodic and event functions of the modules.
Called by pprz_thread_periodic() (the init can run in another thread, e.g. in NPS).
Definition at line 25 of file threads_arch.c.
References main_thread, and main_thread_set.
| bool pprz_thread_is_main | ( | void | ) |
The calling thread is the main thread (also true before pprz_thread_init_main() was called).
Definition at line 30 of file threads_arch.c.
References main_thread, and main_thread_set.
| int pprz_thread_join | ( | pprz_thread_t * | thread, |
| void ** | retval ) |
Wait for the thread to terminate.
| [in] | thread | The thread to be joined |
| [out] | retval | The thread's return value will be written to the variable pointed by retval |
Definition at line 126 of file threads_arch.c.
| int pprz_thread_tryjoin | ( | pprz_thread_t * | thread, |
| void ** | retval ) |
Performs a nonblocking join with the thread.
| [in] | thread | The thread to be joined |
| [out] | retval | The thread's return value will be written to the variable pointed by retval. must not be used if this fuction did not returned 0. |
Definition at line 130 of file threads_arch.c.
|
static |
Definition at line 104 of file threads_arch.c.
References stub_arg::arg, and stub_arg::func.
Referenced by pprz_thread_create().
|
static |
Definition at line 22 of file threads_arch.c.
|
static |
Definition at line 23 of file threads_arch.c.
Referenced by pprz_thread_init_main(), and pprz_thread_is_main().