DILOCK C-3

NAME

dilock, dilockw, diunlock - lock/unlock RMSfile for inserting records

SYNOPSIS

#include <cbase/dirio.h>

int dilock (fcb)

DFILE *fcb;

int dilockw (fcb)

DFILE *fcb;

int diunlock (fcb)

DFILE *fcb;

DESCRIPTION

Dilock attempts to lock an RMSfile exclusively for inserting a record and returns immediately with a status code. If the RMSfile can be locked for record insertion, dilock returns a positive value. If the RMSfile could not be locked for record insertion, perhaps because it was already locked for insertion by another process, then a zero value is returned. Locking an RMSfile for record insertions does not interfere with locking any existing records for update.

Dilockw attempts to lock an RMSfile exclusively for inserting a record and waits until the RMSfile can be locked for insertion before returning. Dilockw normally returns a positive value.

Diunlock unlocks an RMSfile that was locked for insertions using dilock or dilockw.

Fcb is the file block pointer returned by dlopen(C-3) or dopen(C-3).

These routines must be used in a multi-user environment when calling RMS file functions that insert data records to prevent simultaneous access to data by more than one process. The RMS file functions do not automatically lock files or records to prevent simultaneous insertion of records.

These routines lock the RMSfile so that only one record may be inserted at a time. This prevents two records being inserted simultaneously from occupying the same slot. Locking an RMSfile for record insertions does not interfere with locking existing records for update.

SEE ALSO

dflock(C-3), drlock(C-3), dclock(C-3), dlopen(C-3), dopen(C-3)

Chapter 4,

RMS Programming Guide

DIAGNOSTICS

Dilock and Dilockw return a value of zero (0) if fcb is not an opened file block pointer or if locking the RMSfile for insertion would cause a deadlock.