Server for Information Technologies

(095) 932-9212, 932-9213, 939-0783
E-mail: info@citforum.ru
(!) CIT Forum CD-ROM

LOCKING(3)
XENIX System V (21 1987)


locking - opye paopye yaco aa e ac

	#include <sys/types.h>
	#include <sys/locking.h>
	
	int locking (fildes, mode, size)
	int fildes, mode;
	long size;


locking ooe poeccy ypa aa aa ae. pye poecc, eae a ca yaco aa, coepa opoae a, yy a o ex op, oa yaco e paopyec acoc o pea ycaoeo opo.

o oo o ycao opoy o e, a oe op e e/ac. o oo o ycao opoy o ac, a oe op ac e/ac. p eoe oo x yco opoa e cac opyec oa EINVAL.

poecc, ea a ca yaco, paee opoa o e ac py poecco (coy pe LK_LOCK LK_NBLCK), ye a ocooe yaca opoa eo poecco.

poecc, ea ca yaco aa, o aopoa o ac py poecco (coy pe LK_RLCK LK_NBRLCK), ye a ocooe yaca opoa eo poecco, a poecc, ea a o yaco, coe o ee.

poecc, ea opoa yaco, coepoe oopoo ye opoao py poecco, ye a, ec pe opo LK_LOCK LK_RLCK, ye opaa ypaee c oo EACCES, ec pe opo LK_NBLCK LK_NBRLCK.

fildes ec oepo opoo aa, opaae oa creat, open, dup pipe.

mode yaae pe opo yaca. Coece coe ae oo apyea ao:
LK_UNLCK 0 Paopye yaco. Tey poecc ocooae yaco, oop o paee opoa.
LK_LOCK 1 opye yaco. Tey poecc ye a ocooe yaca, ec aa-o eo ac opoaa py poecco. B oeo oe yaco opyec ey poecco pye poecc e oy eep a ca o yaco (opoa o e ac).
LK_NBLCK 2 opye yaco. Ec aa-o ac yaca opoaa py poecco, opaaec oa EACCES e oa ocooe opoaoo yaca (opoa e oa).
LK_RLCK 3 Aaoo LK_LOCK a cee oo, o opoa yaco oe ac py poecca (opoa o ac).
LK_NBRLCK 4 Aaoo LK_NBLCK a cee oo, o opoa yaco oe ac py poecca (opoa o ac e oa).

locking ocae aao opyeoo yaca o eye o aa. Ta oceoaeoc oepaopo, opya peye yaco ae, oe ceye:

     fd=open("datafile",O_RDWR);
     lseek(fd,200L,0);
     locking(fd,LK_LOCK,200L);

opoa paopoa eoo aa yo ycao yaae o a aao aa ae cea o locking c size, pa 0.

size aae co oceoaex ao (y yaca), oope opyc paopyc. aco, oop oe opoa, aaec o eye o ae. Ec size pao 0, opyec paopyec ec a (acao o 2 30 cee ao). size oe aaa pay pay a oo aa; o cyae oo poecc, opoa o yaco, oe oya ocy aa yp oo yaca.

Boooc ao opo (ya) oae oa, oa poecc, e opoa yaco, pocaaaec p oe opoa yaco, opoa ye py poecco. ooy y locking(3), read(3) write(3) poep oooc ya pee, e epeec poecc oae. Ec oapyea oooc ya, cpyec oa [EDEADLK] ( [EDEADLOCK]) ece e oec.

opye yaco (ec eo ac) oe coepac paee opoao yace. B o cyae, a ae ec yac cee, yac oec o yaco p yco coacoa peo opo. Ec pe epeceaxc yaco pa, oeee ooo p yoeope oceeo yaaoo pea. Ta opao, ec yaco, opye o ac, coaae ec ac yaca, opoaoo paee e e poecco o e ac, o yaco ye opoa oo o e, a ocaac ac peeo yaca, ec oa ec, ye pooa opoao o e ac. Ha co opyex ae yaco opae e, o ec opaee a oee co opoax yaco ccee. XENIX o opaee pao 200.

apoc a paopoae oe paopoa ooc aco ecoo yaco, opoax a poecco. Ec yac paopyc e ooc, ocaec yac ocac opoa e e poecco. Paopoae cepe yaca po oe yx opoax yaco, .e. oae ooo eea ae opoax yaco. Ec aa ye oa, cpyec oa ece e oec. Paopoa yaco oe oo o poecc, oop eo opoa. Paopoae yaca, oop e opoa, ye paopoa, e eae eo. p aepe poecca ce opoae yac paopyc.

Ec poecc op a oee ooo paa, ce ceae poecco o ae opo yoac p epo ap aa.

peee opo ceaoy ay popaoy aay e opaae o, o p oepax e/ac c ao opoa oppyec. He pe opoy aaoy.

.
creat(3), open(3), read(3), write(3), dup(3), close(3), lseek(3)


B cyae o locking opaae (int)-1. Ec p opoe c peo LK_LOCK LK_RLCK yaco oaaec ye opoa, XENIX System V aoc errno EAGAIN. XENIX 3.0 o cyae aoc errno EACCES. Ec opoa peec aaoy, errno aocc EACCES. Ec ooe y, errno aocc EDEADLK ( EDEADLOCK). Tao e o o aocc p epeoe cceo a opoax yaco.
Comments: info@citmgu.ru
Designed by Andrey Novikov
Copyright © CIT