Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[CVS ci] parrot-threads-1

0 views
Skip to first unread message

Leopold Toetsch

unread,
Dec 17, 2003, 10:30:34 AM12/17/03
to P6I
getinterp P2
find_method P0, P2, "thread"
find_global P6, "_foo"
clone P5, P2
invoke # start the thread

This little piece of code runs the subroutine "_foo" in a separate
thread inside interpreter P5.

There are of course a lot of things missing, ParrotInterpreter::clone
does only very basic things and so on, but it runs.

Some remarks and thoughts:
1) We have to store the Parrot_thread somewhere - I'm thinking of:
struct thread_data inside the interpreter structure
2) All interpreters get stored in a global Interp_Array, the index being
the user visible thread id for e.g. join.
3) Shared PMCs should probably get their own pmc-pool memory.
4) above code snippet could be one single op:
thread (out INT, in PMC) # run sub $2 threaded, ret thread id in $1

Further pointers and comments are very welcome.

Have fun,
leo

Dan Sugalski

unread,
Dec 22, 2003, 10:41:54 AM12/22/03
to Leopold Toetsch, P6I
At 4:30 PM +0100 12/17/03, Leopold Toetsch wrote:
> getinterp P2
> find_method P0, P2, "thread"
> find_global P6, "_foo"
> clone P5, P2
> invoke # start the thread

I think I'd like to start new threads a bit differently, at least
much more explicitly than an invoke. Invoke on an interpreter
arguably ought to dispatch to the interpreter *without* starting a
new thread.

We also need to work out the details of what and how we clone and
create new interpreters, what gets copied and what doesn't. I see
that thread's already started, though. :)
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Leopold Toetsch

unread,
Dec 22, 2003, 3:42:07 PM12/22/03
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:
> At 4:30 PM +0100 12/17/03, Leopold Toetsch wrote:
>> getinterp P2
>> find_method P0, P2, "thread"
>> find_global P6, "_foo"
>> clone P5, P2
>> invoke # start the thread

> I think I'd like to start new threads a bit differently, at least
> much more explicitly than an invoke. Invoke on an interpreter
> arguably ought to dispatch to the interpreter *without* starting a
> new thread.

Its not invoking the interpreter, the "thread" method of a ParrotThread
is invoked. Actually the example is a bit outdated - the clone is gone
and a new .ParrotThread is instantiated. it should read now or finally:

new P2, .ParrotThread
set S0, "thread" # or better "start" or "run"
find_global P5, "_foo"
set P6, arg1
callmethcc

It should be the same calling sequence as doing a method call on a new
ParrotThread or any other object. But P2/P5 object passing did interfer.

> We also need to work out the details of what and how we clone and
> create new interpreters, what gets copied and what doesn't. I see
> that thread's already started, though. :)

Yep. Currently its the register file to get things running, nothing
more.
"Subject: threads and shared interpreter data structures"
has an example of one of the problems I encountered til now.

leo

0 new messages