| |
� ���������� ������ semctl ��������� ������� ���������� ������ ������ ���:
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
int semctl (semid, semnum, cmd, arg)
int semid, cmd;
int semnum;
union semun {
int val;
struct semid_ds *buf;
ushort *array;
} arg;
��������� ���������� ������ semctl � ������ ��������� ���������� ������� ��
������������ ������������ ��������. ��� ������� �� ����� 0, �� ������ ��������
(GETVAL, GETPID, GETNCNT � GETZCNT) �������� ������������. ��� �������������
������ ������ ������������ -1.
��������� semid � semnum ���������� ��������� ��� ��������� �������, ��� ������� ����������� ����������� ��������. � �������� ��������� semid ������ ��������� ������������� ��������� ���������, �������������� ���������� ��� ������ ���������� ������ semget. �������� semnum ������ ����� �������� � ���������. �������� ���������� � ����.
���������� ��������� arg ������� �� ������������ ��������, ������� ������������ ��������� ��������� cmd. ��������� ��������� ��������:
GETVAL
�������� �������� �������� � ������ ��� � �������� ����������.
SETVAL
���������� �������� �������� ������ arg.val.
GETPID
�������� ������������� ��������, ��������� ������������ �������� ��� ���������, � ������ ��� � �������� ����������.
GETNCNT
�������� ����� ���������, ��������� ���������� �������� ��������, � ������ ��� � �������� ����������.
GETZCNT
�������� ����� ���������, ��������� ��������� �������� ��������, � ������ ��� � �������� ����������.
GETALL
��������� �������� ���� ��������� ��������� � ��������� �� � ������, �� ������� ��������� arg.array.
SETALL
���������� �������� ���� ��������� ��������� ������� ��������� ��������� �������, �� ������� ��������� arg.array.
IPC_STAT
��������� ���������� � ��������� ��������� ���������, ������������ � ��������� ������, ��������������� � ��������������� semid, � ���������������� ���������, �� ������� ��������� arg.buf.
IPC_SET
� ��������� ������, ��������������� � ��������������� semid, �������������� �������� ����������� ��������������� ������������ � ������, � ����� ���� �� ��������. ������ �������� ����������� �� ��������� ������, �� ������� ��������� arg.buf.
IPC_RMID
������� �� ������� ������������� semid, ������������� ��������� ��������� � ��������������� � ��� ��������� ������.