MemoryUtils.writeMem(fp, pool, mem1, offset, bvs);
- Program program = new Program(pool.allocateShip("Memory"));
+ Ship mem = pool.allocateShip("Memory");
+ Program program = new Program(mem);
long ret = new MergeSort(fleet, program, pool, 2, mem1, mem1).main(fp, vals_length);
//long ret = 0;
//MemoryUtils.readMem(fp, new ShipPool(fp.getFleet()), mem1, 0, bvs);
BitVector[] bvx = new BitVector[1024];
+ pool.allocateShip(mem);
MemoryUtils.readMem(fp, new ShipPool(fp.getFleet()), mem1, 0, bvx);
for(int i=0; i<bvx.length; i++)
System.out.println(bvx[i]);
lf.sendWord(program.getCBDDestination());
cb.seal();
+ ShipPool pool = new ShipPool(fp.getFleet());
+ pool.allocateShip(program.memoryShip);
// FIXME
- return program.run(fp, cb, new ShipPool(fp.getFleet()));
+ long ret = program.run(fp, cb, pool);
+ pool.releaseShip(program.memoryShip);
+ return ret;
}
public static void randomizeMemory(FleetProcess fp, ShipPool pool_, Ship memory, long start, long length, boolean randomize) {
return memoryShip.getDock("inCBD").getDataDestination();
}
- public long run(FleetProcess fp, CodeBag run, ShipPool pool) {
+ public long run(FleetProcess fp, CodeBag run, ShipPool pool_) {
+ ShipPool pool = new ShipPool(pool_);
Ship timer = pool.allocateShip("Timer");
Ship debug = pool.allocateShip("Debug");
Dock debugIn = debug.getDock("in");
start.seal();
done.seal();
- install(fp, pool);
+ pool.setParent(null);
+ install(fp, pool_);
+ pool.setParent(pool_);
MemoryUtils.putMemoryShipInDispatchMode(fp, memoryShip);
fp.sendWord(getCBDDestination(), start.getDescriptor().getBitVector());
public void allocateShip(Ship ship) {
if (allocatedShips.contains(ship))
- throw new RuntimeException("already allocated!");
+ throw new RuntimeException("ship " + ship + " is already allocated!");
if (parent != null)
parent.allocateShip(ship);
allocatedShips.add(ship);