[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


cma_thread_create

Creates a thread object and thread.

Syntax

cma_thread_create(
                   new_thread,
                   attr,
                   start_routine,
                   arg);
 


Argument Data Type Access

new_thread opaque cma_t_thread write attr opaque cma_t_attr read start_routine cma_t_start_routine read arg pointer read


C Binding

#include 

void cma_thread_create ( cma_t_thread *new_thread, cma_t_attr *attr, cma_t_start_routine start_routine, cma_t_address arg);

Arguments

new_thread
Variable that receives a handle for the thread object.
attr
Handle of the attributes object that defines the characteristics of the thread being created. If you specify cma_ c_null, default attributes are used.
start_routine
Function executed as the new thread's start routine. This argument is the address of a routine that takes one argument of type cma_t_address, and returns a value of type cma_t_address.
arg
Address value that is copied and passed to the thread's start routine.

Description

This routine creates a thread object and a thread. The thread routine is a function of type cma_t_start_routine. The function accepts a single argument of type cma_t_address and returns a function value of type cma_t_address. For example, the following routine coded in Ada, is compatible with the cma_t_start_routine type:
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).

Exceptions

cma_e_existence
cma_e_use_error



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]