StateServer 1.6.9
Compiled `c` application to handle task state logging and timing.
Loading...
Searching...
No Matches
Thread Management

Single global mutex lock guard and thread condition signals. More...

Variables

pthread_mutex_t mutex
 Only mutex. Manages thread concurrency and synchronization together with condition signals.
 
pthread_cond_t wake_controller_handler
 Condition signal issued by the clock handler thread to wake the controller handler thread.
 
pthread_cond_t wake_input_handler
 Condition signal issued by the controller handler thread to wake the input handler thread.
 
pthread_cond_t wake_state_handler
 Condition signal issued by the input handler thread to wake the state handler thread.
 
pthread_cond_t wake_output_handler
 Condition signal issued by state handler thread to wake the output handler thread.
 
pthread_cond_t wake_clock_handler
 Condition signal issued by the output handler thread to wake the clock handler thread.
 

Detailed Description

Single global mutex lock guard and thread condition signals.

There is a single global mutex to ensure concurrency and synchronization on the 5 main handler threads.
Together with the volatile global sig_atomic_t flags (which ensure atomicity in the compiler), the thread management is ensured to always complete the following cycle:

CLOCK --> CONTROLLER --> INPUT --> STATE --> OUTPUT

Any function that uses print debug while server is running (i.e. printf("my debug statement");) should ensure that prior to printf, it has acquired mutex via pthread_mutex_lock(&mutex);, and releases the lock after via pthread_mutex_unlock(&mutex);. This ensures the debug print statements do not alter the behavior of the state server by accessing the terminal stdio in a non-thread-safe manner.

Variable Documentation

◆ mutex

pthread_mutex_t mutex
extern

Only mutex. Manages thread concurrency and synchronization together with condition signals.

Only mutex. Manages thread concurrency and synchronization together with condition signals. >

◆ wake_clock_handler

pthread_cond_t wake_clock_handler
extern

Condition signal issued by the output handler thread to wake the clock handler thread.

Condition signal issued by output handler thread to wake clock handler thread. >

◆ wake_controller_handler

pthread_cond_t wake_controller_handler
extern

Condition signal issued by the clock handler thread to wake the controller handler thread.

Condition signal issued by clock handler thread to wake controller handler thread. >

◆ wake_input_handler

pthread_cond_t wake_input_handler
extern

Condition signal issued by the controller handler thread to wake the input handler thread.

Condition signal issued by controller handler thread to wake input handler thread. >

◆ wake_output_handler

pthread_cond_t wake_output_handler
extern

Condition signal issued by state handler thread to wake the output handler thread.

Condition signal issued by state handler thread to wake output handler thread. >

◆ wake_state_handler

pthread_cond_t wake_state_handler
extern

Condition signal issued by the input handler thread to wake the state handler thread.

Condition signal issued by input handler thread to wake state handler thread. >