Go to the previous, next section.

semget

SYNOPSIS

int semget(key_t key, int nsems, int semflg);

PARAMETERS

key: [in] the semaphore set identificator.

nsems: [in] the number of semaphore in the set.

semflg: [in] flags (see description).

DESCRIPTION

Gets a semaphore set identifier. If key is IPC_PRIVATE, a new set is created. Otherwise, the result depends on the value of semflg:

IPC_CREAT
creates a new queue for the key if it does not already exist.

IPC_EXCL
if there is already a existing queue associated with key, the call fails.

The 9 lower bits of semflg specify the permission bits of the new set. They have the same layout and meaning as those for files. However, the execute permissions are meaningless for sets.

When creating a set the system sets the appropriate parameters in the semid_ds structure associated with the new set. When accessing an already existing set, the system simply check if the set can be accessed.

RETURN VALUE

On success, the call returns the new semaphore set identificator. On error -1 is returned and errno is set to one of the following values:

Go to the previous, next section.