I'd like to layout some thougts, which get quite dim, when it comes to
threads. So there are a lot of questions.

1) Exceptions
There are 3 kinds of exception sources:
- hard: e.g. SIGFPE, SIGHUP. They get catched by signal handlers[1]
- soft: internal_exception()
- user: a C<raise> opcode signals a warning or die ...

Parrot does a longjmp(3), constructs an exception object[2], searches
the control stack for a matching exception handler and reenters the run
loop at the exception subroutine if a matching handler was found. If
not, a default catch all handler takes the appropriate action.

pdd06 states:
       Exception handlers are dynamically scoped, and any
       exception handler set in a scope will be removed when that
       scope is exited.
Q: How do we automatically remove exception handlers at scope exit?

2) Events
They are generated by e.g. Timer objects or asynchronous IO. They are
kept in prioritized event queues per thread.

Q: When and how do we check the event queue, iff there is something?

3) Threads
The underlaying model are posix threads if available. This implies
that all interpreter data are shared by default. So we'll need per
thread data: interpreter, prederef & JIT code ...

Q: How do we separate shared and per thread variables?
   On thread creation do we copy all shared PMCs?
   Where are these PMCs living, i.e. do we have one common memory
   arena_base or per thread?
   What about DOD/GC?

Q: Can we use the thread system to run event code (suspend the main
code, run the event handler, resume main code - pthread doesn't seem
to have suspend, while pth(3) has it)

Implementation

Are there any bits already done?


[1] sigaction or signal based. On Win32 the main message loop may also be a source of such events e.g. WM_CLOSE. [2] for now, this might be a PerlHash

leo



Reply via email to