[net.unix-wizards] Hark back to olden days, and Slibc.a...

ignatz@ihuxx.UUCP (Dave Ihnat, Chicago, IL) (08/29/84)

Hi, folks.

Well, I guess it's my turn to ask for aid.  I'm helping our a friend
with an altos86 running a v7-derivative Unix(Tm, etc.) system.  In the course
of trying to chivvy the 'C' compiler/assembler/linker to actually honor valid
'C' code, I ran into a reputedly multiply-defined symbol: 'locking' (_locking to
the assembler).  This appeared in a library living as '/lib/Slibc.a'.

Ok. I give.  If this isn't some arcane porting change by Altos, then I'm
dipping into depths of Unix library antiquity that predate my association
with our fine system.  Does anyone know, in order:

	1) Whatinhell was Slibc.a?
	2) Whatinhell was the routine 'locking',
		and how should I have used it?

Eagerly awaiting info from my ancestors on the Unix system,
	(actually, I really would like an answer!),

	Dave Ihnat
	ihuxx!ignatz
	(w) (312) 979-0946
	(w) (312) 784-4544

fair@dual.UUCP (Erik E. Fair) (09/01/84)

Slibc.a is probably an Altos hack, however, I know what ``locking''
is probably about:

Locking is a file locking system call, which is found in UniSoft ports
of V7, sIII, and sV. It is a forced locking system (anyone else trying
to touch the file you just locked will sleep() until you unlock it),
and was originally written by John Bass <dual!dmsd!bass> (formerly of
Onyx and Fortune, now of DMSD) at Onyx. I believe it is part of the
proposed /usr/group standard of UNIX. One of the reasons it is found in
so many ports of Unix to microcomputer systems is that Ryan McFarlane
COBOL needs it, and crufty as it is, most people are using RM/COBOL...

	Erik E. Fair	ucbvax!fair	fair@ucb-arpa.ARPA

	dual!fair@BERKELEY.ARPA
	{ihnp4,ucbvax,hplabs,decwrl,cbosgd,sun,nsc,apple,pyramid}!dual!fair
	Dual Systems Corporation, Berkeley, California

Here is the man page from a DUAL v7 system in house:


LOCKING(2)          UNIX Programmer's Manual           LOCKING(2)



NAME
     locking - provide exclusive file regions for reading or
     writing

SYNOPSIS
     locking(fildes, mode, size)
     int fildes;
     int mode;
     int size;

DESCRIPTION
     _L_o_c_k_i_n_g will allow a specified number of bytes to be
     accessed only by the locking process. Other processes which
     attempt to lock, read, or write the locked area will sleep
     until the area becomes unlocked.

     _F_i_l_d_e_s is the word returned from a successful _o_p_e_n, _c_r_e_a_t,
     _d_u_p, or _p_i_p_e system call.

     _M_o_d_e is zero to unlock the area.  _M_o_d_e is one or two for
     making the area locked. If the _m_o_d_e is one, and the area has
     some other lock on it, then the process will sleep until the
     entire area is available. If the _m_o_d_e is two, and the area
     is locked, an error will be returned.

     _S_i_z_e is the number of contigous bytes to be locked or
     unlocked.  The area to be locked starts at the current
     offset in the file.  If _s_i_z_e is zero the area to end of file
     is locked.

     The potential for a deadlock occurs when a process control-
     ling a locked area is put to sleep by accessing another
     processes locked area.  Thus calls to _l_o_c_k_i_n_g, _r_e_a_d, or
     _w_r_i_t_e scan for a deadlock prior to sleeping on a locked
     area.  An error return is made if sleeping on the locked
     area would cause a deadlock.

     Lock requests may, in whole or part, contain or be contained
     by a previously locked area for the same process.  When this
     or adjacent areas occur, the areas are combined into a sin-
     gle area.  If the request requires a new lock element with
     the lock table full, an error is returned, and the area is
     not locked.

     Unlock requests may, in whole or part, release one or more
     locked regions controlled by the process. When regions are
     not fully released, the remaining areas are still locked by
     the process.  Release of the center section of a locked area
     requires an additional lock element to hold the cut off sec-
     tion. If the lock table is full, an error is returned, and
     the requested area is not released.




Printed 11/10/82                                                1






LOCKING(2)          UNIX Programmer's Manual           LOCKING(2)



     While locks may be applied to special files or pipes,
     read/write operations will not be blocked.  Locks may not be
     applied to a directory.

SEE ALSO
     open(2), creat(2), read(2), write(2), dup(2), close(2)

DIAGNOSTICS
     The value -1 is returned if the file does not exist, or if a
     deadlock using file locks would occur.  EACCES will be
     returned for lock requests in which the area is already
     locked by another process. EDEADLOCK will be returned by:
     read, write, or locking if a deadlock would occur. EDEADLOCK
     will also be returned when the locktable overflows.

ASSEMBLER
     movl #45,D0
     movl fildes,A0
     movl mode,D1
     movl size,A1
     trap #0

     Carry bit cleared on success.


Printed 11/10/82                                                2