f_pthread_create(thread, attr, flag, ent, arg)

Purpose

This function is used to create a new thread in the current process. The newly created thread will assume the attributes defined in the thread attribute object attr, if it is provided. Otherwise, the new thread will have system default attributes. The new thread will begin execution at the subroutine ent, which is required to have one dummy argument. The system will pass the argument arg to the thread entry subroutine ent as its actual argument. The argument flag is used to inform the system of the property of the argument arg. When the execution returns from the entry subroutine ent, the new thread will terminate automatically.

If subroutine ent was declared such that an explicit interface would be required if it was called directly, then an explicit interface is also required when it is passed as an argument to this function.

The argument arg is a generic argument that can be of any type and any rank. The actual argument arg must be a variable, and consequently eligible as a left- value in an assignment statement. If you pass an array section with vector subscripts to the argument arg, the result is unpredictable.

If the actual argument arg is an array section, the corresponding dummy argument in subroutine ent must be an assumed-shape array. Otherwise, the result is unpredictable.

If the actual argument arg has the pointer attribute that points to an array or array section, the corresponding dummy argument in subroutine ent must have a pointer attribute or be an assumed-shape array. Otherwise, the result is unpredictable.

Class

Function

Argument Type and Attributes

thread
TYPE(f_pthread_t), INTENT(OUT)

On successful completion of the function, f_pthread_create stores the ID of the created thread in the thread.

attr
TYPE(f_pthread_attr_t), INTENT(IN)

flag
INTEGER(4), INTENT(IN)

The argument flag must convey the property of the argument arg exactly to the system. The argument flag can be one of, or a combination of, the following constants:

FLAG_CHARACTER:
if the entry subroutine ent expects an argument of type CHARACTER in any way or any form, this flag value must be included to indicate this fact. However, if the subroutine expects a Fortran 90 pointer pointing to an argument of type CHARACTER, the FLAG_DEFAULT value should be included instead.

FLAG_ASSUMED_SHAPE:
if the entry subroutine ent has a dummy argument which is an assumed-shape array of any rank, this flag value must be included to indicate this fact.

FLAG_DEFAULT:
otherwise, this flag value is needed.

ent
A subroutine that has one dummy argument.

arg
A generic argument that can be of any type, kind, and rank.

Result Type and Attributes

INTEGER(4)

Result Value

On successful completion, this function returns 0. Otherwise, this function returns one of the following errors.

EAGAIN
The system does not have enough resources to create a new thread.

EINVAL
The argument thread, attr, or flag is invalid.

ENOMEM
The system does not have sufficient memory to create a new thread.
IBM Copyright 2003