Author: Lars Wassermann <lars.wasserm...@gmail.com> Branch: Changeset: r373:5dddfd278ce6 Date: 2013-05-03 20:11 +0200 http://bitbucket.org/pypy/lang-smalltalk/changeset/5dddfd278ce6/
Log: fixed one of the problems with the last of the four shootout tests used by eliot: renamed highest_priority_process to pop_highest_priority_process to indicate the resulting state changes diff --git a/spyvm/test/test_wrapper.py b/spyvm/test/test_wrapper.py --- a/spyvm/test/test_wrapper.py +++ b/spyvm/test/test_wrapper.py @@ -216,15 +216,15 @@ assert semaphore.excess_signals() == 1 def test_highest_priority(self): - py.test.raises(FatalError, wrapper.scheduler(space).highest_priority_process) + py.test.raises(FatalError, wrapper.scheduler(space).pop_highest_priority_process) process, old_process = self.make_processes(4, 2, space.w_false) process.put_to_sleep() old_process.put_to_sleep() - highest = wrapper.scheduler(space).highest_priority_process() + highest = wrapper.scheduler(space).pop_highest_priority_process() assert highest is process._w_self - highest = wrapper.scheduler(space).highest_priority_process() + highest = wrapper.scheduler(space).pop_highest_priority_process() assert highest is old_process._w_self - py.test.raises(FatalError, wrapper.scheduler(space).highest_priority_process) + py.test.raises(FatalError, wrapper.scheduler(space).pop_highest_priority_process) def test_semaphore_wait(self): semaphore = new_semaphore() diff --git a/spyvm/wrapper.py b/spyvm/wrapper.py --- a/spyvm/wrapper.py +++ b/spyvm/wrapper.py @@ -104,7 +104,7 @@ def suspend(self, w_current_frame): if self.is_active_process(): assert self.my_list().is_same_object(self.space.w_nil) - w_process = scheduler(self.space).highest_priority_process() + w_process = scheduler(self.space).pop_highest_priority_process() self.store_suspended_context(w_current_frame) return ProcessWrapper(self.space, w_process).activate() else: @@ -176,6 +176,18 @@ return ProcessListWrapper(self.space, lists.read(priority)) + def pop_highest_priority_process(self): + w_lists = self.priority_list() + # Asserts as W_PointersObjectonion in the varnish. + lists = Wrapper(self.space, w_lists) + + for i in range(w_lists.size() - 1, -1, -1): + process_list = ProcessListWrapper(self.space, lists.read(i)) + if not process_list.is_empty_list(): + return process_list.remove_first_link_of_list() + + raise FatalError("Scheduler could not find a runnable process") + def highest_priority_process(self): w_lists = self.priority_list() # Asserts as W_PointersObjectonion in the varnish. @@ -184,7 +196,7 @@ for i in range(w_lists.size() - 1, -1, -1): process_list = ProcessListWrapper(self.space, lists.read(i)) if not process_list.is_empty_list(): - return process_list.remove_first_link_of_list() + return process_list.first_link() raise FatalError("Scheduler could not find a runnable process") diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py --- a/targetimageloadingsmalltalk.py +++ b/targetimageloadingsmalltalk.py @@ -12,6 +12,8 @@ def _run_benchmark(interp, number, benchmark): scheduler = wrapper.scheduler(interp.space) w_hpp = scheduler.highest_priority_process() + if space.unwrap_int(scheduler.active_process().fetch(space, 2)) > space.unwrap_int(w_hpp.fetch(space, 2)): + w_hpp = scheduler.active_process() assert isinstance(w_hpp, model.W_PointersObject) w_benchmark_proc = model.W_PointersObject( interp.space, @@ -34,7 +36,7 @@ # third variable is priority priority = space.unwrap_int(w_hpp.fetch(space, 2)) / 2 + 1 # Priorities below 10 are not allowed in newer versions of Squeak. - priority = max(10, priority) + priority = max(11, priority) w_benchmark_proc.store(space, 2, space.wrap_int(priority)) # make process eligible for scheduling _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit