# Copyright (C) 2010, Parrot Foundation. # $Id$ =head1 PDD 30: Threads =head2 Abstract This PDD outlines Parrot's design roadmap for parallelism support =head2 Version $Revision$ =head2 Synopsis =item Low level Parrot Threads ParrotThread PMC will be the interface to a OS schedulable entity. ThreadInterpreter PMC will be the actual object that represents a OS schedulable entity. The shared of the heap, subs, arguments, and globals with the parent Interpreter will be configurable with flags. ParrotThread is expected to be a low level abstraction of an OS schedulable entity, over which more user friendly parallelism constructs and pmcs can be created. Because of the degree of sharing between a ParrotThread and its parent is parameterizable, it is expected that direct instanciation of ParrotThreads will generally be restricted from the VM user for security and safety reasons. =item High level Parallelism PMCs Place PMC extends ParrotThread and will be a message passing ONLY interface to a OS schedulable entity. PlaceInterpreter extens ThreadInterpreter PMC. Future PMC extends ParrotThread and will be a fork/join, safe shared memory access to a OS schedulable entity. FutureInterpreter extends ThreadInterpreter PMC. Futures provide safe access (via a restricted runloop) to shared memory by greatly restricting the operations a future can perform. Futures typically only execute arithmetic and function call ops, and only access fixed size containers. When a future attempts to execute a unsafe operation the computation is suspended and executed by the parent interpreter when it "touches" or joins on the spawned future. =item Unsafe OS Threads While the author recommends against the use of general purpose shared memory threads in Parrot, a UnsafeParrotThread PMC can be created that exposes Parrot mutexes, semaphores, condition variables, barriers, to the fearless end user programers. Shared memory threads in a language runtime make ensuring safety(the VM wont crash) essentially impossible. For security and stability reasons I envision UnsafeParrotThread disabled by most users. =item Green Threads GreenThreadPMC will be the interface to a User schedulable entity. GreenThreadInterpreter PMC extends Interpreter will be the actual container of the execution state of the Green Thread. GreenThreads will be scheduled by the concurrency scheduler allowing intra OS schedulable entity concurrency. beginAtomic and endAtomic methods (with a recursive call counter) on GreenThreads will prevent a green thread from being descheduled until end atomic is called for each beginAtomic. =item Process level Parallelism. ForkedProcessPMC will be the interface to a forked process. ExecedProcessPMC extends ForkedProcessPMC and will be the interface to fork execed processes. =item GC Support. When a GC needs to occur, a global flag will be set. OS Schedulable threads will rendezvous at at barrier via the concurrency schedular interrupt mechanism. Once all the OS Schedule threads have rendezvous (stop the world) collection can occur. =item Google Summer of Code 2010 Project. Worker Thread Pool PMCs should be easily build on top of ParrotThread PMCs. Note: Scheduling tasks(Parrot subs) to OS Schedulable threads allows for unsafe behavior that can arbitarily crash the Parrot VM. =over =head2 Dependencies =head2 Definitions =head2 Implementation =head2 Attachments None. =head2 Footnotes None. =head2 References The design has been liberally taken from PLT Scheme which implements all of the above constructs. None. =cut __END__ Local Variables: fill-column:78 End: