SyncTypeCreate(), SyncTypeCreate_r()

QNX SDP8.0C Library ReferenceAPIDeveloper

Create a synchronization object

CAUTION:
Don't use the SyncTypeCreate() or SyncTypeCreate_r() kernel call directly. Instead, use the POSIX functions for synchronization objects: pthread_mutex_init() for mutexes and sem_init() for semaphores.

Synopsis:

#include <sys/neutrino.h>

int SyncTypeCreate(
        unsigned type,
        sync_t * sync,
        const struct _sync_attr * attr );

int SyncTypeCreate_r(
        unsigned type,
        sync_t * sync,
        const struct _sync_attr * attr );

Arguments:

type
One of the following:
  • _NTO_SYNC_MUTEX_FREE — create a mutex.
  • _NTO_SYNC_SEM — create a semaphore.
sync
A pointer to a sync_t object that the kernel sets up for the synchronization object; you should treat this as an opaque structure.
attr
A pointer to a _sync_attr structure that specifies attributes for the object. This structure contains at least the following members:
  • int __protocolPTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT.

If attr is NULL, the default attributes (PTHREAD_PRIO_INHERIT) are assumed.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

SyncTypeCreate() and SyncTypeCreate_r() are internal kernel calls that create a synchronization object in the kernel and initialize sync for use in other synchronization kernel calls.

These functions are similar, except for the way they indicate errors; see the Returns section for details.

Synchronization objects can be used for mutexes and semaphores.

Blocking states

These calls don't block.

Returns:

The only difference between these functions is the way they indicate errors:

SyncTypeCreate()
If an error occurs, the function returns -1 and sets errno. Any other value returned indicates success.
SyncTypeCreate_r()
Returns EOK on success. This function does NOT set errno. If an error occurs, the function can return any value in the Errors section.

Errors:

EAGAIN
All kernel synchronization objects are in use.
EFAULT
A fault occurred when the kernel tried to access sync or attr.
EINVAL
Either:
  • the type isn't one of _NTO_SYNC_MUTEX_FREE or _NTO_SYNC_SEM

    Or:

  • if the type is correct, and the synchronization object is:
    • a mutex — the protocol isn't one of PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT.
    • a mutex and PTHREAD_PRIO_PROTECT is specified — the ceiling priority isn't within the kernel priority range.
    • a semaphore — the semaphore value exceeds SEM_VALUE_MAX.

Classification:

QNX OS

Safety:
Cancellation pointNo
Signal handlerYes
ThreadYes
Page updated: