Browse Prior Art Database

Algorithm to Support the Emulation of the UNIX SIGALRM Signal in OS/2

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

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 support for the SIGALRM signal in OS/2*. The emulation of the UNIX** functional environment 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 functions particularly challenging. The functional support for the UNIX SIGALRM signal is one of these.

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

Algorithm to Support the Emulation of the UNIX SIGALRM Signal in OS/2

      Disclosed is an invention which provides an algorithm that can
be used to obtain a very close emulation support for the SIGALRM
signal in OS/2*.  The emulation of the UNIX** functional environment
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 functions particularly challenging.  The functional
support for the UNIX SIGALRM signal 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 signal(SIGALRM,handler) 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 signal(SIGALRM,handler) call.
The algorithm is based on a signal handler function link list data
structure to track the SIGALRM handlers that are installed, an OS/2
event semaphore, an OS/2 thread (SIGALRM thread) that waits on that
event semaphore, and several global variables that are used for
communication between the signal() function and the SIGALRM thread.
These global variables are used for: (1) Pointing to the first
handler list entry.  (2) Storing the OS/2 mutex semaphore id for
serialization of thread access to the handler list.  (3) Storing the
OS/2 event semaphore id used by the SIGALRM thread for waiting for
postings from OS/2 every time the timer installed by the alarm()
emulation expires.  (4) Indicating to the SIGALRM thread that it must
terminate.  (5) Indicating to the SIGALRM thread that a handler has
been reset.

      The algorithm used for the SIGALRM handling thread function
is described in detail in the article describing the alarm() function
emulation.

      The detailed algorithm for an OS/2 emulation of the UNIX
signal(SIGALRM,handler) system call is shown below.
  void ( * signal( int sig, void (* handler)(int) ) )(int) BEGIN
    IF sig parameter is equal to SIGALRM THEN
    BEGIN
      IF this is a reset call (i.e., value of sigalarm_reset global
        variable is 1, as set by the SIGALRM thread function) THEN
      BEGIN
        Return the value of the handler parameter.
      END
      IF the value of the handler parameter is equal to SIG_IGN THEN
      BEGIN
        Set the sigalarm_ignore global variable to 1.
        Return the value of the handler parameter.
  END
  ELSE Set the sigalarm_ignore global variable to 0.
    Try to open the SIGALRM handler li...