cvs commit: hugs98/src array.c builtin.c connect.h dirprim.c interns.c iomonad.c static.c stmonad.c timeprim.c

ross 2003/01/25 17:03:59 PST Modified files: src array.c builtin.c connect.h dirprim.c interns.c iomonad.c static.c stmonad.c timeprim.c Log: Introduce a definition #define IOArity 2 for the number of arguments (continuations) passed to an IO action, and use it consistently for all IO primitives. This is currently just a cosmetic change, but the plan is to change IOArity to 1 when the unused failure continuation is removed from the IO type. Revision Changes Path 1.7 +17 -17 hugs98/src/array.c 1.45 +6 -6 hugs98/src/builtin.c 1.61 +4 -3 hugs98/src/connect.h 1.15 +13 -13 hugs98/src/dirprim.c 1.9 +4 -4 hugs98/src/interns.c 1.40 +106 -107 hugs98/src/iomonad.c 1.135 +5 -5 hugs98/src/static.c 1.9 +4 -4 hugs98/src/stmonad.c 1.8 +15 -15 hugs98/src/timeprim.c

Ross:
#define IOArity 2
From the sound of it, you're redoing the IO monad and that means changes to the concurrency code.
Just want to be sure to point out that, because we don't have preemptive concurrency, changes to the order threads get scheduled can cause previously working code to deadlock. So, please be very careful to check that concurrency is still useful. At a minimum this means that it is still possible to write code which implements the producer-consumer pattern. Better yet, the producer-consumer testcase in the testsuite would work unchanged. Better yet, the HGL would work unchanged. Better yet, the scheduling order would be completely unaffected (there are some tests for this in the testsuite). (The above ought to be unnecessary to say but changes to the scheduler are a large part of part of what went wrong when Hugs and the HGL were incompatible for so long a year or two back.) -- Alastair

On Fri, Jan 31, 2003 at 06:10:22PM +0000, Alastair Reid wrote:
Ross:
#define IOArity 2
From the sound of it, you're redoing the IO monad and that means changes to the concurrency code.
I haven't touched the scheduling logic, I think. It already handled non-deterministic exceptions (HugsException) -- I just changed that to Exception. And the IOError continuations are gone, because they are now subsumed by Exceptions. All of the test suite still works (except for known export and Ratio bugs). One thing I did change was to switch exitWith to the System.Exit definition, i.e. throw an ExitException. forkIO catches all exceptions in the other thread and prints them, as before, but now exit is also an exception. I did break greencard and hdirect (they assume IO takes 2 continuations), but Sigbjorn has a fix for that.

ps If you are contemplating significant changes to the concurrency code, there's a minor issue which it would be nice to fix while in there. At present, there are separate thread queues for 'main' and for each invocation of 'unsafePerformIO'. This means that any threads spawned while running in 'unsafePerformIO' must complete (or block) before unsafePerformIO returns and any runnable threads spawned 'outside' the unsafePerformIO will not be scheduled until the unsafePerformIO completes. I think that it would be better to have a single queue of runnable threads. -- Alastair
participants (3)
-
Alastair Reid
-
Ross Paterson
-
ross@glass.cse.ogi.edu