C library interface: pthread_create()
CEEOPC creates a new thread in the caller's enclave and in the
context of the current enclave with the specified attribute, attr.
The new thread starts executing the routine at the entry point referred
to by routine_addr with arg as
its sole argument. When the routine returns, thread is implicitly
terminated using the return value of the program as the termination
status. The thread is detached according to the detachstate setting
of the thread attribute specified at thread creation.
Upon successful completion of this function, the thread identifier
of the newly created thread is returned in the location referred to
by thread_id. Other threading functions
may use thread_id as a token in their parameter
lists to refer to the new thread.
Syntax
void CEEOPC (
routine_addr,
[
arg], [
attr],
thread_id,
[
fc]
CEE_ENTRY *routine_addr;
CEE_TOKEN *arg;
CEE_PTAT *attr;
CEE_THDID *thread_id;
FEED_BACK *fc;
- CEEOPC
- Call this CWI interface as follows:
L R15,CEECAALEOV-CEECAA(,R12) CAA address is in R12
L R15,0048(,R15)
BALR R14,R15
- routine_addr (input)
- The entry point of an external routine (not a nested procedure)
that the new thread starts executing.
- arg (input/optional)
- An argument to be passed to the routine at its entry point. Its
type is determined by the requirements of the routine called. This
is the R1 value that is inbound to the target routine.
- attr (input/optional)
- The thread attributes object to be used for the new thread. When attr is
omitted, the default attributes are used.
- thread_id (output)
- The unique thread identifier generated by Language Environment. It is
used to refer to the new thread in other services. The thread identifier
occupies a double word. The exact content of the thread identifier
is not externalized.
- fc (output/optional)
- The feedback code returned by the service. It indicates the degree
of success in creating the new thread.
The following message identifiers and associated severities can
be returned by the service in the feedback code fc.
Condition |
|
CEE000 |
Severity |
0 |
Msg_No |
0000 |
Message |
The service completed successfully. |
CEE5F1 |
Severity |
3 |
Msg_No |
5601 |
Message |
The attributes object parameter did
not contain a valid initialized attributes object (POSIX PTAT). |
CEE5F4 |
Severity |
3 |
Msg_No |
5604 |
Message |
A new thread could not be created
due to some system-detected error with error code <err_code>
and reason code <rsn_code>. |
CEE5F5 |
Severity |
3 |
Msg_No |
5605 |
Message |
There was not enough storage available
to create the new thread. |
Usage Notes: - It is assumed that routine_addr is currently
available and does not require an explicit LOAD performed.
- The new thread starts execution at the external procedure given
in routine_addr and shares the context of
the current enclave.
- The thread shares all resources of the enclave.
- The new thread has access to a new, independent stack. In particular,
a new stack frame zero is provided.
- The new thread inherits the execution priority from its creator.
The size of the stack is determined by the stack size thread attribute.
- The user must serialize use of shared resources, for instance,
external data or arguments.
- Arguments can be passed to the routine to be executed if the routine
is declared to accept them. Output arguments and in/out arguments
can be passed. Since the thread runs asynchronously with the creating
thread, arguments passed by reference become shared variables and
their use should be serialized, if necessary. Since the thread doesn't
return to its creator, output arguments returned by value could be
lost if the storage referred to by the arguments no longer exists.
This might occur if the caller provided automatic storage for the
arguments to the new thread.
- POSIX provides a per-process signal vector and a per-thread signal
mask.
- The thread_id is used to refer to the
thread as input to other services. No other use of thread_id is
allowed.
- Success of thread creation is reported by the fc.
This does not report on success of Language Environment initialization
in the new thread nor the successful execution of the code on the
thread. If the fc is nonzero, thread_id is
not valid. If the fc is zero, the thread_id is
valid and can be used in functions that require thread identifiers.
- The new thread's state is runnable.