yumapro  24.10-1
YumaPro SDK
Loading...
Searching...
No Matches

Posix threads support for server and client. More...

Collaboration diagram for Posix Threads:

Data Structures

struct  thd_tcb_t
 Thread control block (TCB) More...
 

Enumerations

enum  thd_tcb_state_t {
  THD_TCB_STATE_NONE ,
  THD_TCB_STATE_ACTIVE ,
  THD_TCB_STATE_INACTIVE ,
  THD_TCB_STATE_DELETED ,
  THD_TCB_STATE_LIMIT
}
 Thread (tcb) states. More...
 
enum  thd_type_t {
  THD_TYPE_NONE ,
  THD_TYPE_BKGD ,
  THD_TYPE_CONN ,
  THD_TYPE_TMR ,
  THD_TYPE_SES ,
  THD_TYPE_DUMMY ,
  THD_TYPE_LIMIT
}
 Thread types. More...
 

Functions

boolean thd_rcv_signal_setup (sigset_t *sigmask, thd_tcb_t *tcb)
 Init thread to receive omnibus signal. More...
 
void thd_check_shutdown_signal (sigset_t *sigmask, thd_tcb_t *tcb)
 The agt_shutdown_requested == TRUE at this point. More...
 
boolean thd_yield_for_cdx (int max_yield_count, uint usec, int ival, test_cdx_int_t sid_test_func)
 Yield scheduler in loop until specified condition(s) are met or max loop count is exceeded. More...
 
void thd_set_main_pthread_attr (void)
 Set/display main pthread attributes, to be inherited by all threads, unless otherwise noted. More...
 
status_t thd_master_init (void)
 Initialize all mutexes for use by threads. More...
 
void thd_set_main_handle (void)
 Record the thread handle of "main" (running initially before any threads are created) for reference. More...
 
thd_tcb_tthd_new_tcb (thd_type_t type)
 Allocate a new thread control block. More...
 
void thd_clear_locks (thd_tcb_t *tcb)
 Clear mutexes and RWLOCKs prior to termination. More...
 
void thd_mark_tcb_deleted (thd_tcb_t *tcb)
 Cleanup (release resources associated with a TCB) and free it. More...
 
void thd_shutdown (void)
 Begin thread ermination by signalling.
 
void thd_cleanup (boolean phase1)
 Terminate threads and deallocate associated resources, including thread control blocks. More...
 
thd_tcb_tthd_find_tcb_by_handle (pthread_t handle)
 Find a thread by its OS pthread handle. More...
 
thd_tcb_tthd_find_tcb_by_capability (uint cap)
 Find a TCB supporting the specified capability. More...
 
thd_tcb_tthd_find_tcb_by_type (thd_type_t type)
 Find a TCB supporting the specified type. More...
 
int thd_count_ses_threads (void)
 Count the number of session threads. More...
 
thd_tcb_tthd_find_tcb_by_sid (ses_id_t sid, boolean strict)
 Lookup TCB by session ID. More...
 
ses_id_t thd_find_sess_id_by_handle (pthread_t handle)
 Find the session ID represented by the thread handle. More...
 
ses_id_t thd_find_sess_id (void)
 Find the session ID represented by the current thread. More...
 
int thd_find_thread_id (void)
 Find the thread ID represented by the current thread. More...
 
thd_tcb_tthd_get_thread_tcb (void)
 Return the TCB of the current thread. More...
 
void thd_get_ids (int *tid, ses_id_t *sid)
 Return the TID and SID of the current running thread. More...
 
void thd_set_ready (void)
 Netconfd will set thd_ready when initialization is complete, but before creating threads. More...
 
int thd_lock_recursive_log_cs_mutex (void)
 Request lock on recursive logger CS (critical section) mutex. More...
 
int thd_unlock_recursive_log_cs_mutex (void)
 Unlock recursive logger CS (critical section) mutex. More...
 
int thd_lock_ses_sync_mutex (void)
 Request lock on session sync mutex (enforce session synchronization) More...
 
int thd_unlock_ses_sync_mutex (void)
 Unlock session sync mutex (enforce session synchronization) More...
 
int thd_lock_inreadyQ_mutex (ses_id_t sid)
 Request mutex lock for access to the inreadyQ (pending input). More...
 
int thd_unlock_inreadyQ_mutex (ses_id_t sid)
 Unlock mutex for access to the inreadyQ (pending input). More...
 
status_t thd_module_db_rdlock (thd_tcb_t *tcb)
 Request read access to the module DB ("object tree") More...
 
status_t thd_module_db_wrlock (thd_tcb_t *tcb)
 Request write access to the module DB ("object tree"). More...
 
status_t thd_module_db_unlock (thd_tcb_t *tcb)
 Unlock (release access) to the module DB ("object tree"). More...
 
thd_tcb_tthd_get_first_tcb (void)
 Get the first thread control block. More...
 
thd_tcb_tthd_get_next_tcb (thd_tcb_t *tcb)
 Get the next thread control block from the specified entry. More...
 

Detailed Description

Posix threads support for server and client.

Each program has its own hard-wired thread design. Each session (rx_thread) is in its own thread. Other threads are used to maintain the server functions.

Enumeration Type Documentation

◆ thd_tcb_state_t

Thread (tcb) states.

Enumerator
THD_TCB_STATE_NONE 

not set

THD_TCB_STATE_ACTIVE 

active

THD_TCB_STATE_INACTIVE 

Phase 1 cleanup done - ready to reuse.

THD_TCB_STATE_DELETED 

Phase 2 cleanup done - ready to free

◆ thd_type_t

enum thd_type_t

Thread types.

Enumerator
THD_TYPE_NONE 

not set

THD_TYPE_BKGD 

Background.

THD_TYPE_CONN 

Connection.

THD_TYPE_TMR 

Timer.

THD_TYPE_SES 

Session (rx_thread)

THD_TYPE_DUMMY 

Dummy session TCB.

Function Documentation

◆ thd_check_shutdown_signal()

void thd_check_shutdown_signal ( sigset_t *  sigmask,
thd_tcb_t tcb 
)

The agt_shutdown_requested == TRUE at this point.

Need to ensure that the thread received this shutdown signal as well.

Wait and verify that the thread received omnibus signal "THD_SIGNAL" So the cleanup procedure can be started in proper order.

Parameters
sigmasksig mask param
tcbthread control block

◆ thd_cleanup()

void thd_cleanup ( boolean  phase1)

Terminate threads and deallocate associated resources, including thread control blocks.

Phase 1 causes (allows) threads to terminate and deallocates associated resources. Phase 2 removes mutex/lock structure, which must remain in place right to the bitter end (due mostly to logger).

Parameters
phase1Preliminary or final
      THD_CLEANUP_PHASE1 => preliminary
      THD_CLEANUP_PHASE2 => final
Here is the call graph for this function:

◆ thd_clear_locks()

void thd_clear_locks ( thd_tcb_t tcb)

Clear mutexes and RWLOCKs prior to termination.

Parameters
tcbthread control block to clear
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_count_ses_threads()

int thd_count_ses_threads ( void  )

Count the number of session threads.

Returns
number of session threads
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_find_sess_id()

ses_id_t thd_find_sess_id ( void  )

Find the session ID represented by the current thread.

WARNING: Used by logger internally. Do not introduce (recursive) calls back into logger

Returns
corresponding session ID (if any)
Here is the call graph for this function:

◆ thd_find_sess_id_by_handle()

ses_id_t thd_find_sess_id_by_handle ( pthread_t  handle)

Find the session ID represented by the thread handle.

WARNING: Used by logger internally. Do not introduce (recursive) calls back into logger

Parameters
handlethread handle
Returns
corresponding session ID
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_find_tcb_by_capability()

thd_tcb_t * thd_find_tcb_by_capability ( uint  cap)

Find a TCB supporting the specified capability.

Parameters
capdesired capability
Returns
thread control block for capability
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_find_tcb_by_handle()

thd_tcb_t * thd_find_tcb_by_handle ( pthread_t  handle)

Find a thread by its OS pthread handle.

Parameters
handlethread handle
Returns
Thread control block (if any)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_find_tcb_by_sid()

thd_tcb_t * thd_find_tcb_by_sid ( ses_id_t  sid,
boolean  strict 
)

Lookup TCB by session ID.

Parameters
sidsession ID
strictTRUE if strict lookup
Returns
thread control block for session (if any)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_find_tcb_by_type()

thd_tcb_t * thd_find_tcb_by_type ( thd_type_t  type)

Find a TCB supporting the specified type.

Parameters
typedesired type
Returns
tcb thread control block
Here is the call graph for this function:

◆ thd_find_thread_id()

int thd_find_thread_id ( void  )

Find the thread ID represented by the current thread.

WARNING: Used by logger internally. Do not introduce (recursive) calls back into logger

Returns
corresponding thread ID (if any)
Here is the call graph for this function:

◆ thd_get_first_tcb()

thd_tcb_t * thd_get_first_tcb ( void  )

Get the first thread control block.

Returns
pointer to the first tcb in the static thd_tcb_qhdr Queue if found, or NULL if none
Here is the caller graph for this function:

◆ thd_get_ids()

void thd_get_ids ( int *  tid,
ses_id_t sid 
)

Return the TID and SID of the current running thread.

Parameters
[out]tidaddress of return thread ID
  • *tid thread ID (or 0 if main line or -1 if initializing)
[out]sidaddress of return session ID
  • *sid session ID (or 0 if main line or -1 if initializing)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_get_next_tcb()

thd_tcb_t * thd_get_next_tcb ( thd_tcb_t tcb)

Get the next thread control block from the specified entry.

Parameters
tcbthread control block to use
Returns
pointer to the next tcb in the static thd_tcb_qhdr Queue if found, or NULL if none
Here is the caller graph for this function:

◆ thd_get_thread_tcb()

thd_tcb_t * thd_get_thread_tcb ( void  )

Return the TCB of the current thread.

Returns
thread control block (or NULL if error)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_lock_inreadyQ_mutex()

int thd_lock_inreadyQ_mutex ( ses_id_t  sid)

Request mutex lock for access to the inreadyQ (pending input).

Parameters
sidsession id of calling thread
Returns
status
Here is the caller graph for this function:

◆ thd_lock_recursive_log_cs_mutex()

int thd_lock_recursive_log_cs_mutex ( void  )

Request lock on recursive logger CS (critical section) mutex.

Used by logger (invoked for server code only). (See log.h)

◆ thd_lock_ses_sync_mutex()

int thd_lock_ses_sync_mutex ( void  )

Request lock on session sync mutex (enforce session synchronization)

See agt_ncxserver.c: do_processing()

◆ thd_mark_tcb_deleted()

void thd_mark_tcb_deleted ( thd_tcb_t tcb)

Cleanup (release resources associated with a TCB) and free it.

NOTE: This routine should be called ONLY from the thread itself. Third party callers may call only indirectly via thd_cleanup() (i.e., at shutdown).

Parameters
tcbthread control block to clean
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_master_init()

status_t thd_master_init ( void  )

Initialize all mutexes for use by threads.

Returns
result status
Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_module_db_rdlock()

status_t thd_module_db_rdlock ( thd_tcb_t tcb)

Request read access to the module DB ("object tree")

Note: calling thread may block

Parameters
tcbthread to use
Returns
status_t == NO_ERR or error status
Here is the caller graph for this function:

◆ thd_module_db_unlock()

status_t thd_module_db_unlock ( thd_tcb_t tcb)

Unlock (release access) to the module DB ("object tree").

Returns
status: NO_ERR or error status
Here is the caller graph for this function:

◆ thd_module_db_wrlock()

status_t thd_module_db_wrlock ( thd_tcb_t tcb)

Request write access to the module DB ("object tree").

Note: calling thread may block

Parameters
tcbthread to use
Returns
status_t == NO_ERR or error status

◆ thd_new_tcb()

thd_tcb_t * thd_new_tcb ( thd_type_t  type)

Allocate a new thread control block.

Parameters
typethread type (filled in)
Returns
tcb new thread control block
Here is the call graph for this function:

◆ thd_rcv_signal_setup()

boolean thd_rcv_signal_setup ( sigset_t *  sigmask,
thd_tcb_t tcb 
)

Init thread to receive omnibus signal.

Parameters
sigmasksig mask param
tcbthread control block
Returns
TRUE == Successful initialization

◆ thd_set_main_handle()

void thd_set_main_handle ( void  )

Record the thread handle of "main" (running initially before any threads are created) for reference.

This is useful when trying to distinguish a thread from "main" (for example, when displaying logger output).

Here is the caller graph for this function:

◆ thd_set_main_pthread_attr()

void thd_set_main_pthread_attr ( void  )

Set/display main pthread attributes, to be inherited by all threads, unless otherwise noted.

For now, we accept default scheduling. If and when we want to change scheduling characteristics and/or raise process] priorities (dangerous!) we will do it here.

Here is the caller graph for this function:

◆ thd_set_ready()

void thd_set_ready ( void  )

Netconfd will set thd_ready when initialization is complete, but before creating threads.

This helps thd_get_ids() to distinguish between mainline/thread callers and mainline (initialization) callers.

Here is the caller graph for this function:

◆ thd_unlock_inreadyQ_mutex()

int thd_unlock_inreadyQ_mutex ( ses_id_t  sid)

Unlock mutex for access to the inreadyQ (pending input).

Parameters
sidsession id of calling thread
Returns
status
Here is the caller graph for this function:

◆ thd_unlock_recursive_log_cs_mutex()

int thd_unlock_recursive_log_cs_mutex ( void  )

Unlock recursive logger CS (critical section) mutex.

Used by logger (invoked for server code only). (See log.h)

◆ thd_unlock_ses_sync_mutex()

int thd_unlock_ses_sync_mutex ( void  )

Unlock session sync mutex (enforce session synchronization)

See agt_ncxserver.c: do_processing()

◆ thd_yield_for_cdx()

boolean thd_yield_for_cdx ( int  max_yield_count,
uint  usec,
int  ival,
test_cdx_int_t  sid_test_func 
)

Yield scheduler in loop until specified condition(s) are met or max loop count is exceeded.

Optionally interject a (usec) delay.

Parameters
max_yield_countmaximum yield count (return if exceeded)
usecdelay between iterations (may be 0, cannot exceed 1,000,000)
ivalint parameter to pass to test_func
sid_test_funcfunction to test for successful completion
Returns
TRUE == test_func condition detected
FALSE == retry count exceeded, test_func condition not met
Here is the caller graph for this function: