Creates a thread object and thread.
cma_thread_create( new_thread, attr, start_routine, arg);
Argument Data Type Accessnew_thread opaque cma_t_thread write attr opaque cma_t_attr read start_routine cma_t_start_routine read arg pointer read
#includevoid cma_thread_create ( cma_t_thread *new_thread, cma_t_attr *attr, cma_t_start_routine start_routine, cma_t_address arg);
function START_ROUTINE ( ARG : in CMA_T_ADDRESS) return CMA_T_ADDRESS;
The same example coded in C, is as follows:
cma_t_address start_routine ( cma_t_address arg);
Calling this routine sets into motion the following actions:
The thread is created in the ready state and therefore might immediately begin executing the function specified by the start_routine argument. The newly created thread will begin running before cma_thread_create completes if the new thread follows the cma_c_sched_rr or cma_c_sched_fifo scheduling policy or has a priority higher than the creating thread, or both. Otherwise, the new thread begins running at its turn, which might also be before cma_thread_create returns.
The start_routine is passed a copy of the arg argument. The value of the arg argument is specified by the calling application code.
The thread object exists until the cma_thread_detach routine is called and the thread terminates, whichever occurs last.
Synchronization between the caller of cma_thread_create and the newly created thread is done through the use of the cma_thread_join routine (or any other mutexes or condition variables they agree to use).
cma_e_existence cma_e_use_error