develooper Front page | perl.perl6.internals | Postings from September 2005


Thread Next
Dave Frost
September 27, 2005 08:15
Message ID:
hi all,

Im interested to know how perl6/parrot implements threads.  Im mainly 
interested as im writing a small vm of my own.  Not a production vm like 
parrot, more for interest/curiosity etc.  From the outset i decided i 
wanted the vm to provide its own threading mechanism i.e. not based on 
posix threads for example.  My first plan was to have 2 native threads, 
one for execution of the main 'core' execution code the runtime if you 
like, the other thread was used to tell the execution code to swap 
threads.  I thought i could synchronise these 2 using native 
semaphores.  When it comes down to it a single op code takes a number of 
nastive instructions i.e. to execute an add insttuction i may have to do 
(say) 5 things.  so  I just check after each op code has been executed 
to see if the thread needs swapping out.  That seems like a bad idea 
mainly due to speed/efficiency.  Each thread is a top level object, so 
the stack, all stack pointers and register data etc resides in the 
thread, but i still cant have the execution engine swapping threads mid 
operation, so in my add example i still dont think i would want the 
execution engine swapping out a thread after 3 instructions, it would 
need to complete all 5.

Its been a bit of  a brick wall this, it seemed to be going quite well 
up to this point and i need to solve this before i can move on with 
lwm,(light weight machine).

Any pointers, thoughts or comments are welcome.



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About