Skip to content

Commit

Permalink
Corrected scheduling policy unfairness that affects stop ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Nov 11, 2013
1 parent 3863a48 commit 33bf0ed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,19 @@ public void register(ISchedulableThread thread, long priority)
{
synchronized (threads)
{
threads.add(thread);
// The last thread is the one currently running, so insert ahead of this
// one so that the new thread is scheduled before the current one is
// next scheduled.
int count = threads.size();

if (count == 0)
{
threads.add(thread);
}
else
{
threads.add(count - 1, thread);
}
}
}

Expand Down
14 changes: 8 additions & 6 deletions core/vdmj/src/test/resources/Overture/evaluate/stoptest.vpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ system SYS
instance variables
static public obj1 : A := new A();
static public obj2 : A := new A();
static public obj3 : A := new A();

cpu1:CPU := new CPU(<FP>, 1E6);
cpu2:CPU := new CPU(<FP>, 1E6);
Expand All @@ -14,6 +15,7 @@ operations
(
cpu1.deploy(obj1, "Test object one");
cpu2.deploy(obj2, "Test object two");
cpu2.deploy(obj3, "Test object three");
)

end SYS
Expand Down Expand Up @@ -53,17 +55,17 @@ operations
test() ==
(
SYS`obj1.run();
SYS`obj1.null();
SYS`obj1.kill();

SYS`obj1.run();
SYS`obj2.null();
SYS`obj2.kill(SYS`obj1);
-- SYS`obj1.run();
-- SYS`obj2.null();
-- SYS`obj2.kill(SYS`obj1); -- Error, wrong CPU

SYS`obj1.run();
SYS`obj2.run();
SYS`obj2.null();
SYS`obj2.kill({SYS`obj1, SYS`obj2});
SYS`obj3.run();
SYS`obj2.kill({SYS`obj2, SYS`obj3});
SYS`obj1.kill(SYS`obj1);
)

end Test

0 comments on commit 33bf0ed

Please sign in to comment.