Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ locking(2) — A/UX 0.7

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

close(2)

creat(2)

dup(3)

open(2)

read(2)

write(2)



     locking(2)                                             locking(2)



     NAME
          locking - provide exclusive file regions for reading or
          writing

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

     DESCRIPTION
          locking 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.

          fildes is the word returned from a successful open, creat,
          dup, or pipe system call.

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

          size is the number of contiguous bytes to be locked or
          unlocked.  The area to be locked starts at the current
          offset in the file.  If size is zero, the area to the end of
          file is locked.

          The potential for a deadlock occurs when a process
          controlling a locked area is put to sleep by accessing
          another process's locked area.  Thus calls to locking, read,
          or write 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
          single 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
          section. If the lock table is full, an error is returned,
          and the requested area is not released.




     Page 1                                        (last mod. 1/14/87)





     locking(2)                                             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.

          Note that close(2) automatically removes any locks that were
          associated with the closed file descriptor.

     SEE ALSO
          close(2), creat(2), dup(3), open(2), read(2), write(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.  EREMOTE
          will be returned if fildes is a file descriptor that refers
          to file on a remotely mounted file system.




































     Page 2                                        (last mod. 1/14/87)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026