#include <rtl_sched.h> int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); |
This function is an RTLinux version of standard POSIX threads function. pthread_create creates a realtime thread that will have attributes given by attr, and that begins executing function start_routine(arg ). If the attribute is NULL, default attributes are used. The thread attributes in RTLinux are extended to allow thread creation on specific processors (pthread_attr_setcpu_np), to enable FPU operations in the created thread (pthread_attr_setfp_np).
The standard thread attribute setting functions supported include pthread_attr_setschedparam, pthread_attr_setdetachstate, pthread_attr_setstacksize, pthread_attr_setstackaddr. The last call is to allow users to allocate memory for thread stacks -- so that threads can be created in RT operating mode by making use of pre-allocated memory. pthread_join should be used to synchronize freeing of thread resources including memory. For example if a thread is created with user allocated stack via pthread_attr_setstackaddr, that memory can only be safely reallocated after a pthread_join.
Either not enough memory, or PTHREAD_THREADS_MAX would be exceeded, or pthread_create is called from RT-thread context and preallocated stack use is not specified.
Bad attributes.
In the absense of preallocated stack (via pthread_attr_setstackaddr), the use of this function is restricted to the Linux init_module() or cleanup_module() context.
©2001 FSMLabs Inc.
All rights reserved.