cvsuser 04/01/30 04:09:25
Modified: docs/dev events.pod
src events.c
Log:
event-handling-22
* docu updated
* don't broadcast signals to dead interpreters
Revision Changes Path
1.4 +30 -19 parrot/docs/dev/events.pod
Index: events.pod
===================================================================
RCS file: /cvs/public/parrot/docs/dev/events.pod,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- events.pod 16 Dec 2003 13:01:26 -0000 1.3
+++ events.pod 30 Jan 2004 12:09:11 -0000 1.4
@@ -22,8 +22,9 @@
=head1 DESCRIPTION
On construction of the first interpreter (that one with no
-B<parent_interpreter>) an B<event_thread> is started, which manages
-the static global B<event_queue>.
+B<parent_interpreter>) two threads are started: The B<event_thread>,
+which manages the static global B<event_queue> and the B<io_thread>
+which is responsible for signal and IO related events.
=head2 Events
@@ -50,6 +51,25 @@
the entry is duplicated and reinserted with the interval added to the
current time.
+=head2 B<Signals>
+
+All signals that should be handled inside Parrot are blocked in all
+threads and only enabled in the B<io_thread>. The signal handler
+functions just sets an atomic flag, that this signal arrived and
+returns. This finally interrupts the select(2) loop in the
+B<io_thread>.
+
+=head2 The B<io_thread>
+
+The B<io_thread> sleeps in a select(2) loop, which is interrupted,
+when either a signal arrives or when one of the file descriptors has a
+ready condition. Additionally the file descriptor set contains the
+reader end of an internal pipe, which is used by other threads, to
+communicate with the B<io_thread>.
+
+Signal events like SIGINT are broadcasted to all running
+interpreters, which then throw an approprate exception.
+
=head2 The interpreter event checking code
We cannot interrupt the interpreter at arbitrary points and run some
@@ -63,11 +83,14 @@
table is replaced. The switched core does an explicit check if events
are to be handled.
-Prederefed and especially the CGP core are not handled yet. The plan
-is to replace backward branches (and invoke) in the opcode image, with
-the B<check_events__> opcode.
+Prederefed and especially the CGP core don't have an opcode dispatch
+table that is checked during running the opcodes. When an event is
+scheduled, the event handler replaces backward branches in the opcode
+image, with the B<check_events__> opcode.
-After all events are poped off and handled, the opcode dispatch table
+The JIT core doesn't handles events yet.
+
+After all events are popped off and handled, the opcode dispatch table
is restored to its original, and the B<check_events__> reexecutes the
same instruction again, which is now the real one and thus normal
execution flow continues.
@@ -83,24 +106,12 @@
Sync events could be placed directly into the interpreters task queue.
-=item Broadcast events
-
-When there is no interpreter argument for an event, broadcast the event
-to all running interpreters or depeding on the event type, only to the
-first interpreter.
-
=item Async IO
That depends probably on the underlying OS, i.e. if it does async IO
or we have to do it.
-=item timer.pmc
-
-Remove time handling code, use events.
-
-=item Handle event priorities
-
-=item Signals
+=item Event priorities
=item A lot more
1.28 +5 -6 parrot/src/events.c
Index: events.c
===================================================================
RCS file: /cvs/public/parrot/src/events.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -w -r1.27 -r1.28
--- events.c 30 Jan 2004 11:28:10 -0000 1.27
+++ events.c 30 Jan 2004 12:09:25 -0000 1.28
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: events.c,v 1.27 2004/01/30 11:28:10 leo Exp $
+$Id: events.c,v 1.28 2004/01/30 12:09:25 leo Exp $
=head1 NAME
@@ -504,10 +504,8 @@
* handle it
* Finally, we send the first (main) interpreter that signal
*
- * or just send to all?
+ * For now just send to all.
*
- * TODO put first interpreter into interp. array immediately
- * not only when threads are started
*/
switch(event->u.signal) {
case SIGINT:
@@ -516,6 +514,7 @@
for (i = 1; i < n_interpreters; ++i) {
edebug((stderr, "deliver SIGINT to %d\n", i));
interp = interpreter_array[i];
+ if (interp)
Parrot_schedule_interp_qentry(interp,
dup_entry(entry));
}