yumapro
24.10-3
YumaPro SDK
|
Posix threads support for server and client. More...
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_t * | thd_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_t * | thd_find_tcb_by_handle (pthread_t handle) |
Find a thread by its OS pthread handle. More... | |
thd_tcb_t * | thd_find_tcb_by_capability (uint cap) |
Find a TCB supporting the specified capability. More... | |
thd_tcb_t * | thd_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_t * | thd_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_t * | thd_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_t * | thd_get_first_tcb (void) |
Get the first thread control block. More... | |
thd_tcb_t * | thd_get_next_tcb (thd_tcb_t *tcb) |
Get the next thread control block from the specified entry. More... | |
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.
enum thd_tcb_state_t |
enum thd_type_t |
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.
sigmask | sig mask param |
tcb | thread control block |
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).
phase1 | Preliminary or final |
THD_CLEANUP_PHASE1 => preliminary THD_CLEANUP_PHASE2 => final
void thd_clear_locks | ( | thd_tcb_t * | tcb | ) |
Clear mutexes and RWLOCKs prior to termination.
tcb | thread control block to clear |
int thd_count_ses_threads | ( | void | ) |
Count the number of session threads.
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
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
handle | thread handle |
thd_tcb_t * thd_find_tcb_by_capability | ( | uint | cap | ) |
Find a TCB supporting the specified capability.
cap | desired capability |
thd_tcb_t * thd_find_tcb_by_handle | ( | pthread_t | handle | ) |
Find a thread by its OS pthread handle.
handle | thread handle |
Lookup TCB by session ID.
sid | session ID |
strict | TRUE if strict lookup |
thd_tcb_t * thd_find_tcb_by_type | ( | thd_type_t | type | ) |
Find a TCB supporting the specified type.
type | desired type |
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
thd_tcb_t * thd_get_first_tcb | ( | void | ) |
Get the first thread control block.
void thd_get_ids | ( | int * | tid, |
ses_id_t * | sid | ||
) |
Return the TID and SID of the current running thread.
[out] | tid | address of return thread ID
|
[out] | sid | address of return session ID
|
Get the next thread control block from the specified entry.
tcb | thread control block to use |
thd_tcb_t * thd_get_thread_tcb | ( | void | ) |
Return the TCB of the current thread.
int thd_lock_inreadyQ_mutex | ( | ses_id_t | sid | ) |
Request mutex lock for access to the inreadyQ (pending input).
sid | session id of calling thread |
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)
int thd_lock_ses_sync_mutex | ( | void | ) |
Request lock on session sync mutex (enforce session synchronization)
See agt_ncxserver.c: do_processing()
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).
tcb | thread control block to clean |
status_t thd_master_init | ( | void | ) |
Initialize all mutexes for use by threads.
Request read access to the module DB ("object tree")
Note: calling thread may block
tcb | thread to use |
Unlock (release access) to the module DB ("object tree").
Request write access to the module DB ("object tree").
Note: calling thread may block
tcb | thread to use |
thd_tcb_t * thd_new_tcb | ( | thd_type_t | type | ) |
Allocate a new thread control block.
type | thread type (filled in) |
boolean thd_rcv_signal_setup | ( | sigset_t * | sigmask, |
thd_tcb_t * | tcb | ||
) |
Init thread to receive omnibus signal.
sigmask | sig mask param |
tcb | thread control block |
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).
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.
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.
int thd_unlock_inreadyQ_mutex | ( | ses_id_t | sid | ) |
Unlock mutex for access to the inreadyQ (pending input).
sid | session id of calling thread |
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)
int thd_unlock_ses_sync_mutex | ( | void | ) |
Unlock session sync mutex (enforce session synchronization)
See agt_ncxserver.c: do_processing()
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.
max_yield_count | maximum yield count (return if exceeded) |
usec | delay between iterations (may be 0, cannot exceed 1,000,000) |
ival | int parameter to pass to test_func |
sid_test_func | function to test for successful completion |