Browse Prior Art Database

Algorithm to Support the Emulation of UNIX Alarm() System Call in OS/2

IP.com Disclosure Number: IPCOM000114605D
Original Publication Date: 1995-Jan-01
Included in the Prior Art Database: 2005-Mar-29
Document File: 2 page(s) / 85K

Publishing Venue

IBM

Related People

Hidalgo, DS: AUTHOR [+2]

Abstract

Disclosed is an invention which provides an algorithm that can be used to obtain a very close emulation of the alarm() function in OS/2*. The emulation of UNIX** system calls is an accepted approach to porting UNIX C source code to OS/2. The differences between these two operating systems makes the emulation of some UNIX system calls particularly challenging. The alarm() function used in UNIX to send inter-process signals is one of these.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 52% of the total text.

Algorithm to Support the Emulation of UNIX Alarm() System Call in OS/2

      Disclosed is an invention which provides an algorithm that can
be used to obtain a very close emulation of the alarm() function in
OS/2*.  The emulation of UNIX** system calls is an accepted approach
to porting UNIX C source code to OS/2.  The differences between these
two operating systems makes the emulation of some UNIX system calls
particularly challenging.  The alarm() function used in UNIX to send
inter-process signals is one of these.

      An approach used to port program code written for UNIX
platforms to other operating systems such as OS/2 is to emulate the
UNIX system calls in those operating systems, along with all the
necessary semantics of those calls and the necessary header file
definitions expected by the ported source code.  Some UNIX system
calls are easier to emulate in OS/2 than others.  Of particular
interest are the emulation of the UNIX signal related system calls.
The UNIX alarm() system call has no direct correspondence in OS/2.

      This invention provides an algorithm that can be used to obtain
a very close OS/2 emulation of the UNIX alarm() system call that is
used to setup and alarm signal that is continuously issued by the
operating system at the expiration of the seconds interval specified
by the function parameter.  This alarm signal may be fielded by a
function installed by a call to the signal() function with the
SIGALRM parameter.

      The algorithm used by this emulation is based on the use of an
OS/2 event semaphore, the installation of an OS/2 timer that posts
that semaphore every time that timer interval expires, and the
creation of a thread (by the signal(SIGALRM,alrmhdlr) function call)
that waits on that same event semaphore and calls the alrmhdlr()
function when it awakes.

      The alarm() system call emulation only installs the OS/2 timer
the first time it is called, and only one SIGALRM handling thread is
created by signal().  All subsequent calls to alarm() return an OK
code.

      The detailed algorithm for an OS/2 emulation of the UNIX
alarm() system call is shown below.
  unsigned int alarm(unsigned int Seconds ) BEGIN
    A SIGALRM event semaphore must created for use by the OS/2 timer
    function called below.
    IF the SIGALRM event semaphore hasn't been allocated
    (i.e., The SIGALRM event semap...