Skip to content
Newer
Older
100644 346 lines (216 sloc) 7.77 KB
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
1 /*
3f0c008 @NotFound use a hash keyed by int in Schecduler task_list to avoid string-int c…
NotFound authored Sep 7, 2011
2 Copyright (C) 2001-2011, Parrot Foundation.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
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 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 {
fb0dfd8 @NatTuck Progress on alarms / timers.
NatTuck authored Jun 30, 2010
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
9f3e20d @NatTuck [gsoc_threads] Alarms work, at least the easy way.
NatTuck authored Jul 1, 2010
32 ATTR PMC *task_queue; /* List of tasks/green threads waiting to run */
33 ATTR PMC *alarms; /* List of future alarms ordered by time */
fb0dfd8 @NatTuck Progress on alarms / timers.
NatTuck authored Jun 30, 2010
34
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
35 ATTR PMC *all_tasks; /* Hash of all active tasks by ID */
36 ATTR UINTVAL next_task_id; /* ID to assign to the next created task */
e6fa7fc @Whiteknight rename enable_event_checking -> Parrot_runcore_enable_event_checking,…
Whiteknight authored Oct 29, 2011
37 ATTR INTVAL enable_preemption;
38 /* Can perform uncooperative task preemption */
39 ATTR INTVAL enable_scheduling;
40 /* Can perform task scheduling behaviors */
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
41
fb0dfd8 @NatTuck Progress on alarms / timers.
NatTuck authored Jun 30, 2010
42 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
43
44 /*
45
46 =item C<void init()>
47
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
48 Initializes a concurrency scheduler object.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
49
50 =cut
51
52 */
53
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
54 VTABLE void init() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
55 Parrot_Scheduler_attributes * const core_struct =
5a7584e @NotFound merge auto_attrs branch into trunk
NotFound authored Aug 18, 2009
56 (Parrot_Scheduler_attributes *) PMC_data(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
57
1997c49 @cotto [gc] remove/replace DOD references in core PMCs
cotto authored Feb 12, 2009
58 /* Set flags for custom GC mark and destroy. */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
59 PObj_custom_mark_SET(SELF);
4591dbb @chromatic [HLL] Fixed two compilation-breaking typos accidentally committed in …
chromatic authored Sep 3, 2009
60 PObj_custom_destroy_SET(SELF);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
61
62 /* Set up the core struct. */
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
63 core_struct->id = 0;
64 core_struct->handlers = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
65 core_struct->messages = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
66 core_struct->task_queue = Parrot_pmc_new(INTERP, enum_class_PMCList);
67 core_struct->alarms = Parrot_pmc_new(INTERP, enum_class_PMCList);
68 core_struct->all_tasks = Parrot_pmc_new(INTERP, enum_class_Hash);
e6fa7fc @Whiteknight rename enable_event_checking -> Parrot_runcore_enable_event_checking,…
Whiteknight authored Oct 29, 2011
69 core_struct->enable_scheduling = 0;
70 core_struct->enable_preemption = 0;
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
71 core_struct->next_task_id = 0;
72 core_struct->interp = INTERP;
73
74 /* Chandon TODO: Delete from int-keyed hash doesn't like me. */
75 /* VTABLE_set_integer_native(interp, core_struct->all_tasks, Hash_key_type_int); */
76
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
77 }
78
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
79
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
80 /*
81
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
82 =item C<void init_pmc(PMC *data)>
83
84 Initializes a new Scheduler with a C<Hash> PMC with any or all of the keys:
85
86 =over 4
87
88 =item C<id>
89
90 An C<Integer> representing the unique identifier for this scheduler.
91
92 =back
93
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
94 =cut
95
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
96 */
97
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
98 VTABLE void init_pmc(PMC *data) {
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
99 PMC *elem;
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
100 Parrot_Scheduler_attributes *core_struct;
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
101
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
102 if (!VTABLE_isa(INTERP, data, CONST_STRING(INTERP, "Hash")))
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
103 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
104 "Scheduler initializer must be a Hash");
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
105
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
106 SELF.init();
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
107
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
108 core_struct = PARROT_SCHEDULER(SELF);
109 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
110
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
111 if (!PMC_IS_NULL(elem))
112 core_struct->id = VTABLE_get_integer(INTERP, elem);
96858ee @chromatic [PMC] Added init_pmc() to Scheduler PMC, with tests.
chromatic authored Dec 3, 2007
113 }
114
115 /*
116
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
117 =item C<void push_pmc(PMC *value)>
118
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
119 Inserts a task into the task list, giving it a task ID one higher than the
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
120 current maximum, and a birthtime of the current time.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
121
122 =cut
123
124 */
125
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
126 void push_pmc(PMC *task) {
3fe43f8 @Whiteknight Fix conflicts after merge to newest master
Whiteknight authored Oct 26, 2011
127 /* TODO: This doesn't appear to do anything */
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);
9ddac31 @Whiteknight cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix …
Whiteknight authored Oct 28, 2011
129 PMC * const type_pmc = VTABLE_get_attr_str(interp, task, CONST_STRING(interp, "type"));
130 STRING * const type = VTABLE_get_string(interp, type_pmc);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
131 }
132
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
133
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
134 /*
135
136 =item C<PMC *pop_pmc()>
137
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
138 Retrieves the next task from the task list. If the task index is invalid,
139 recalculates it before retrieving the next task.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
140
141 =cut
142
143 */
144
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
145 VTABLE PMC *pop_pmc() {
9ddac31 @Whiteknight cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix …
Whiteknight authored Oct 28, 2011
146 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
147 PMC * const task = VTABLE_shift_pmc(INTERP, core_struct->task_queue);
98ca8df @allisonrandal [concurrency] Further work on the new concurrency scheduler. (With ap…
allisonrandal authored Dec 31, 2007
148 return task;
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
149 }
150
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
151
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
152 /*
153
2f43c23 @allisonrandal [concurrency] Initialize interp struct member in Scheduler. Add a way to
allisonrandal authored Dec 2, 2007
154 =item C<INTVAL get_integer()>
155
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
156 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
157
158 =cut
159
160 */
161
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
162 VTABLE INTVAL get_integer() {
fd1a800 @petdance removed unused var task_id_str. Consted a pointer, and marked an inte…
petdance authored Oct 18, 2011
163 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
856f3b2 @niner Cleanup green_threads/kill_threads merge, builds now
niner authored Sep 25, 2011
164 return VTABLE_elements(INTERP, core_struct->task_queue);
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
165 }
166
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
167
e922116 @allisonrandal [concurrency] Initial implementation of concurrency scheduler runloop.
allisonrandal authored Dec 4, 2007
168 /*
169
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
170 =item C<void destroy()>
171
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
172 Frees the scheduler's underlying struct.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
173
174 =cut
175
176 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
177 VTABLE void destroy() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
178 Parrot_Scheduler_attributes * const core_struct = PARROT_SCHEDULER(SELF);
fd1a800 @petdance removed unused var task_id_str. Consted a pointer, and marked an inte…
petdance authored Oct 18, 2011
179 UNUSED(interp);
180
40787d4 @Whiteknight [gc] Gix order-of-destruction bug discovered by Chandon++. The check …
Whiteknight authored Jun 12, 2010
181 core_struct->interp->scheduler = NULL;
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
182 }
183
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
184
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
185 /*
186
187 =item C<void mark()>
188
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
189 Marks any referenced strings and PMCs as live.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
190
191 =cut
192
193 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
194 VTABLE void mark() {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
195 if (PARROT_SCHEDULER(SELF)) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
196 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
197
26914e1 changed interp in pmc class to INTERP for unification
Jimmy Zhuo authored May 5, 2010
198 Parrot_gc_mark_PMC_alive(INTERP, core_struct->handlers);
199 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
200 Parrot_gc_mark_PMC_alive(INTERP, core_struct->task_queue);
201 Parrot_gc_mark_PMC_alive(INTERP, core_struct->alarms);
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
202 Parrot_gc_mark_PMC_alive(INTERP, core_struct->all_tasks);
5d8728e @NatTuck [gsoc_threads] Fix some failing tests.
NatTuck authored Jul 2, 2010
203 }
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
204 }
205
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
206
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
207 /*
208
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
209 =item C<void visit(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
210
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
211 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
212
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
213 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
214
215 =cut
216
217 */
218
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
219 VTABLE void visit(PMC *info) {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
220 /* 1) visit task list */
62b52c9 @NatTuck [gsoc_threads] Added callback PMC to handle NCI.
NatTuck authored Jul 4, 2010
221 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
222
223 /* 2) visit the handlers */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
224 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, handlers);
62b52c9 @NatTuck [gsoc_threads] Added callback PMC to handle NCI.
NatTuck authored Jul 4, 2010
225
226 /* 3) visit the alarms */
227 VISIT_PMC_ATTR(INTERP, info, SELF, Scheduler, alarms);
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
228
229 /* 3) visit all tasks */
230 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
231 }
232
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
233
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
234 /*
235
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
236 =item C<void freeze(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
237
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
238 Archives the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
239
240 =cut
241
242 */
243
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
244 VTABLE void freeze(PMC *info) {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored Sep 8, 2008
245 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
246
247 /* 1) freeze scheduler id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
248 VTABLE_push_integer(INTERP, info, core_struct->id);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
249 }
250
251 /*
252
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
253 =item C<void thaw(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
254
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
255 Unarchives the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
256
257 =cut
258
259 */
260
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
261 VTABLE void thaw(PMC *info) {
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
262 /* 1. thaw scheduler id */
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
263 const INTVAL id = VTABLE_shift_integer(INTERP, info);
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
264
265 /* Allocate the scheduler's core data struct and set custom flags. */
266 SELF.init();
267
268 /* Set the scheduler's id to the frozen id */
269 PARROT_SCHEDULER(SELF)->id = id;
270 }
271
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
272
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
273 /*
274
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
275 =item C<void thawfinish(PMC *info)>
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
276
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
277 Finishes thawing the scheduler.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
278
279 =cut
280
281 */
282
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
283 VTABLE void thawfinish(PMC *info) {
5d8728e @NatTuck [gsoc_threads] Fix some failing tests.
NatTuck authored Jul 2, 2010
284 /* Parrot_cx_refresh_task_list(INTERP, SELF); */
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
285 }
286
be7602b @chromatic [PMC] Fixed compiler warnings (use of uninitialized variables) and ti…
chromatic authored Aug 9, 2008
287
d6808fe @allisonrandal [events] Add interface for event handling, add subtype attribute to t…
allisonrandal authored Dec 12, 2007
288 /*
289
290 =back
291
292 =head2 Methods
293
294 =over 4
295
296 =cut
297
298 */
299
300 /*
301
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
302 =item C<METHOD active_tasks()>
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
303
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
304 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
305
306 =cut
307
308 */
309
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
310 METHOD active_tasks() {
311 Parrot_Scheduler_attributes *sdata = PARROT_SCHEDULER(SELF);
9ddac31 @Whiteknight cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix …
Whiteknight authored Oct 28, 2011
312 PMC * const tasks = Parrot_pmc_new(interp, enum_class_ResizablePMCArray);
313 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
314
315 while (!VTABLE_get_bool(interp, iter)) {
9ddac31 @Whiteknight cleanup Scheduler.pmc and Task.pmc. Add const for the optimizer. Fix …
Whiteknight authored Oct 28, 2011
316 PMC * const pair = VTABLE_shift_pmc(interp, iter);
317 PMC * task = PMCNULL;
318 STRING * const value = CONST_STRING(interp, "value");
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
319 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
320 value, "->P", &task);
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
321 VTABLE_push_pmc(interp, tasks, task);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
322 }
323
9110bb8 @NatTuck [gsoc_threads] More green threads API.
NatTuck authored Jul 21, 2010
324 RETURN(PMC* tasks);
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
325 }
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
326 }
327
328 /*
329
330 =back
331
332 =head1 SEE ALSO
333
4d9c960 @allisonrandal [concurrency] Next stage of concurrency implementation, message passi…
allisonrandal authored Jan 5, 2008
334 F<docs/pdds/pdd25_concurrency.pod>.
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
335
336 =cut
337
338 */
339
340 /*
341 * Local variables:
342 * c-file-style: "parrot"
343 * End:
1d7dded @plobsing update C file vim modelines
plobsing authored Nov 29, 2010
344 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
1d259c6 @allisonrandal [concurrency] Initial implementations of the Scheduler and Task PMCs.
allisonrandal authored Nov 25, 2007
345 */
Something went wrong with that request. Please try again.