Xenomai
3.0.5
|
Cobalt (POSIX) thread management services. More...
Functions | |
int | pthread_create (pthread_t *ptid_r, const pthread_attr_t *attr, void *(*start)(void *), void *arg) |
Create a new thread. More... | |
int | pthread_setmode_np (int clrmask, int setmask, int *mode_r) |
Set the mode of the current thread. More... | |
int | pthread_setname_np (pthread_t thread, const char *name) |
Set a thread name. More... | |
int | pthread_kill (pthread_t thread, int sig) |
Send a signal to a thread. More... | |
int | pthread_join (pthread_t thread, void **retval) |
Wait for termination of a specified thread. More... | |
Cobalt (POSIX) thread management services.
int pthread_create | ( | pthread_t * | ptid_r, |
const pthread_attr_t * | attr, | ||
void *(*)(void *) | start, | ||
void * | arg | ||
) |
Create a new thread.
This service creates a thread managed by the Cobalt core in a dual kernel configuration.
Attributes of the new thread depend on the attr argument. If attr is NULL, default values for these attributes are used.
Returning from the start routine has the same effect as calling pthread_exit() with the return value.
ptid_r | address where the identifier of the new thread will be stored on success; |
attr | thread attributes; |
start | thread start routine; |
arg | opaque user-supplied argument passed to start; |
When creating a Cobalt thread for the first time, libcobalt installs an internal handler for the SIGSHADOW signal. If you had previously installed a handler for such signal before that point, such handler will be exclusively called for any SIGSHADOW occurrence Xenomai did not send.
If, however, an application-defined handler for SIGSHADOW is installed afterwards, overriding the libcobalt handler, the new handler is required to call cobalt_sigshadow_handler() on entry. This routine returns a non-zero value for every occurrence of SIGSHADOW issued by the Cobalt core. If zero instead, the application-defined handler should process the signal.
int cobalt_sigshadow_handler(int sig, siginfo_t *si, void *ctxt);
You should register your handler with sigaction(2), setting the SA_SIGINFO flag.
int pthread_join | ( | pthread_t | thread, |
void ** | retval | ||
) |
Wait for termination of a specified thread.
If thread is running and joinable, this service blocks the caller until thread terminates or detaches. When thread terminates, the caller is unblocked and its return value is stored at the address value_ptr.
On the other hand, if thread has already finished execution, its return value collected earlier is stored at the address value_ptr and this service returns immediately.
This service is a cancelation point for Cobalt threads: if the calling thread is canceled while blocked in a call to this service, the cancelation request is honored and thread remains joinable.
Multiple simultaneous calls to pthread_join() specifying the same running target thread block all the callers until the target thread terminates.
thread | identifier of the thread to wait for; |
retval | address where the target thread return value will be stored on success. |
References pthread_setschedparam().
int pthread_kill | ( | pthread_t | thread, |
int | sig | ||
) |
Send a signal to a thread.
This service send the signal sig to the Cobalt thread thread (created with pthread_create()). If sig is zero, this service check for existence of the thread thread, but no signal is sent.
thread | thread identifier; |
sig | signal number. |
int pthread_setmode_np | ( | int | clrmask, |
int | setmask, | ||
int * | mode_r | ||
) |
Set the mode of the current thread.
This service sets the mode of the calling thread, which affects its behavior under particular circumstances. clrmask and setmask are two masks of mode bits which are respectively cleared and set by pthread_setmode_np():
This service is a non-portable extension of the Cobalt interface.
clrmask | set of bits to be cleared. |
setmask | set of bits to be set. |
mode_r | If non-NULL, mode_r must be a pointer to a memory location which will be written upon success with the previous set of active mode bits. If NULL, the previous set of active mode bits will not be returned. |
int pthread_setname_np | ( | pthread_t | thread, |
const char * | name | ||
) |
Set a thread name.
This service set to name, the name of thread. This name is used for displaying information in /proc/xenomai/sched.
This service is a non-portable extension of the Cobalt interface.
thread | target thread; |
name | name of the thread. |