It also provides a callback-driven system for applications that may use threads but don't require them. The Globus Thread API is modeled closely after the POSIX threads API.
Applications can choose whether to run as threaded or non-threaded at runtime by either setting the GLOBUS_THREAD_MODEL environment variable or calling the globus_thread_set_model() function prior to activating any Globus modules.
The Globus thread system provides primitives for mutual exclusion (globus_mutex_t, globus_rmutex_t, globus_rw_mutex_t), event synchronization (globus_cond_t), one-time execution (globus_once_t), and threading (globus_thread_t).
In non-threaded operation, globus_cond_wait() and its variants will poll the callback queue and I/O system to allow event-driven programs to run in the absence of threads. The globus_thread_create() function will fail in that model. Other primitive operations will return success but not provide any thread exclusion as there is only one thread.
|
Disable thread cancellation value.
|
|
Enable thread cancellation value.
|
|
Thread Module.
|
|
Thread-specific data destructor.
|
|
Select threading model for an application. The globus_thread_set_model() function selects which runtime model the current application will use. By default, the Globus runtime uses a non-threaded model. Additional models may be available based on system support: pthread, or windows. This function must be called prior to activating any globus module, as it changes how certain functions (like globus_mutex_lock() and globus_cond_wait()) behave. This function overrides the value set by the GLOBUS_THREAD_MODEL environment variable. The globus_thread_set_model() function will fail if a Globus module has been activated already.
|
|
Create a new thread. The globus_thread_create() function creates a new thread of execution in the current process to run the function pointed to by the func parameter passed the user_arg value as its only parameter. This new thread will be detached, so that storage associated with the thread will be automatically reclaimed by the operating system. A thread identifier will be copied to the value pointed by the thread parameter if it is non-NULL. The caller may use this thread identifier to signal or cancel this thread. The attr paramter is ignored by this function. If the "none" threading model is used by an application, then this function will always fail. One alternative that will work both with and without threads is to use the functions in the Globus Callback API .
|
|
Yield execution to another thread. The globus_thread_yield() function yields execution to other threads which are ready for execution. The current thread may continue to execute if there are no other threads in the system's ready queue. |
|
Terminate the current thread. The globus_thread_exit() terminates the current thread with the value passed to it. This function does not return. |
|
Modify the current thread's signal mask. The globus_thread_sigmask() function modifies the current thread's signal mask and returns the old value of the signal mask in the value pointed to by the old_mask parameter. The how parameter can be one of SIG_BLOCK, SIG_UNBLOCK, or SIG_SETMASK to control how the signal mask is modified.
|
|
Send a signal to a thread. The globus_thread_kill() function sends the signal specified by the sig number to the thread whose ID matches the thread parameter. Depending on the signal mask of that thread, this may result in a signal being delivered or not, and depending on the process's signal actions, a signal handler, termination, or no operation will occur in that thread.
|
|
Determine the current thread's ID. The globus_thread_self() function returns the thread identifier of the current thread. This value is unique among all threads which are running at any given time. |
|
Check whether thread identifiers match. The globus_thread_equal() function checks whether the thread identifiers passed as the thread1 and thread2 parameters refer to the same thread. If so, globus_thread_equal() returns GLOBUS_TRUE; otherwise GLOBUS_FALSE.
|
|
Indicate whether the active thread model supports preemption. The globus_thread_preemptive_threads() function returns GLOBUS_TRUE if the current thread model supports thread preemption; othwerise it returns GLOBUS_FALSE. |
|
Determine if threads are supported. The globus_i_am_only_thread() function returns GLOBUS_TRUE if the current thread model is the "none" thread model; GLOBUS_FALSE otherwise. If running with the "none" thread model, there will only be one Globus thread available and the globus_thread_create() function will always fail. |
|
Execute a function with thread cleanup in case of cancellation. The globus_thread_cancellable_func() function provides an interface to POSIX thread cancellation points that does not rely on preprocessor macros. It is roughly equivalent to pthread_cleanup_push(cleanup_func, cleanup_arg); (*func)(arg); pthread_cleanup_pop(execute_cleanup)
|
|
Cancel a thread. The globus_thread_cancel() function cancels the thread with the identifier thr if it is still executing. If it is running with a cancellation cleanup stack, the functions in that stack are executed. The target thread's cancel state determines when the cancellation is delivered.
|
|
Thread cancellation point. The globus_thread_testcancel() function acts as a cancellation point for the current thread. If a thread has called globus_thread_cancel() and cancellation is enabled, this will cause the thread to be cancelled and any functions on the thread's cleanup stack to be executed. This function will not return if the thread is cancelled. |
|
Set the thread's cancellable state. The globus_thread_setcancelstate() function sets the current cancellation state to either GLOBUS_THREAD_CANCEL_DISABLE or GLOBUS_THREAD_CANCEL_ENABLE, do control whether globus_thread_cancel() is able to cancel this thread.
|
about globus |
globus toolkit |
dev.globus
Comments? webmaster@globus.org