The "mt" Package

These routines are meant to provide management of a pool of threads which may execute concurrently.

Library: karma
Link With: -lkarma

Functions

mt_create_poolCreate a pool of threads which may have jobs launched onto it.
mt_get_shared_poolCreate or get the shared thread pool.
mt_destroy_poolThis routine will destroy a thread pool.
mt_destroy_all_poolsThis routine will destroy all thread pools.
mt_num_threadsGet the number of threads in a thread pool.
mt_launch_jobLaunch a job onto a thread pool.
mt_setlockSet a lock on a thread pool.
mt_new_thread_infoRegister new thread information for the threads in a pool.
mt_get_thread_infoGet the thread information pointer for a pool of threads.
mt_wait_for_all_jobsWait for all previously launched jobs to complete.

Prototype Functions

MT_PROTO_funcPerform a job.


Functions


KThreadPool mt_create_pool (void *pool_info)

Create a pool of threads which may have jobs launched onto it.

Parameters:

Returns: A KThreadPool object on success, else NULL.
Multithreading Level: Safe under Solaris 2.
Note:


KThreadPool mt_get_shared_pool ()

This routine will get a pool of threads which may be shared between several services within a process. This shared pool may be used to reduce the number of thread pools created. Creating large numbers of thread pools may consume significant system resources on some platforms. The first time this routine is called the shared pool is created.

Parameters:

Returns: The shared KThreadPool object on success. On failure the process aborts.
Multithreading Level: Safe under Solaris 2.
Note:


void mt_destroy_pool (KThreadPool pool, flag interrupt)

This routine will destroy a thread pool.

Parameters:

Returns: Nothing.
Multithreading Level: Safe.


void mt_destroy_all_pools (flag interrupt)

This routine will destroy all thread pools.

Parameters:

Returns: Nothing.
Multithreading Level: Safe.


unsigned int mt_num_threads (KThreadPool pool)

This function will determine the number of threads that may be run concurrently in a thread pool.

Parameters:

Returns: The number of concurrent threads.
Multithreading Level: Safe.


void mt_launch_job (KThreadPool pool, void (*func) (void *pool_info, void *call_info1, void *call_info2, void *call_info3, void *call_info4, void *thread_info), void *call_info1, void *call_info2, void *call_info3, void *call_info4)

This function will launch a job to a pool of threads, running the job on the first available thread.

Parameters:

Returns: Nothing.
Multithreading Level: Safe.
Note:


void mt_setlock (KThreadPool pool, flag lock)

This function will lock a thread pool such that no other thread can lock the pool at the same time. This does not prevent other threads from running, nor new jobs from being launched, it merely prevents them from aquiring the lock.

Parameters:

Returns: Nothing.
Multithreading Level: Safe.


void mt_new_thread_info (KThreadPool pool, void *info, uaddr size)

Register new thread information for the threads in a pool.

Parameters:

Returns: Nothing. On failure the process aborts.
Multithreading Level: Safe.


void * mt_get_thread_info (KThreadPool pool)

Get the thread information pointer for a pool of threads.

Parameters:

Returns: A pointer to the thread information array.
Multithreading Level: Safe.


void mt_wait_for_all_jobs (KThreadPool pool)

Wait for all previously launched jobs to complete.

Parameters:

Returns: Nothing.
Multithreading Level: Safe.


Prototype Functions


void MT_PROTO_func (void *pool_info, void *call_info1, void *call_info2, void *call_info3, void *call_info4, void *thread_info)

Perform a job.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


Contact: Richard Gooch
Web Development: Ariel Internet Services