Threads

Threading.

Summary
ThreadsThreading.
Types
nacore_threadThread identifier.
Functions
nacore_thread_create()Creates a new thread.
nacore_thread_exit()Terminates the calling thread.
nacore_thread_self()Gets an identifier for the calling thread.
nacore_thread_join()Waits for termination of the specified thread.
nacore_thread_equal()Compares two thread identifiers.

Types

nacore_thread

Thread identifier.

It is unspecified whether nacore_thread is a pointer, a structure or whatever.

Two thread identifiers can only be compared using nacore_thread_equal().

Functions

nacore_thread_create()

_NACORE_DEF int nacore_thread_create(nacore_thread *thread,
size_t stack_size,
void (*start_routine)(void *arg),
void *arg)

Creates a new thread.

Parameters

threadMemory location where to put a thread identifier.
sizeStack size for the new thread or 0 to indicate the default stack size.
start_routineFunction to be executed by the new thread.
argArgument to be passed to start_routine or NULL.

Returns

0 on success, ENOMEM if there was not enough memory, EINVAL if the system cannot allocate the requested stack size, EAGAIN if the system lacked the necessary resources or EPERM if the caller does not have appropriate permission.

nacore_thread_exit()

_NACORE_DEF void nacore_thread_exit()

Terminates the calling thread.

nacore_thread_self()

_NACORE_DEF nacore_thread nacore_thread_self()

Gets an identifier for the calling thread.

Returns

Thread identifier for the calling thread.

nacore_thread_join()

_NACORE_DEF int nacore_thread_join(nacore_thread thread)

Waits for termination of the specified thread.

Parameters

threadThread identifier.

Returns

0 on success.  Depending on the platform, in case of error it may return EDEADLK if thread is the calling thread or if a deadlock was detected, EINVAL if the specified thread is not joinable or another thread is already waiting to join with it, ESRCH if no thead corresponding to the given thread identifier was found or NACORE_EUNKNOWN if another kind of error happened.

nacore_thread_equal()

_NACORE_DEF char nacore_thread_equal(nacore_thread t1,
nacore_thread t2)

Compares two thread identifiers.

Parameters

t1First thread identifier.
t2Second thread identifier.

Returns

A nonzero value if the two identifiers indicate the same thread, 0 otherwise.

_NACORE_DEF int nacore_thread_create(nacore_thread *thread,
size_t stack_size,
void (*start_routine)(void *arg),
void *arg)
Creates a new thread.
_NACORE_DEF void nacore_thread_exit()
Terminates the calling thread.
_NACORE_DEF nacore_thread nacore_thread_self()
Gets an identifier for the calling thread.
_NACORE_DEF int nacore_thread_join(nacore_thread thread)
Waits for termination of the specified thread.
_NACORE_DEF char nacore_thread_equal(nacore_thread t1,
nacore_thread t2)
Compares two thread identifiers.
Error code for unknown errors.
Close