Skip to content
Newer
Older
100644 379 lines (235 sloc) 8.28 KB
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
1 /*
9c10771 @rurban [pmc2c] inline gc write barriers into vtable methods
rurban authored Mar 19, 2014
2 Copyright (C) 2001-2014, Parrot Foundation.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
3
4 =head1 NAME
5
0385383 @rurban [docs] Fix pmc NAME
rurban authored Jun 15, 2014
6 src/pmc/scheduler.pmc - Scheduler PMC
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
7
8 =head1 DESCRIPTION
9
0385383 @rurban [docs] Fix pmc NAME
rurban authored Jun 16, 2014
10 Access to the core concurrency scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
11
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
12 =head2 Vtable Functions
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
13
14 =over 4
15
16 =cut
17
18 */
19
ec73fb3 @allisonrandal [concurrency] Divide scheduler headers into public and private (for c…
allisonrandal authored Dec 6, 2007
20 #include "parrot/scheduler_private.h"
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
21
6bdd5f9 @petdance headerizer now runs on PMC files
petdance authored Mar 28, 2010
22 /* HEADERIZER HFILE: none */
23 /* HEADERIZER BEGIN: static */
24 /* HEADERIZER END: static */
25
6b81760 @Whiteknight [pmc] we don't need need_ext anymore, so BALEETED
Whiteknight authored Aug 23, 2009
26 pmclass Scheduler auto_attrs {
f29b241 @niner Keep a list of foreign tasks
niner authored Mar 2, 2012
27 ATTR INTVAL id; /* The scheduler's ID. */
28 ATTR PMC *handlers; /* The list of currently active handlers. */
29 ATTR PMC *messages; /* A message queue used for communication
30 between schedulers. */
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
31
f29b241 @niner Keep a list of foreign tasks
niner authored Mar 2, 2012
32 ATTR PMC *task_queue; /* List of tasks/green threads waiting to run */
33 ATTR PMC *foreign_tasks; /* List of tasks/green threads waiting to run */
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
34 ATTR Parrot_mutex task_queue_lock;
f29b241 @niner Keep a list of foreign tasks
niner authored Mar 2, 2012
35 ATTR PMC *alarms; /* List of future alarms ordered by time */
fb0dfd8 @NatTuck Progress on alarms / timers.
NatTuck authored Jun 30, 2010
36
f29b241 @niner Keep a list of foreign tasks
niner authored Mar 2, 2012
37 ATTR PMC *all_tasks; /* Hash of all active tasks by ID */
38 ATTR UINTVAL next_task_id; /* ID to assign to the next created task */
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
39
f29b241 @niner Keep a list of foreign tasks
niner authored Mar 2, 2012
40 ATTR Parrot_Interp interp; /* A link to the scheduler's interpreter. */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
41
42 /*
43
44 =item C<void init()>
45
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
46 Initializes a concurrency scheduler object.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
47
48 =cut
49
50 */
51
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
52 VTABLE void init() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
53 Parrot_Scheduler_attributes * const core_struct =
5a7584e @NotFound merge auto_attrs branch into trunk
NotFound authored Aug 18, 2009
54 (Parrot_Scheduler_attributes *) PMC_data(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
55
1997c49 @cotto [gc] remove/replace DOD references in core PMCs
cotto authored Feb 12, 2009
56 /* Set flags for custom GC mark and destroy. */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
57 PObj_custom_mark_SET(SELF);
4591dbb @chromatic [HLL] Fixed two compilation-breaking typos accidentally committed in …
chromatic authored Sep 3, 2009
58 PObj_custom_destroy_SET(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
59
60 /* Set up the core struct. */
f29b241 @niner Keep a list of foreign tasks
niner authored Mar 2, 2012
61 core_struct->id = 0;
33a45e3 @Whiteknight A few small cleanups to scheduler and schedulermessage PMCs. No funct…
Whiteknight authored Aug 9, 2012
62 core_struct->next_task_id = 0;
63 core_struct->interp = INTERP;
64
65 /* TODO: Do we need to eagerly create all these PMCs, or can we create
66 them lazily on demand? */
f29b241 @niner Keep a list of foreign tasks
niner authored Mar 2, 2012
67 core_struct->handlers = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
68 core_struct->messages = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
69 core_struct->task_queue = Parrot_pmc_new(INTERP, enum_class_PMCList);
65e2704 @niner Fix the wait op for threads
niner authored Mar 25, 2012
70 core_struct->foreign_tasks = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
f29b241 @niner Keep a list of foreign tasks
niner authored Mar 2, 2012
71 core_struct->alarms = Parrot_pmc_new(INTERP, enum_class_PMCList);
72 core_struct->all_tasks = Parrot_pmc_new(INTERP, enum_class_Hash);
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
73
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
74 MUTEX_INIT(core_struct->task_queue_lock);
75
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
76 /* Chandon TODO: Delete from int-keyed hash doesn't like me. */
77 /* VTABLE_set_integer_native(interp, core_struct->all_tasks, Hash_key_type_int); */
78
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
79 }
80
81 /*
82
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
83 =item C<void init_pmc(PMC *data)>
84
85 Initializes a new Scheduler with a C<Hash> PMC with any or all of the keys:
86
87 =over 4
88
89 =item C<id>
90
91 An C<Integer> representing the unique identifier for this scheduler.
92
93 =back
94
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
95 =cut
96
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
97 */
98
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
99 VTABLE void init_pmc(PMC *data) {
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
100 PMC *elem;
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
101 Parrot_Scheduler_attributes *core_struct;
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
102
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
103 if (!VTABLE_isa(INTERP, data, CONST_STRING(INTERP, "Hash")))
ac932da @rurban Use new Parrot_ex_throw_from_c_noargs, simplify some PMCs
rurban authored Nov 11, 2014
104 Parrot_ex_throw_from_c_noargs(INTERP, EXCEPTION_INVALID_OPERATION,
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
105 "Scheduler initializer must be a Hash");
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
106
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
107 SELF.init();
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
108
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
109 core_struct = PARROT_SCHEDULER(SELF);
110 elem = VTABLE_get_pmc_keyed_str(INTERP, data, CONST_STRING(INTERP, "id"));
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
111
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
112 if (!PMC_IS_NULL(elem))
113 core_struct->id = VTABLE_get_integer(INTERP, elem);
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
114 }
115
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
116
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
117 /*
118
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
119 =item C<void push_pmc(PMC *value)>
120
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
121 Inserts a task into the task list.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
122
123 =cut
124
125 */
126
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
127 void push_pmc(PMC *task) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
128 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
129
130 LOCK(core_struct->task_queue_lock);
131 VTABLE_push_pmc(INTERP, core_struct->task_queue, task);
132 UNLOCK(core_struct->task_queue_lock);
133 }
134
135
136 /*
137
138 =item C<void unshift_pmc(PMC *value)>
139
140 Inserts a task into the head of the task list.
141
142 =cut
143
144 */
145
146 void unshift_pmc(PMC *task) {
147 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
148
149 LOCK(core_struct->task_queue_lock);
150 VTABLE_unshift_pmc(INTERP, core_struct->task_queue, task);
151 UNLOCK(core_struct->task_queue_lock);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
152 }
153
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
154
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
155 /*
156
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
157 =item C<PMC *shift_pmc()>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
158
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
159 Retrieves the next task from the task list.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
160
161 =cut
162
163 */
164
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
165 VTABLE PMC *shift_pmc() {
9ddac31 @Whiteknight cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix …
Whiteknight authored Oct 28, 2011
166 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
167 PMC * task;
168
169 LOCK(core_struct->task_queue_lock);
170 task = VTABLE_shift_pmc(INTERP, core_struct->task_queue);
171 UNLOCK(core_struct->task_queue_lock);
172
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
173 return task;
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
174 }
175
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
176
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
177 /*
178
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored Dec 2, 2007
179 =item C<INTVAL get_integer()>
180
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
181 Retrieves the number of pending tasks in the scheduler's task list.
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored Dec 2, 2007
182
183 =cut
184
185 */
186
fb14814 @rurban [pmc] Fixup most WBs. :no_wb for all non-writers, ... [1/2]
rurban authored May 30, 2014
187 VTABLE INTVAL get_integer() :no_wb {
fd1a800 @petdance removed unused var task_id_str. Consted a pointer, and marked an inte…
petdance authored Oct 18, 2011
188 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
04717ae @niner Move all access to task_queue to scheduler.pmc and protect by a lock
niner authored Nov 12, 2011
189 INTVAL elements;
190
191 LOCK(core_struct->task_queue_lock);
192 elements = VTABLE_elements(INTERP, PARROT_SCHEDULER(SELF)->task_queue);
193 UNLOCK(core_struct->task_queue_lock);
194
195 return elements;
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
196 }
197
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
198
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
199 /*
200
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
201 =item C<void destroy()>
202
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
203 Frees the scheduler's underlying struct.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
204
205 =cut
206
207 */
37f7521 @ZYROz [pmc] Improved WBs [a-z]*.pmc
ZYROz authored Jun 8, 2014
208 VTABLE void destroy() :no_wb {
847cb9b @rurban [GH #836] Cleaned wrong UNUSED(arg) macros in all pmc's
rurban authored Sep 24, 2012
209 UNUSED(INTERP)
97eac13 @rurban [cage] Add remaining missing UNUSED(arg) declarations from pmc
rurban authored Dec 11, 2012
210 UNUSED(SELF)
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
211 }
212
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
213
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
214 /*
215
216 =item C<void mark()>
217
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
218 Marks any referenced strings and PMCs as live.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
219
220 =cut
221
222 */
fb14814 @rurban [pmc] Fixup most WBs. :no_wb for all non-writers, ... [1/2]
rurban authored May 30, 2014
223 VTABLE void mark() :no_wb {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
224 if (PARROT_SCHEDULER(SELF)) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
225 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
226
26914e1 changed interp in pmc class to INTERP for unification
Jimmy Zhuo authored May 5, 2010
227 Parrot_gc_mark_PMC_alive(INTERP, core_struct->handlers);
228 Parrot_gc_mark_PMC_alive(INTERP, core_struct->messages);
9f3e20d @NatTuck [gsoc_threads] Alarms work, at least the easy way.
NatTuck authored Jul 1, 2010
229 Parrot_gc_mark_PMC_alive(INTERP, core_struct->task_queue);
f29b241 @niner Keep a list of foreign tasks
niner authored Mar 2, 2012
230 Parrot_gc_mark_PMC_alive(INTERP, core_struct->foreign_tasks);
9f3e20d @NatTuck [gsoc_threads] Alarms work, at least the easy way.
NatTuck authored Jul 1, 2010
231 Parrot_gc_mark_PMC_alive(INTERP, core_struct->alarms);
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
232 Parrot_gc_mark_PMC_alive(INTERP, core_struct->all_tasks);
5d8728e @NatTuck [gsoc_threads] Fix some failing tests.
NatTuck authored Jul 2, 2010
233 }
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
234 }
235
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
236
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
237 /*
238
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
239 =item C<void visit(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
240
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
241 Visits the contents of the scheduler (used by freeze/thaw).
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
242
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
243 C<*info> is the visit info (see F<include/parrot/pmc_freeze.h>).
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
244
245 =cut
246
247 */
248
37f7521 @ZYROz [pmc] Improved WBs [a-z]*.pmc
ZYROz authored Jun 7, 2014
249 VTABLE void visit(PMC *info) :no_wb {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
250 /* 1) visit task list */
62b52c9 @NatTuck [gsoc_threads] Added callback PMC to handle NCI.
NatTuck authored Jul 4, 2010
251 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, task_queue);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
252
253 /* 2) visit the handlers */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
254 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, handlers);
62b52c9 @NatTuck [gsoc_threads] Added callback PMC to handle NCI.
NatTuck authored Jul 4, 2010
255
256 /* 3) visit the alarms */
257 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, alarms);
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
258
259 /* 3) visit all tasks */
260 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, all_tasks);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
261 }
262
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
263
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
264 /*
265
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
266 =item C<void freeze(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
267
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
268 Archives the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
269
270 =cut
271
272 */
273
37f7521 @ZYROz [pmc] Improved WBs [a-z]*.pmc
ZYROz authored Jun 7, 2014
274 VTABLE void freeze(PMC *info) :no_wb {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
275 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
276
277 /* 1) freeze scheduler id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
278 VTABLE_push_integer(INTERP, info, core_struct->id);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
279 }
280
281 /*
282
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
283 =item C<void thaw(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
284
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
285 Unarchives the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
286
287 =cut
288
289 */
290
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
291 VTABLE void thaw(PMC *info) {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
292 /* 1. thaw scheduler id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
293 const INTVAL id = VTABLE_shift_integer(INTERP, info);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
294
295 /* Allocate the scheduler's core data struct and set custom flags. */
296 SELF.init();
297
298 /* Set the scheduler's id to the frozen id */
299 PARROT_SCHEDULER(SELF)->id = id;
300 }
301
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
302
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
303 /*
304
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
305 =item C<void thawfinish(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
306
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
307 Finishes thawing the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
308
309 =cut
310
311 */
312
37f7521 @ZYROz [pmc] Improved WBs [a-z]*.pmc
ZYROz authored Jun 7, 2014
313 VTABLE void thawfinish(PMC *info) :no_wb {
97eac13 @rurban [cage] Add remaining missing UNUSED(arg) declarations from pmc
rurban authored Dec 11, 2012
314 UNUSED(info)
37f7521 @ZYROz [pmc] Improved WBs [a-z]*.pmc
ZYROz authored Jun 7, 2014
315 UNUSED(INTERP)
316 UNUSED(SELF)
97eac13 @rurban [cage] Add remaining missing UNUSED(arg) declarations from pmc
rurban authored Dec 11, 2012
317 /* Parrot_cx_refresh_task_list(INTERP, SELF); */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
318 }
319
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
320
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
321 /*
322
323 =back
324
325 =head2 Methods
326
327 =over 4
328
329 =cut
330
331 */
332
333 /*
334
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
335 =item C<METHOD active_tasks()>
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
336
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
337 Returns a ResizablePMCArray containing pointers to all active tasks.
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
338
339 =cut
340
341 */
342
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
343 METHOD active_tasks() {
344 Parrot_Scheduler_attributes *sdata = PARROT_SCHEDULER(SELF);
847cb9b @rurban [GH #836] Cleaned wrong UNUSED(arg) macros in all pmc's
rurban authored Sep 24, 2012
345 PMC * const tasks = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
346 PMC * const iter = Parrot_pmc_new_init(INTERP, enum_class_HashIterator, sdata->all_tasks);
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
347
847cb9b @rurban [GH #836] Cleaned wrong UNUSED(arg) macros in all pmc's
rurban authored Sep 24, 2012
348 while (!VTABLE_get_bool(INTERP, iter)) {
349 PMC * const pair = VTABLE_shift_pmc(INTERP, iter);
9ddac31 @Whiteknight cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix …
Whiteknight authored Oct 28, 2011
350 PMC * task = PMCNULL;
847cb9b @rurban [GH #836] Cleaned wrong UNUSED(arg) macros in all pmc's
rurban authored Sep 24, 2012
351 STRING * const value = CONST_STRING(INTERP, "value");
352 Parrot_pcc_invoke_method_from_c_args(INTERP, pair,
9ddac31 @Whiteknight cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix …
Whiteknight authored Oct 28, 2011
353 value, "->P", &task);
847cb9b @rurban [GH #836] Cleaned wrong UNUSED(arg) macros in all pmc's
rurban authored Sep 24, 2012
354 VTABLE_push_pmc(INTERP, tasks, task);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
355 }
356
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
357 RETURN(PMC* tasks);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
358 }
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
359 }
360
361 /*
362
363 =back
364
365 =head1 SEE ALSO
366
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
367 F<docs/pdds/pdd25_concurrency.pod>.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
368
369 =cut
370
371 */
372
373 /*
374 * Local variables:
375 * c-file-style: "parrot"
376 * End:
1d7dded @plobsing update C file vim modelines
plobsing authored Nov 29, 2010
377 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
378 */
Something went wrong with that request. Please try again.