Opened 11 years ago

Closed 10 years ago

Last modified 8 years ago

#850 closed bug (fixed)

threaded RTS uses SIGALRM

Reported by: simonmar Owned by: simonmar
Priority: normal Milestone: 6.6.1
Component: Runtime System Version: 6.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The threaded RTS uses SIGALRM for its timer signal, this is a bit naughty and could interfere with use of SIGALRM by the application. Also it can cause EINTR of system calls, which the application might not be prepared to handle. Some system calls can't be reliably restarted (eg. usleep()).

The single threaded RTS uses SIGVTALRM, but we can't use this in the multithreaded RTS because it ticks in CPU time, and our threads might be idle. Ideally we should be using the timer_*() family of functions, if supported.

Change History (6)

comment:1 Changed 10 years ago by simonmar

Priority: normallow

comment:2 Changed 10 years ago by simonmar

Priority: lownormal

Upping priority, as requested by Eelis in #1156

comment:3 Changed 10 years ago by simonmar

Owner: set to simonmar

I'm looking at this

comment:4 Changed 10 years ago by simonmar

Resolution: fixed
Status: newclosed

The problem with usleep() is that it stops with EINTR whenever a signal is received, and there's no way to restart it because it doesn't let you know how much of the original time has expired. The right way these days is to use nanosleep(), so I've added support for that to the unix package:

Fri Mar  2 11:41:18 GMT 2007  Simon Marlow <>
  * don't retry usleep() on EINTR (see #850/#1156)

Fri Mar  2 13:28:18 GMT 2007  Simon Marlow <>
  * Provide nanosleep if we have it, and use it to implement usleep
  Fixes #1156

The SIGALRM question is really orthogonal: usleep will be interrupted by whatever signal we use. However, I've modified the RTS to use timer_create() instead of setitimer() and therefore we now use SIGVTALRM for timer signals on both the threaded and non-threaded RTSs:

Fri Mar  2 03:31:04 PST 2007  Simon Marlow <>
  * Use timer_create() for the interval timer, if available

I'll do the appropriate merging.

comment:5 Changed 8 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:6 Changed 8 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.