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


Ulm's Oberon Library:
SysSelect


NAME

SysSelect - synchronous I/O multiplexing

SYNOPSIS

TYPE FileDescriptorSet = RECORD (Objects.ObjectRec) END;
VAR emptyset: FileDescriptorSet;
PROCEDURE CreateSet(VAR fdset: FileDescriptorSet);
PROCEDURE Incl(VAR fdset: FileDescriptorSet; fd: SysTypes.File);
PROCEDURE Excl(VAR fdset: FileDescriptorSet; fd: SysTypes.File);
PROCEDURE In(fdset: FileDescriptorSet; fd: SysTypes.File) : BOOLEAN;
PROCEDURE SelectWithTimeLimit(
             VAR readfds, writefds, exceptfds: FileDescriptorSet;
             timeout: SysTime.TimeVal; VAR ready: INTEGER;
             errors: RelatedEvents.Object;
             retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN;
PROCEDURE Select(VAR readfds, writefds, exceptfds: FileDescriptorSet;
                 VAR ready: INTEGER;
                 errors: RelatedEvents.Object;
                 retry: BOOLEAN; VAR interrupted: BOOLEAN) : BOOLEAN;
PROCEDURE Poll(VAR readfds, writefds, exceptfds: FileDescriptorSet;
               VAR ready: INTEGER;
               errors: RelatedEvents.Object) : BOOLEAN;
PROCEDURE InputAvailable(fd: SysTypes.File;
                         errors: RelatedEvents.Object) : BOOLEAN;

DESCRIPTION

SysSelect interfaces the select(2) system call. This interface is now deprecated. SysPoll should be used instead.

SysSelect allows to examine sets of file descriptors whether they are ready for reading or writing or if exceptional conditions are pending. Further, the process can be blocked until one of the given file descriptors becomes ready for the intended operation.

File descriptor sets are completely covered by SysSelect because the size of file descriptor sets is not known in advance (and may even vary at runtime). CreateSet creates a new set and initializes it to the empty set. Incl and Excl allow to include and exclude individual members. In checks fd to be a member of fdset.

SelectWithTimeLimit returns either if the time limit expires (ready = 0) or if at least one of the file descriptors gets ready (in this case ready equals the number of ready file descriptors). Poll works like SelectWithTimeLimit with a time limit of 0.

Select blocks until one of the file descriptors gets ready (no time limit). InputAvailable returns TRUE if a subsequent SysIO.Read does not block.

DIAGNOSTICS

System call errors cause FALSE to be returned and lead to events of SysErrors. The errors parameter is passed to SysErrors.Raise.

The longtime variants of the 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

select(2)
underlying system call
SysErrors
error handling
SysIO
read and write operations
SysPoll
newer interface for synchronous I/O multiplexing
SysSockets
creation and preparation of sockets

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

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