NAME
cthread_fork, cthread_thread_alloc, cthread_thread_schedule
- thread creation routines
LIBRARY
C Threads Library (libcthreads.a)
SYNOPSIS
#include <cthread.h>
cthread_t cthread_fork( any_t (*func)(), any_t arg,
int node);
cthread_t cthread_thread_alloc( any_t (*func)(), any_t arg,
int node);
void cthread_thread_schedule( cthread_t t);
PARAMETERS
func A pointer to the function that the thread is to exe-
cute.
arg a single argument to pass to the function.
node the logical processor where the thread will execute.
t the thread to schedule.
DESCRIPTION
These functions and macros comprise Cthread's thread crea-
tion routines.
cthread_thread_alloc() removes a free thread from the thread
pool and initializes it. The new thread will execute func-
tion func with argument arg and will execute on logical pro-
cessor node. If node is a number between 0 and
(*num_of_procs-1) (inclusive), the thread will run on that
processor number. If node is N_CURRENT, the thread will run
on the current processor. If node is N_ANYWHERE, or if it
is negative or larger than the number of processors avail-
able, the location of the thread will be determined in some
manner by the threads package.
cthread_thread_schedule() takes a thread previously returned
by cthread_thread_alloc() and makes it available for
scheduling. (I.E. causes it to run.) Thread allocation is
made separate from scheduling in order to allow calls to
cthread_set_sched_info(), cthread_set_name(), and
cthread_set_data() to be applied to the new thread after it
is allocated but before it is released. The effect of using
cthread_thread_schedule() on an already scheduled thread is
undefined.
cthread_fork() is a macro. It captures the textual
representation of the func argument and uses it to construct
a default name for the thread. Except for that functional-
ity, cthread_fork(func, arg, node) is just a convenience
that is identical to:
cthread_schedule(cthread_thread_alloc(func, arg, node));
DIAGNOSTICS
Both cthread_thread_alloc() and cthread_fork() will return
NULL if there are no more threads available on the target
processor. See cthread_parse_args() and cthread_configure()
for information on the number of threads available.
SEE ALSO
cthread_intro(3), cthread_set_data(3),
cthread_set_sched_info(3), cthread_set_name(3),
cthread_join(3), cthread_detach(3), cthread_exit(3),
cthread_self(3)
AUTHOR
Cthreads was written and maintained by many people.
This man page written by Greg Eisenhauer.