Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
threads_arch.c File Reference
#include "modules/core/threads.h"
#include "modules/core/threads_arch.h"
#include "stdbool.h"
Include dependency graph for threads_arch.c:

Go to the source code of this file.

Functions

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)
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_thread_create (pprz_thread_t *thread, size_t size, const char *name, uint8_t prio, void(*pf)(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 thread_t * main_thread = NULL

Function Documentation

◆ pprz_bsem_init()

void pprz_bsem_init ( pprz_bsem_t * bsem,
bool taken )

Definition at line 39 of file threads_arch.c.

References bsem.

Referenced by amt22_init(), humid_sht_init_i2c(), i2c_chibios_submit(), i2c_linux_submit(), pmw3901_init(), spi_submit(), thd_test_init(), and uavcanInitIface().

Here is the caller graph for this function:

◆ pprz_bsem_signal()

void pprz_bsem_signal ( pprz_bsem_t * bsem)

Definition at line 57 of file threads_arch.c.

References bsem.

Referenced by amt22_periodic(), handle_spi_thd(), humid_sht_thd(), i2c_thread(), opticflow_pmw3901_periodic(), thd_test_periodic(), uavcan_request(), uavcan_response(), and uavcan_transfer().

Here is the caller graph for this function:

◆ pprz_bsem_wait()

void pprz_bsem_wait ( pprz_bsem_t * bsem)

Definition at line 43 of file threads_arch.c.

References bsem.

Referenced by amt22_thd(), pmw3901_thd(), test_thd(), and uavcan_tx().

Here is the caller graph for this function:

◆ pprz_bsem_wait_timeout()

int pprz_bsem_wait_timeout ( pprz_bsem_t * bsem,
float timeout )

Wait on semaphore no more than timeout.

Parameters
timeoutin seconds
Returns
0 on success

Definition at line 47 of file threads_arch.c.

References bsem, and timeout.

Referenced by humid_sht_periodic_i2c(), i2c_blocking_submit(), and spi_blocking_transceive().

Here is the caller graph for this function:

◆ pprz_mtx_init()

int pprz_mtx_init ( pprz_mutex_t * mtx)

Definition at line 18 of file threads_arch.c.

References mtx.

Referenced by amt22_init(), copilot_init(), gec_transport_init(), rc_uavcan_init(), slcan_init(), syslink_dl_init(), thd_test_init(), tunnel_uavcan_init_periph(), and uavcanInitIface().

Here is the caller graph for this function:

◆ pprz_mtx_lock()

◆ pprz_mtx_trylock()

int pprz_mtx_trylock ( pprz_mutex_t * mtx)

Performs a nonblocking lock on the mutex.

Returns
0 if successful

Definition at line 28 of file threads_arch.c.

References mtx.

Referenced by rc_uavcan_cb(), rc_uavcan_event(), thd_test_periodic(), thd_test_syracuse_restart(), and tunnel_uavcan_cb().

Here is the caller graph for this function:

◆ pprz_mtx_unlock()

◆ pprz_thread_assert_main()

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)

Parameters
whatwhat was done outside the main thread (printed on Linux/NPS)
idits identifier (e.g. the ABI message ID)

Definition at line 72 of file threads_arch.c.

References pprz_thread_is_main().

Here is the call graph for this function:

◆ pprz_thread_create()

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.

Parameters
[in]sizesize of the stack. Unused on linux at the moment.
[in]priothe priority level for the new thread. Unused on linux at the moment. NORMALPRIO
[in]pfthe thread function
[in]argan argument passed to the thread function. It can be NULL.
[out]threadpointer to a pprz_thread_t that will be writen with the handle to the thread
Returns
Return 0 on success, or a platform dependant error code.

@api

Definition at line 80 of file threads_arch.c.

Referenced by amt22_init(), humid_sht_init_i2c(), pmw3901_init(), thd_test_init(), thd_test_syracuse_restart(), and uavcanInitIface().

Here is the caller graph for this function:

◆ pprz_thread_exit()

void pprz_thread_exit ( void * retval)

Exit the current thread.

Parameters
[out]retvalThe thread's return value

Definition at line 88 of file threads_arch.c.

Referenced by test_thd().

Here is the caller graph for this function:

◆ pprz_thread_init_main()

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 64 of file threads_arch.c.

References main_thread.

Referenced by pprz_thread_periodic().

Here is the caller graph for this function:

◆ pprz_thread_is_main()

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 68 of file threads_arch.c.

References main_thread.

Referenced by pprz_thread_assert_main().

Here is the caller graph for this function:

◆ pprz_thread_join()

int pprz_thread_join ( pprz_thread_t * thread,
void ** retval )

Wait for the thread to terminate.

Note
Warning ! This is a blocking function, do not use it in the main AP thread !
Parameters
[in]threadThe thread to be joined
[out]retvalThe thread's return value will be written to the variable pointed by retval

Definition at line 93 of file threads_arch.c.

Referenced by pprz_thread_tryjoin().

Here is the caller graph for this function:

◆ pprz_thread_tryjoin()

int pprz_thread_tryjoin ( pprz_thread_t * thread,
void ** retval )

Performs a nonblocking join with the thread.

Parameters
[in]threadThe thread to be joined
[out]retvalThe thread's return value will be written to the variable pointed by retval. must not be used if this fuction did not returned 0.
Returns
0 if the thread successfully joined.

Definition at line 99 of file threads_arch.c.

References pprz_thread_join().

Referenced by thd_test_periodic().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ main_thread

thread_t* main_thread = NULL
static

Definition at line 62 of file threads_arch.c.

Referenced by pprz_thread_init_main(), and pprz_thread_is_main().