diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-04-19 12:09:50 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-04-19 12:09:50 +0000 |
commit | fbe8da45a9b682f3cbb921e2ea6537ef558d64f3 (patch) | |
tree | 97ca12e6ddf41f073395fc297add5a607cbc3dd4 /src/util/scheduler.c | |
parent | b272a833ee57cad630ecbcce1aab366777042dd9 (diff) | |
download | gnunet-fbe8da45a9b682f3cbb921e2ea6537ef558d64f3.tar.gz gnunet-fbe8da45a9b682f3cbb921e2ea6537ef558d64f3.zip |
-fixing #2274
Diffstat (limited to 'src/util/scheduler.c')
-rw-r--r-- | src/util/scheduler.c | 83 |
1 files changed, 1 insertions, 82 deletions
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 8d3106032..6b8d21443 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -115,11 +115,6 @@ struct Task | |||
115 | GNUNET_SCHEDULER_TaskIdentifier id; | 115 | GNUNET_SCHEDULER_TaskIdentifier id; |
116 | 116 | ||
117 | /** | 117 | /** |
118 | * Identifier of a prerequisite task. | ||
119 | */ | ||
120 | GNUNET_SCHEDULER_TaskIdentifier prereq_id; | ||
121 | |||
122 | /** | ||
123 | * Absolute timeout value for the task, or | 118 | * Absolute timeout value for the task, or |
124 | * GNUNET_TIME_UNIT_FOREVER_ABS for "no timeout". | 119 | * GNUNET_TIME_UNIT_FOREVER_ABS for "no timeout". |
125 | */ | 120 | */ |
@@ -216,13 +211,6 @@ static struct Task *ready[GNUNET_SCHEDULER_PRIORITY_COUNT]; | |||
216 | static GNUNET_SCHEDULER_TaskIdentifier last_id; | 211 | static GNUNET_SCHEDULER_TaskIdentifier last_id; |
217 | 212 | ||
218 | /** | 213 | /** |
219 | * Highest number so that all tasks with smaller identifiers | ||
220 | * have already completed. Also the lowest number of a task | ||
221 | * still waiting to be executed. | ||
222 | */ | ||
223 | static GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id; | ||
224 | |||
225 | /** | ||
226 | * Number of tasks on the ready list. | 214 | * Number of tasks on the ready list. |
227 | */ | 215 | */ |
228 | static unsigned int ready_count; | 216 | static unsigned int ready_count; |
@@ -293,60 +281,6 @@ check_priority (enum GNUNET_SCHEDULER_Priority p) | |||
293 | 281 | ||
294 | 282 | ||
295 | /** | 283 | /** |
296 | * Is a task with this identifier still pending? Also updates | ||
297 | * "lowest_pending_id" as a side-effect (for faster checks in the | ||
298 | * future), but only if the return value is "GNUNET_NO" (and | ||
299 | * the "lowest_pending_id" check failed). | ||
300 | * | ||
301 | * @param id which task are we checking for | ||
302 | * @return GNUNET_YES if so, GNUNET_NO if not | ||
303 | */ | ||
304 | static int | ||
305 | is_pending (GNUNET_SCHEDULER_TaskIdentifier id) | ||
306 | { | ||
307 | struct Task *pos; | ||
308 | enum GNUNET_SCHEDULER_Priority p; | ||
309 | GNUNET_SCHEDULER_TaskIdentifier min; | ||
310 | |||
311 | if (id < lowest_pending_id) | ||
312 | return GNUNET_NO; | ||
313 | min = -1; /* maximum value */ | ||
314 | pos = pending; | ||
315 | while (pos != NULL) | ||
316 | { | ||
317 | if (pos->id == id) | ||
318 | return GNUNET_YES; | ||
319 | if (pos->id < min) | ||
320 | min = pos->id; | ||
321 | pos = pos->next; | ||
322 | } | ||
323 | pos = pending_timeout; | ||
324 | while (pos != NULL) | ||
325 | { | ||
326 | if (pos->id == id) | ||
327 | return GNUNET_YES; | ||
328 | if (pos->id < min) | ||
329 | min = pos->id; | ||
330 | pos = pos->next; | ||
331 | } | ||
332 | for (p = 0; p < GNUNET_SCHEDULER_PRIORITY_COUNT; p++) | ||
333 | { | ||
334 | pos = ready[p]; | ||
335 | while (pos != NULL) | ||
336 | { | ||
337 | if (pos->id == id) | ||
338 | return GNUNET_YES; | ||
339 | if (pos->id < min) | ||
340 | min = pos->id; | ||
341 | pos = pos->next; | ||
342 | } | ||
343 | } | ||
344 | lowest_pending_id = min; | ||
345 | return GNUNET_NO; | ||
346 | } | ||
347 | |||
348 | |||
349 | /** | ||
350 | * Update all sets and timeout for select. | 284 | * Update all sets and timeout for select. |
351 | * | 285 | * |
352 | * @param rs read-set, set to all FDs we would like to read (updated) | 286 | * @param rs read-set, set to all FDs we would like to read (updated) |
@@ -374,12 +308,6 @@ update_sets (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws, | |||
374 | pos = pending; | 308 | pos = pending; |
375 | while (pos != NULL) | 309 | while (pos != NULL) |
376 | { | 310 | { |
377 | if ((pos->prereq_id != GNUNET_SCHEDULER_NO_TASK) && | ||
378 | (GNUNET_YES == is_pending (pos->prereq_id))) | ||
379 | { | ||
380 | pos = pos->next; | ||
381 | continue; | ||
382 | } | ||
383 | if (pos->timeout.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) | 311 | if (pos->timeout.abs_value != GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) |
384 | { | 312 | { |
385 | to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); | 313 | to = GNUNET_TIME_absolute_get_difference (now, pos->timeout); |
@@ -459,15 +387,7 @@ is_ready (struct Task *task, struct GNUNET_TIME_Absolute now, | |||
459 | reason |= GNUNET_SCHEDULER_REASON_WRITE_READY; | 387 | reason |= GNUNET_SCHEDULER_REASON_WRITE_READY; |
460 | if (reason == 0) | 388 | if (reason == 0) |
461 | return GNUNET_NO; /* not ready */ | 389 | return GNUNET_NO; /* not ready */ |
462 | if (task->prereq_id != GNUNET_SCHEDULER_NO_TASK) | 390 | reason |= GNUNET_SCHEDULER_REASON_PREREQ_DONE; |
463 | { | ||
464 | if (GNUNET_YES == is_pending (task->prereq_id)) | ||
465 | { | ||
466 | task->reason = reason; | ||
467 | return GNUNET_NO; /* prereq waiting */ | ||
468 | } | ||
469 | reason |= GNUNET_SCHEDULER_REASON_PREREQ_DONE; | ||
470 | } | ||
471 | task->reason = reason; | 391 | task->reason = reason; |
472 | return GNUNET_YES; | 392 | return GNUNET_YES; |
473 | } | 393 | } |
@@ -1373,7 +1293,6 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1373 | #if PROFILE_DELAYS | 1293 | #if PROFILE_DELAYS |
1374 | t->start_time = GNUNET_TIME_absolute_get (); | 1294 | t->start_time = GNUNET_TIME_absolute_get (); |
1375 | #endif | 1295 | #endif |
1376 | t->prereq_id = GNUNET_SCHEDULER_NO_TASK; | ||
1377 | t->timeout = GNUNET_TIME_relative_to_absolute (delay); | 1296 | t->timeout = GNUNET_TIME_relative_to_absolute (delay); |
1378 | t->priority = check_priority ((priority == GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority : priority); | 1297 | t->priority = check_priority ((priority == GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority : priority); |
1379 | t->lifeness = current_lifeness; | 1298 | t->lifeness = current_lifeness; |