Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
SysPoll


NAME

SysPoll - synchronous I/O multiplexing

SYNOPSIS

(* bits for events and revents *)
CONST pollIn =       1H; (* fd is readable *)
CONST pollPri =      2H; (* high priority info at fd *)
CONST pollOut =      4H; (* fd is writable (won't block) *)
CONST pollRdNorm =  40H; (* normal data is readable *)
CONST pollWrNorm = pollOut;
CONST pollRdBand =  80H; (* out-of-band data is readable *)
CONST pollWrBand = 100H; (* out-of-band data is writable *)
CONST pollNorm = pollRdNorm;
CONST pollErr =      8H; (* fd has error condition *)
CONST pollHup =     10H; (* fd has been hung up on *)
CONST pollNval =    20H; (* invalid pollfd entry *)


(* struct pollfd of Solaris 2, see <sys/poll.h> *) TYPE Flags = SYSTEM.INT16; TYPE Entry = POINTER TO EntryRec; TYPE EntryRec = RECORD (Objects.ObjectRec) fd: SysTypes.File; events: Flags; revents: Flags; END; FdSet = POINTER TO FdSetRec; FdSetRec = RECORD (Objects.ObjectRec) END;

PROCEDURE ConvertTimeout(timeout: SysTime.TimeVal) : LONGINT;

PROCEDURE CreateSet(VAR fdset: FdSet); PROCEDURE Incl(fdset: FdSet; entry: Entry); PROCEDURE Card(fdset: FdSet) : INTEGER; PROCEDURE ExamineEntries(fdset: FdSet); PROCEDURE Next(fdset: FdSet; VAR entry: Entry) : BOOLEAN;

PROCEDURE Poll(fdset: FdSet; timeout: LONGINT; VAR ready: INTEGER; errors: RelatedEvents.Object; retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN;

DESCRIPTION

SysPoll interfaces the poll(2) system call. This interface is significantly more efficient and more flexible than the older interface of SysSelect:

ConvertTimeout allows to convert a tuple consisting of seconds and micro seconds (SysTime.TimeVal) into milliseconds. This is the scale that is expected for the timeout value of Poll.

File descriptor sets for Poll are actually linear lists of tuples consisting of a file descriptor, a set of conditions on which Poll should wait for to become true (field events) and a set that is set on return of Poll to those conditions that are actually true (field revents). CreateSet creates a new list of file descriptors that is initially empty. Incl adds the given entry to the list. Card returns the number of entries within fdset. ExamineEntries and Next allow to iterate through a linear list of entries.

Poll waits up to timeout seconds until one of the conditions within fdset is true. If timeout is 0, Poll returns immediately. In case of -1, Poll blocks until one of the conditions is true or the process is interrupted. In the latter case, interrupted is set to TRUE and the call is automatically repeated if retry is TRUE. In case of a successful return, ready is set to the number of file descriptors in fdset for which at least one condition is true.

DIAGNOSTICS

In case of errors, Poll returns FALSE and raises events of SysErrors. The errors parameter is passed to SysErrors.Raise.

The poll system call may be interrupted. Usually (if retry = FALSE), this causes the appropriate error event to be raised (error code SysErrors.intr) and the system call to be aborted. However, if retry is TRUE, the system call will be repeated until no interrupt occurs. interrupt indicates in both cases whether interrupts occurred or not.

SEE ALSO

poll(2)
underlying system call
SysErrors
error handling
SysIO
read and write operations
SysSelect
deprecated interface for synchronous I/O multiplexing
SysSockets
creation and preparation of sockets
UnixFileConditions
conditions which base on SysPoll

Edited by: borchert, last change: 2005/08/25, revision: 1.1, converted to HTML: 2005/08/25

Oberon || Library || Module Index || Search Engine || Definition || Module