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

threads

Thread Next
From:
Dave Frost
Date:
September 27, 2005 08:15
Subject:
threads
Message ID:
433961F1.6010603@blueyonder.co.uk
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.

Cheers

Dave


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About