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

Core of the multi-threaded state_server application.
More...

Functions

void signalHandler (int signal)
 
void * clockHandler (void *arg)
 
void * controllerHandler (void *arg)
 
void * outputHandler (void *arg)
 
void * inputHandler (void *arg)
 
void * stateHandler (void *arg)
 

Detailed Description

Core of the multi-threaded state_server application.

There are 5 core "handler" threads, which allow the server to manage the state of the task and interface to external user control/input sources.
The threads are managed by pthread_mutex_t lock guards with pthread_cond_t condition signals to ensure concurrency.
In the event that a condition signal is missed, there is an additional layer of protection added by condition flags, so that it is highly unlikely that the state server will ever break the following "cycle" of thread management:

  1. CLOCK - Waits for a fixed period of time before waking the controller handler thread.
  2. CONTROLLER - Takes "light" input e.g. from user interface controlling the subject/logging state of the server.
  3. INPUT - Takes "heavy" input, constantly updating the cursor position and occasionally the target positions (as they are requested from the controller).
  4. STATE - Handles calculations of whether to stay in current task state, advance to next task state, or fail to beginning of task.
  5. OUTPUT - Outputs the cursor position and any changes in target position/visibility to the rendering device. Also issues sound requests to the rendering device as appropriate, and issues reward delivery requests to the reward controller as appropriate. Finally, logs the current state of this cycle, with cursor position and timestamp.

Function Documentation

◆ clockHandler()

void * clockHandler ( void * arg)

Thread function for handling clock

◆ controllerHandler()

void * controllerHandler ( void * arg)

Thread function for controller handler

◆ inputHandler()

void * inputHandler ( void * arg)

Thread function for handling input messages etc

◆ outputHandler()

void * outputHandler ( void * arg)

Thread function for handling output messages etc

◆ signalHandler()

void signalHandler ( int signal)

Handles SIGINT for ctrl+c shutdown case.

◆ stateHandler()

void * stateHandler ( void * arg)

Thread function for state handler