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_num_processorsGet the number of processors available on the system.
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.
mt_get_notify_pipeCreate/get the notification pipe.
mt_disable_notify_pipeDisable the notification pipe.

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.


EXPERIMENTAL FUNCTION: subject to change without notice

unsigned int mt_num_processors ()

Get the number of processors available on the system.

Parameters:

Returns: The number of processors available.
Multithreading Level: Unsafe


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.


EXPERIMENTAL FUNCTION: subject to change without notice

int mt_get_notify_pipe (KThreadPool pool)

This routine gets the read-end of the notification pipe for a thread pool. If the pipe does not yet exist, it is created. Every time a job completes, a byte is written to the write-end of the pipe (if it exists).

Parameters:

Returns: The read-end of the pipe. On failure the process aborts.
Multithreading Level: Safe.
Note:


EXPERIMENTAL FUNCTION: subject to change without notice

void mt_disable_notify_pipe (KThreadPool pool)

Disable the notification pipe.

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


Back to Karma Home Page
Contact: Richard Gooch
Web Development: Ariel Internet Services