diff options
author | neal <neal> | 2008-02-15 15:04:50 +0000 |
---|---|---|
committer | neal <neal> | 2008-02-15 15:04:50 +0000 |
commit | 7d27d13b06e8ce78e7afb027f3fed6a315dfaf75 (patch) | |
tree | 987f96812301990cd4b71d62631c095f7439e437 /viengoos/pager.c | |
parent | 7ca2c774880a6a88ff64dd4f4a3df5b3e054a11e (diff) |
2008-02-15 Neal H. Walfield <neal@gnu.org>
* activity.h: Include "list.h".
(LIST_CLASS_TYPE): Declare a activity_children list.
(struct activity): Change children's type to a struct
activity_children_list. Replace sibling_next and sibling_prev
with sibling, a struct list_node.
(activity_for_each_inmemory_child): Remove macro.
* activity.c (children_list_insert_after): Remove function.
Replace uses with appropriate list function.
(children_list_detach): Likewise.
* pager.c (pager_collect): Replace use of
activity_for_each_inmemory_child with a list iterator.
* ager.c (ager_loop): Likewise.
Diffstat (limited to 'viengoos/pager.c')
-rw-r--r-- | viengoos/pager.c | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/viengoos/pager.c b/viengoos/pager.c index cb4de04..4e77c8b 100644 --- a/viengoos/pager.c +++ b/viengoos/pager.c @@ -79,61 +79,62 @@ pager_collect (void) frames = victim_frames; struct activity *child; - activity_for_each_inmemory_child - (parent, child, - ({ - if (child->policy.sibling_rel.priority < victim_policy.priority) - /* CHILD has a lower absolute priority. */ - { - victim = child; - victim_frames = victim->frames_total; - victim_policy = victim->policy.sibling_rel; - - /* Reset the weight. */ - weight = victim_policy.weight; - frames = victim_frames; - } - else if (child->policy.sibling_rel.priority - == victim_policy.priority) - /* CHILD and VICTIM have equal priority. Steal from the one - which has the most pages taking into their respective - weights. */ - { - weight += child->policy.sibling_rel.weight; - frames += child->frames_total; - - if (child->policy.sibling_rel.weight == victim_policy.weight) - /* CHILD and VICTIM have the same weight. Prefer the - one with more frames. */ - { - if (child->frames_total > frames) - { - victim = child; - victim_frames = victim->frames_total; - victim_policy = victim->policy.sibling_rel; - } - } - else - { - int f = child->frames_total + victim_frames; - int w = child->policy.sibling_rel.weight - + victim_policy.weight; - - int child_excess = child->frames_total - - (child->policy.sibling_rel.weight * f) / w; - int victim_excess = victim_frames - - (victim_policy.weight * f) / w; - - if (child_excess > victim_excess) - /* CHILD has more excess frames than VICTIM. */ - { - victim = child; - victim_frames = victim->frames_total; - victim_policy = victim->policy.sibling_rel; - } - } - } - })); + for (child = activity_children_list_head (&parent->children); + child; + child = activity_children_list_next (child)) + { + if (child->policy.sibling_rel.priority < victim_policy.priority) + /* CHILD has a lower absolute priority. */ + { + victim = child; + victim_frames = victim->frames_total; + victim_policy = victim->policy.sibling_rel; + + /* Reset the weight. */ + weight = victim_policy.weight; + frames = victim_frames; + } + else if (child->policy.sibling_rel.priority + == victim_policy.priority) + /* CHILD and VICTIM have equal priority. Steal from the one + which has the most pages taking into their respective + weights. */ + { + weight += child->policy.sibling_rel.weight; + frames += child->frames_total; + + if (child->policy.sibling_rel.weight == victim_policy.weight) + /* CHILD and VICTIM have the same weight. Prefer the + one with more frames. */ + { + if (child->frames_total > frames) + { + victim = child; + victim_frames = victim->frames_total; + victim_policy = victim->policy.sibling_rel; + } + } + else + { + int f = child->frames_total + victim_frames; + int w = child->policy.sibling_rel.weight + + victim_policy.weight; + + int child_excess = child->frames_total + - (child->policy.sibling_rel.weight * f) / w; + int victim_excess = victim_frames + - (victim_policy.weight * f) / w; + + if (child_excess > victim_excess) + /* CHILD has more excess frames than VICTIM. */ + { + victim = child; + victim_frames = victim->frames_total; + victim_policy = victim->policy.sibling_rel; + } + } + } + } if (frames >= goal) /* The number of frames at this priority level exceed the |