1.0.25.44: INTERRUPT-THREAD and timer improvements
authorGabor Melis <mega@hotpop.com>
Mon, 16 Feb 2009 22:16:20 +0000 (22:16 +0000)
committerGabor Melis <mega@hotpop.com>
Mon, 16 Feb 2009 22:16:20 +0000 (22:16 +0000)
commitae09f8fd7765f6cab6ad317a13e27ff22ab0c11e
tree253fdc79b2e8c31ec1d1dd0d01c34611a22eabc6
parent816c50a5589bcf756f67119e657ae348e4858357
1.0.25.44: INTERRUPT-THREAD and timer improvements

The main thing accomplished by this commit is that it's finally
possible to use INTERRUPT-THREAD and TIMERS sanely:

- there is a per thread interruption queue, interruption are executed
  in order of arrival

- the interruption has to explicitly enable interrupts with
  WITH-INTERRUPTS if needed. In the absence of WITH-INTERRUPTS the
  interruption itself is not interrupted and running out of stack is
  not a problem.

- timers have an improved repeat mechanism

Implementation notes:

- INTERRUPT-THREAD is implemented on all platforms and builds (that
  is, even without :SB-THREAD) by sending a signal to the current
  thread (or process without thread). This allows us to hook into the
  normal, interrupt deferral mechanism without having to commit OAOO
  violations on the Lisp side. And it makes threaded, non-threaded
  builds closer, hopefully easing testing.

- SIG_INTERRUPT_THREAD is SIGPIPE on all platforms. SIGPIPE is not
  used in SBCL for its original purpose, instead it's for signalling a
  thread that it should look at its interruption queue. The handler
  (RUN_INTERRUPTION) just returns if there is nothing to do so it's
  safe to receive spurious SIGPIPEs coming from the kernel.

- IN-INTERRUPTION does not unblock deferrables anymore, but arranges
  for them to be unblocked when interrupts are enabled (see
  *UNBLOCK-DEFERRABLES-ON-ENABLING-INTERRUPTS-P*).

- Thread interruption run wrapped in a (WITHOUT-INTERRUPTS
  (ALLOW-WITH-INTERRUPTS ...)).

- Repeating timers reschedule themselves when they finished to the
  current expiry time + repeat interval even if that's in the past.
  Hence, a timer's schedule does not get shifted if it takes a long
  time to run. If it takes more time than the repeat interval then it
  may catch up on later invokations.

- Timers run wrapped in a (WITHOUT-INTERRUPTS (ALLOW-WITH-INTERRUPTS
  ...)) even in run in a new thread.

- Enable previously failing tests.

- Add more tests.

- Automatically unschedule repeating timers if they take up all the
  CPU.
23 files changed:
NEWS
src/code/cold-init.lisp
src/code/early-impl.lisp
src/code/signal.lisp
src/code/target-signal.lisp
src/code/target-thread.lisp
src/code/timer.lisp
src/compiler/generic/parms.lisp
src/runtime/backtrace.c
src/runtime/bsd-os.c
src/runtime/bsd-os.h
src/runtime/darwin-os.h
src/runtime/interrupt.c
src/runtime/interrupt.h
src/runtime/linux-os.c
src/runtime/linux-os.h
src/runtime/sunos-os.c
src/runtime/sunos-os.h
src/runtime/thread.c
src/runtime/win32-os.h
tests/threads.impure.lisp
tests/timer.impure.lisp
version.lisp-expr