Skip to content

HTTPS clone URL

Subversion checkout URL

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