Create a dynamic thread library on UNIX operating systems

To create a dynamic thread library, you must define routines for every threaded operation that performs and you must register those functions with . The following list shows all of the functions that a multithreaded application requires and describes what each function must do.
mint ifxOS_th_once(ifxOS_th_once_t *pblock, ifxOS_th_initroutine_t pfn, int *init_data)
This routine executes the initialization routine pfn(). Execute the pfn() functions only once, even if they are called simultaneously by multiple threads or multiple times in the same thread. The pfn() routine is equivalent to the DCE pthread_once(), or the POSIX pthread_once() routines.
The init_data variable is used for thread packages that do not have a pthread_once() type routine, such as Solaris Kernel Threads. The routine can be simulated as follows by using init_data as a global variable initialized to 0.
if (!*init_data)
{
      mutex_lock(pblock);
      if (!*init_data)
      {  
         (*pfn)();
         *init_data = 1;
      }
      mutex_unlock(pblock);
}
return(0);
mint ifxOS_th_mutexattr_create(ifxOS_th_mutexattr_t *mutex_attr
This function creates a mutex attributes object that specifies the attributes of mutexes when they are created. The mutex attributes object is initialized with the default value for all of the attributes defined by the implementation of the user. This routine is equivalent to the DCE pthread_mutexattr_create(), or the POSIX pthread_mutexattr_init() routines. If a thread package does not support mutex attribute objects, the mutex attribute routines can be no-ops.
mint ifxOS_th_mutexattr_setkind_np(ifxOS_th_mutexattr_t *mutex_attr, int kind)
This routine sets the mutex type attribute that is used when a mutex is created. The mutex attribute mutex_attr is set to type kind. For DCE, this routine is pthread_mutexattr_setkind_np().
mint ifxOS_th_mutexattr_delete(ifxOS_th_mutexattr_t *mutex_attr)
This routine deletes the mutex attribute object mutex_attr. This routine has the same functionality as the DCE pthread_mutexattr_delete(), or the POSIX pthread_mutexattr_destroy() routines.
mint ifxOS_th_mutex_init(ifxOS_th_mutex_t *mutexp, ifxOS_th_mutexattr_t mutex_attr)
This routine creates a mutex and initializes it to the unlocked state. This routine has the same functionality as the DCE pthread_mutex_init(), or the POSIX pthread_mutex_init() routines.
mint ifxOS_th_mutex_destroy(ifxOS_th_mutex_t *mutexp)
This routine deletes a mutex. The mutex must be unlocked before it is deleted. This routine has the same functionality as the DCE pthread_mutex_destroy(), or the POSIX pthread_mutex_destroy() routines.
mint ifxOS_th_mutex_lock(ifxOS_th_mutex_t *mutexp)
This routine locks an unlocked mutex. If the mutex is already locked, the calling thread waits until the mutex becomes unlocked. This routine has the same functionality as the DCE pthread_mutex_lock(), or the POSIX pthread_mutex_lock() routines.
mint ifxOS_th_mutex_trylock(ifxOS_th_mutex_t *mutexp)
If the mutex is successfully locked, it returns the value 1, if the mutex is locked by another thread, it returns the value 0.

This routine has the same functionality as the DCE pthread_mutex_trylock() routine.

mint ifxOS_th_mutex_unlock(ifxOS_th_mutex_t *mutexp)
This routine unlocks the mutex mutexp. If threads are waiting to lock this mutex, the implementation defines which thread receives the mutex. This routine has the same functionality as the DCE pthread_mutex_unlock(), or the POSIX pthread_mutex_unlock() routines.
mint ifxOS_th_condattr_create(ifxOS_th_condattr_t *cond_attr)
This routine creates an object that is used to specify the attributes of condition variables when they are created. Initialize the object with the default value for all of the attributes defined by the implementation of the user. This routine has the same functionality as the DCE pthread_condattr_create(), or the POSIX pthread_condattr_init() routines.
mint ifxOS_th_cond_init(ifxOS_th_cond_t *condp, ifxOS_th_condattr_t cond_attr)
This routine creates and initializes a condition variable. This routine has the same functionality as the DCE pthread_cond_init(), or the POSIX pthread_cond_init() routines.
mint ifxOS_th_condattr_delete(ifxOS_th_condattr_t *cond_attr)
This routine deletes the condition variable attribute object cond_attr. This routine has the same functionality as the DCE pthread_condattr_delete(), or POSIX pthread_condattr_destroy() routines.
mint ifxOS_th_cond_destroy(ifxOS_th_cond_t *condp)
This routine deletes the condition variable condp. The routine has the same functionality as the DCE pthread_cond_destroy(), or the POSIX pthread_cond_destroy() routines.
mint ifxOS_th_cond_timedwait(ifxOS_th_cond_t *sleep_cond, ifxOS_th_mutex_t *sleep_mutex, ifxOS_th_timespec_t *t)
This routine causes a thread to wait until either the condition variable sleep_cond is signaled or broadcast, or the current system clock time becomes greater than or equal to the time specified in t. The routine has the same functionality as the DCE pthread_cond_timedwait(), or the POSIX pthread_cond_timedwait() routines.
mint ifxOS_th_keycreate(ifxOS_th_key_t *allkey, ifxOS_th_destructor_t AllDestructor)
This routine generates a unique value that identifies a thread-specific data value. This routine has the same functionality as the DCE pthread_keycreate(), or the POSIX pthread_key_create() routines.
mint ifxOS_th_getspecific(ifxOS_th_key_t key, ifxOS_th_addr_t *tcb)
This routine obtains the thread-specific data associated with the key. This routine has the same functionality as the DCE pthread_getspecific(), or the POSIX pthread_getspecific() routines.
mint ifxOS_th_setspecific(ifxOS_th_key_t key, ifxOS_th_addr_t tcb)
This routine sets the thread-specific data in the tcb associated with the key for the current thread. If a value is already defined for key in the current thread, the new value is substituted for the existing value. This routine has the same functionality as the DCE pthread_setspecific(), or the POSIX pthread_setspecific() routines.