Ticket #1601: pdd32_parallelism

File pdd32_parallelism, 3.6 KB (added by tewk, 12 years ago)

Parallelism Ideas

Line 
1# Copyright (C) 2010, Parrot Foundation.
2# $Id$
3
4=head1 PDD 30: Threads
5
6=head2 Abstract
7
8This PDD outlines Parrot's design roadmap for parallelism support
9
10=head2 Version
11
12$Revision$
13
14=head2 Synopsis
15
16=item Low level Parrot Threads
17
18ParrotThread PMC will be the interface to a OS schedulable entity.
19ThreadInterpreter PMC will be the actual object that represents a OS schedulable entity.
20The shared of the heap, subs, arguments, and globals with the parent Interpreter will be configurable
21with flags.
22
23ParrotThread is expected to be a low level abstraction of an OS schedulable entity, over which more user
24friendly parallelism constructs and pmcs can be created.
25
26Because of the degree of sharing between a ParrotThread and its parent is parameterizable, it is expected that
27direct instanciation of ParrotThreads will generally be restricted from the VM user for security and safety reasons.
28
29
30=item High level Parallelism PMCs
31
32
33Place PMC extends ParrotThread and will be a message passing ONLY interface to a OS schedulable entity.
34PlaceInterpreter extens ThreadInterpreter PMC.
35
36Future PMC extends ParrotThread and will be a fork/join, safe shared memory access to a OS schedulable entity.
37FutureInterpreter extends ThreadInterpreter PMC.
38
39Futures provide safe access (via a restricted runloop) to shared memory by greatly restricting the operations a future can perform.
40Futures typically only execute arithmetic and function call ops, and only access fixed size containers.
41When a future attempts to execute a unsafe operation the computation is suspended and executed by the parent interpreter when it "touches"
42or joins on the spawned future.
43
44
45=item Unsafe OS Threads
46
47
48While the author recommends against the use of general purpose shared memory threads in Parrot,
49a UnsafeParrotThread PMC can be created that exposes Parrot mutexes, semaphores, condition variables, barriers, to the
50fearless end user programers.
51
52Shared memory threads in a language runtime make ensuring safety(the VM wont crash) essentially impossible.
53For security and stability reasons I envision UnsafeParrotThread disabled by most users.
54
55
56=item Green Threads
57
58GreenThreadPMC will be the interface to a User schedulable entity.
59GreenThreadInterpreter PMC extends Interpreter will be the actual container of the execution state of the Green Thread.
60
61GreenThreads will be scheduled by the concurrency scheduler allowing intra OS schedulable entity concurrency.
62beginAtomic and endAtomic methods (with a recursive call counter) on GreenThreads will prevent a green thread from being descheduled until end
63atomic is called for each beginAtomic.
64
65
66
67=item Process level Parallelism.
68
69ForkedProcessPMC will be the interface to a forked process.
70ExecedProcessPMC extends ForkedProcessPMC and will be the interface to fork execed processes.
71
72=item GC Support.
73
74When a GC needs to occur, a global flag will be set.
75OS Schedulable threads will rendezvous at at barrier via the concurrency schedular interrupt mechanism.
76Once all the OS Schedule threads have rendezvous (stop the world) collection can occur.
77
78
79=item Google Summer of Code 2010 Project.
80
81Worker Thread Pool PMCs should be easily build on top of ParrotThread PMCs.
82Note: Scheduling tasks(Parrot subs) to OS Schedulable threads allows for unsafe behavior that can arbitarily
83crash the Parrot VM.
84
85=over
86
87
88=head2 Dependencies
89
90=head2 Definitions
91
92=head2 Implementation
93
94=head2 Attachments
95
96None.
97
98=head2 Footnotes
99
100None.
101
102=head2 References
103
104The design has been liberally taken from PLT Scheme which implements all of the above constructs.
105
106None.
107
108=cut
109
110__END__
111Local Variables:
112 fill-column:78
113End: