You copied the Doc URL to your clipboard.

Threads [ALPHA]

The C++ Thread Porting API provides thread function prototypes in the <arm-tpl.h> header file.

Note

This topic describes an [ALPHA] feature. See Support level definitions.

Types

typedef uint32_t __ARM_TPL_thread_id;

struct __ARM_TPL_thread_t {
    uintptr_t data;
};

typedef uint32_t __ARM_TPL_tls_key;

Functions

int __ARM_TPL_thread_create(__ARM_TPL_thread_t* __t, void* (*__f)(void*), void* __arg);
__ARM_TPL_thread_id __ARM_TPL_thread_get_current_id();
__ARM_TPL_thread_id __ARM_TPL_thread_get_id(const __ARM_TPL_thread_t* __t);
int __ARM_TPL_thread_id_compare(__ARM_TPL_thread_id t1, __ARM_TPL_thread_id t2);
int __ARM_TPL_thread_join(__ARM_TPL_thread_t* __t);
int __ARM_TPL_thread_detach(__ARM_TPL_thread_t* __t);
void __ARM_TPL_thread_yield();
void __ARM_TPL_thread_nanosleep(const timespec *req, timespec *rem);
unsigned __ARM_TPL_thread_hw_concurrency();
int __ARM_TPL_tls_create(__ARM_TPL_tls_key* __key, void (*__at_exit) (void*));
void __ARM_TPL_tls_set(__ARM_TPL_tls_key __key, void* __p);
void* __ARM_TPL_tls_get(__ARM_TPL_tls_key __key);

Usage

The C++ Thread Porting API uses the __ARM_TPL_thread_t type to encapsulate a pointer to an underlying platform-specific thread type. The types __ARM_TPL_thread_id and __ARM_TPL_tls_key are identifiers of threads and instances of thread local storage created within the system. The semantics of the functions are:

  • The __ARM_TPL_thread_create() function must initialize __t->data to point to a newly allocated system thread structure. There is no requirement for this initialization to be thread safe. The newly allocated thread must be scheduled to execute the __f routine with __arg as its sole argument.
  • The function __ARM_TPL_thread_get_current_id() must return the thread identifier for the calling thread.
  • The function __ARM_TPL_thread_get_id() must return the corresponding thread identifier for the argument __t.
  • The function __ARM_TPL_thread_id_compare() must return positive if t1 > t2, zero if t1 == t2, and negative if t1 < t2.
  • The function __ARM_TPL_thread_join() must cause the calling thread to block until the thread represented in __t terminates. This function must return zero (success) immediately if __t has already terminated. If the argument __t does not represent a joinable thread or refers to the calling thread itself, this function must return a non-zero value to indicate error. When a thread __t has been joined to, it is guaranteed not to be accessed again. Therefore, any system resources accessible through __t must be reclaimed before returning from this function. All threads are created in a joinable state, calling either __ARM_TPL_thread_join() or __ARM_TPL_thread_detach() on an argument __t makes the thread represented in __t non-joinable.
  • The function __ARM_TPL_thread_detach() should cleanup any system resources accessible through __t while allowing the underlying thread to continue execution. As with __ARM_TPL_thread_join(), invoking this function on an argument __t causes the underlying thread to become non-joinable. This function must return zero on success or non-zero if not successful.
  • The function __ARM_TPL_thread_yield() must force the calling thread to relinquish the processor until it becomes eligible for execution again.
  • The function __ARM_TPL_thread_nanosleep() must cause the calling thread to be blocked for a minimum interval specified by req. The thread might be interrupted due to a signal being delivered to it, in which case either the corresponding signal handler must be invoked or the process must be terminated. When the argument rem is provided (non-null), and the function returns before having the requested time interval elapsed, rem must be populated to indicate the remaining time interval of the original request (time requested – actual time elapsed).
  • The function __ARM_TPL_thread_hw_concurrency() must return the number of concurrent threads supported by the underlying platform. The sole use of this function is for the implementation of the std::hardware_concurrency() function.
  • The __ARM_TPL_tls_create() function must initialize *__key to identify a unique process-wide thread local storage. Upon creation, each __key must be bound to a NULL value, as if __ARM_TPL_tls_set(*__key, NULL) was invoked. Individual threads within the current process might later bind thread specific values to this key using the __ARM_TPL_tls_set() function. There is no requirement for the initialization of *__key to be thread safe. If the __at_exit argument is provided (non-null), and a thread has a non-null binding for that *__key at the point of termination, the system must ensure that __at_exit(void*) is invoked with the current binding for *__key as the sole argument.
  • The function __ARM_TPL_tls_set() must associate the value __p with *__key for the calling thread. It is guaranteed that __key has been obtained using __ARM_TPL_tls_create(). It is also guaranteed that __ARM_TPL_tls_set() will not be invoked from thread-local destructor functions registered in __ARM_TPL_tls_create(). This function must return zero if successful or a non-zero value if not successful.
  • The function __ARM_TPL_tls_get() must return the value bound to the __key argument for the calling thread. It is guaranteed that __ARM_TPL_tls_get() will not be invoked from thread-local destructor functions registered in __ARM_TPL_tls_create().

Returns

These functions must return zero if successful, or return non-zero to indicate an error if not successful.

Was this page helpful? Yes No