Opened 8 years ago

Closed 7 years ago

Last modified 6 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: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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 7 years ago by simonmar

  • Priority changed from normal to low

comment:2 Changed 7 years ago by simonmar

  • Priority changed from low to normal

Upping priority, as requested by Eelis in #1156

comment:3 Changed 7 years ago by simonmar

  • Owner set to simonmar

I'm looking at this

comment:4 Changed 7 years ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

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 <simonmar@microsoft.com>
  * don't retry usleep() on EINTR (see #850/#1156)

Fri Mar  2 13:28:18 GMT 2007  Simon Marlow <simonmar@microsoft.com>
  * 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 <simonmar@microsoft.com>
  * Use timer_create() for the interval timer, if available

I'll do the appropriate merging.

comment:5 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:6 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.