Commit 3ed4b1dc authored by Melanie Jakob's avatar Melanie Jakob

Kommentate und Codeverschönerung

parent 2eaa2de9
C:\Daten\UniMel\vam\
join.tma
newstack.tma
......@@ -66,8 +66,9 @@ class State {
private List<Integer> rqValues;
private List<List> jtabValues;
private List<Integer> threadPosition;
public static List<Integer> cvPosition; //Beschriftungszellen fr CV
public static List<Integer> mutexPosition; //Beschriftungszellen fr Mutex
public static List<ReadyQueue> test2;
private HashMap mem;
private java.util.Stack trailCopy;
......@@ -100,9 +101,13 @@ class State {
//store Mutex and CV Cells
test2 = new LinkedList<ReadyQueue>();
for(ReadyQueue a:vam.machines.tma.MainCommand.newCells){
test2.add(a);
cvPosition = new LinkedList<Integer>();
for(Integer a:vam.machines.tma.MainCommand.cvCells){
cvPosition.add(a);
}
mutexPosition = new LinkedList<Integer>();
for(Integer b:vam.machines.tma.MainCommand.mutexCells){
mutexPosition.add(b);
}
//store values of JTab
......@@ -110,7 +115,7 @@ class State {
for(JTableElement current:JTableElement.jTable){
List<Integer> a = new LinkedList<Integer>();
for(ReadyQueue now:current.waitingQueueList){
for(ReadyQueue now:current.elementList){
a.add(now.getIntValue());
}
jtabValues.add(a);
......@@ -184,14 +189,8 @@ class State {
restoreReadyQueue(rqValues);
restoreJTable(jtabValues);
restoreThreadPosition(threadPosition);
restoreMutexAndCv();
for(ReadyQueue c:vam.machines.tma.MainCommand.newCells){
c.remove();}
vam.machines.tma.MainCommand.newCells.clear();
for(ReadyQueue d:this.test2){
ReadyQueue e = new ReadyQueue(d.getName(),"Mutex",d.getLocation(),true);
vam.machines.tma.MainCommand.newCells.add(e);
}
history.vm.memory.addressForNewHeapObjects = addressForNewHeapObjects;
history.vm.memory.newHeapObjectLocation = newHeapObjectLocation;
......@@ -207,6 +206,39 @@ class State {
history.vm.repaintView();
}
private void restoreMutexAndCv(){
for(ReadyQueue current:vam.machines.tma.MainCommand.newCells){
ReadyQueue.rqGroup.remove(current);
current.remove();}
vam.machines.tma.MainCommand.newCells.clear();
vam.machines.tma.MainCommand.cvCells.clear();
vam.machines.tma.MainCommand.mutexCells.clear();
Point p = new Point();
for(Integer current:cvPosition){
p = vam.machines.tma.MainCommand.memory.getLocation(current);
p.translate(-50,0);
ReadyQueue c = new ReadyQueue("CV: ","Mutex",p,true);
MainCommand.newCells.add(c);
}
int i = 0;
for(Integer current:mutexPosition){
if (i%2 == 0) { // gerade
p = vam.machines.tma.MainCommand.memory.getLocation(current);
p.translate(-50,0);
ReadyQueue c = new ReadyQueue("Mutex: ","Mutex",p,true);
MainCommand.newCells.add(c);
}
else{
p = vam.machines.tma.MainCommand.memory.getLocation(current);
p.translate(-50,0);
ReadyQueue c = new ReadyQueue("Owner: ","Mutex",p,true);
MainCommand.newCells.add(c);
}
i++;
}
}
private void restoreThreadPosition(List<Integer> pos) {
vam.machines.tma.Thread.threadPosition.clear();
for(int current:pos){
......@@ -243,7 +275,7 @@ class State {
for(int i=0;i<JTableElement.jTable.size();i++){
JTableElement j = JTableElement.jTable.get(i);
for(ReadyQueue current:j.waitingQueueList){
for(ReadyQueue current:j.elementList){
ReadyQueue.rqGroup.remove(current);
current.remove();}
......
......@@ -21,7 +21,7 @@ public class Memory
// Laufzeitumgebeung
static ViewMachine vm;
public int threadPos; // von mir fr neue Berechnung von Location
public int threadPos; // for the calculation of the tma-machine
// (CMa)-Heap
public int addressForNewHeapObjects;
......@@ -688,42 +688,59 @@ public class Memory
threadPos = thread.getPosition();
int differenz = 100; //Platz zwischen den Stacks
int startwidth = 150; //Anfangspunkt des ersten Stacks
int bound = vm.getStackBound();
int a = address;
int cellsPerColumn = (vm.view.getHeight()-30)/Cell.stdHeight;
int stackSpace = vam.machines.tma.MainCommand.getStackspace();
while (a>=stackSpace){
a=a-stackSpace;
}
int b = a;
if ( 0<=address && address<=700 )
if ( 0<=address && address<=(MainCommand.getStacknumber()*MainCommand.getStackspace()))
{
int cellsPerColumn = (vm.view.getHeight()-30)/Cell.stdHeight;
if ( exists(0) )
{
int i = 0;
while(b>=cellsPerColumn){
while(b>=cellsPerColumn){ //Berechnet wie oft ein berlauf vorhanden ist
b = b - cellsPerColumn;
i++;
}
if(i>0){
if((vam.machines.tma.Thread.threadPosition.get(threadPos+1)>-1)){
vam.machines.tma.Thread.threadPosition.add(threadPos+1,-2);
vam.machines.tma.Thread.push(threadPos+2);}
else{
if((vam.machines.tma.Thread.threadPosition.get(threadPos+1)>-i-1)){
vam.machines.tma.Thread.push(threadPos+2);
int now = vam.machines.tma.Thread.threadPosition.get(threadPos+1);
vam.machines.tma.Thread.threadPosition.set(threadPos+1,now-1);}
else if((vam.machines.tma.Thread.threadPosition.get(threadPos+1)<-i-1)){
vam.machines.tma.Thread.pull(threadPos+2);
int now = vam.machines.tma.Thread.threadPosition.get(threadPos+1);
vam.machines.tma.Thread.threadPosition.set(threadPos+1,now+1);}
}
if(i==0){ //berprfung ob evtl ein berlauf entfernt werden muss
if(vam.machines.tma.Thread.threadPosition.size()>threadPos+1){
if(vam.machines.tma.Thread.threadPosition.get(threadPos+1)==-2){
vam.machines.tma.Thread.threadPosition.remove(threadPos+1);
vam.machines.tma.Thread.pull(threadPos+1);
}
}
}
else if(i>0){ //berprffung ob berlauf schon gesetzt
if(vam.machines.tma.Thread.threadPosition.size()>threadPos+i){
if((vam.machines.tma.Thread.threadPosition.get(threadPos+i)==-2)){
//dann passt alles
}
else if((vam.machines.tma.Thread.threadPosition.get(threadPos+i)==-1)){
vam.machines.tma.Thread.threadPosition.set(threadPos+1,-2);
}
else{ //Setzen des berlaufs
vam.machines.tma.Thread.threadPosition.add(threadPos+1,-2);
vam.machines.tma.Thread.push(threadPos+2);
}
}
else{ //berlauf nicht mehr bentigt
vam.machines.tma.Thread.threadPosition.add(threadPos+1,-2);
vam.machines.tma.Thread.push(threadPos+2);
}
}
else if(i>0){
if(vam.machines.tma.Thread.threadPosition.size()>threadPos+1+i){
if((vam.machines.tma.Thread.threadPosition.get(threadPos+2+i)==-2)){
vam.machines.tma.Thread.threadPosition.remove(threadPos+1);
vam.machines.tma.Thread.pull(threadPos+1);
}
}
}
Point trans = getCell(0).getLocation();
if (address < MainCommand.getStackspace()){
......@@ -733,6 +750,7 @@ public class Memory
}
else p.setLocation(startwidth+differenz*(threadPos),vm.view.getHeight()-30);
p.translate( (a/cellsPerColumn)*(Cell.stdWidth+30),-(a % cellsPerColumn)*Cell.stdHeight );
}
// CMa Heap
......@@ -746,15 +764,14 @@ public class Memory
int top = 1200;
int count1 = address;
int count2 = 0;
int cellsPerColumn = (vm.view.getHeight()-30)/Cell.stdHeight;
p.setLocation(vm.view.getWidth()-100, 0);
while (top-count1 >= cellsPerColumn){
count1 = count1 + cellsPerColumn;
}
p.translate( -(count2)*(Cell.stdWidth+30), (1200-count1)*Cell.stdHeight );
}
// }
return p;
}
/**
......
......@@ -1438,6 +1438,8 @@ public class ViewMachine implements ActionListener
Threadtable.reset();
ReadyQueue.reset();
vam.machines.tma.Thread.threadPosition.clear();
vam.machines.tma.MainCommand.mutexCells.clear();
vam.machines.tma.MainCommand.cvCells.clear();
repaintView();
......
......@@ -15,13 +15,13 @@ public class BROADCAST extends MainCommand{
while(memory.getValue(cvpointer)!=""){
ReadyQueue.enqueue(memory.getIntValue(cvpointer));
for (int i = 0;i<MainCommand.getStacknumber();i++){
for (int i = 0;i<MainCommand.getStacknumber()-2;i++){
if(memory.getValue(cvpointer+i+1) == ""){
memory.setValue(cvpointer+i, "");
}
else{memory.setIntValue(cvpointer+i,memory.getIntValue(cvpointer+1+i));}
}
memory.setValue(cvpointer+MainCommand.getStacknumber()-2,"");
}
......
......@@ -35,7 +35,6 @@ public class CALL extends MainCommand
stack.highlight( 1,Color.magenta ); // Rücksprungadresse retten
FP(SP()); // setzen des neuen Frame Pointer
PC(newPC); // Funktion anspringen
//memory.getCell(SP()).setVisible(true);
memory.getCell(SP()).fadeIn();
cell.fadeOut();
register.fadeOut();
......@@ -43,15 +42,5 @@ public class CALL extends MainCommand
cell.remove();
register.remove();
// stack.push()
//memory.free(SP());
// int newPC = stack.popInt();
// stack.push( PC() );
// stack.highlight( 1,Color.magenta ); // Rücksprungadresse retten
// FP(SP()); // setzen des neuen Frame Pointer
// PC(newPC); // Funktion anspringen
}
}
......@@ -13,7 +13,6 @@ public class DIV extends MainCommand
{
int op2 = memory.getIntValue( SP() );
int op1 = memory.getIntValue( SP()-1 );
//else stack.binaryOperation( "DIV", op1 / op2 );
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
if( op2 == 0 ) cmaError("Division by zero.");
else thread.getStack().binaryOperation( "DIV", op1 / op2 );
......
......@@ -11,7 +11,6 @@ public class DUP extends MainCommand
public void execute()
{
//stack.pushFromAddress( SP() );
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().pushFromAddress( SP() );
}
......
......@@ -12,6 +12,7 @@ public class ENTER extends MainCommand
public void execute()
{
// kein EP mehr in der TMA
/*EP( SP() + number ); // Extreme Pointer erh�hen
if( EP() >= NP() ) // nicht gen�gend Platz zur Verf�gung
cmaError("Stack Overflow");*/
......
......@@ -13,7 +13,6 @@ public class EQ extends MainCommand
{
int op2 = memory.getIntValue( SP() );
int op1 = memory.getIntValue( SP()-1 );
//stack.binaryOperation( "EQ", op1==op2 ? 1 : 0 );
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().binaryOperation( "EQ", op1==op2 ? 1 : 0 );
}
......
......@@ -21,12 +21,11 @@ public class EXIT extends MainCommand
int oldFP = memory.getIntValue(MainCommand.FP.get()-1);
MainCommand.FP.set(oldFP);
FP = MainCommand.FP.getIntValue();
//stack abbauen:
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().decrease(oldSP-newSP);
}
}
memory.setIntValue(MainCommand.SP.get(), result);
}
}
......@@ -9,14 +9,14 @@ public class FINALIZE extends MainCommand {
}
public void execute()
{
{
int tid = memory.getIntValue(SP.get());
if(tid>MainCommand.TC.get()){
MainCommand.viewMachine.output("The chosen Thread is not available");
PC(-1);
}
else{
int returnValue = JTableElement.jTable.get(tid).waitingQueueList.get(1).getIntValue();
int returnValue = JTableElement.jTable.get(tid).elementList.get(1).getIntValue();
memory.setIntValue(SP.get(),returnValue);
}
}
......
......@@ -12,7 +12,6 @@ public class GE extends MainCommand
{
int op2 = memory.getIntValue( SP() );
int op1 = memory.getIntValue( SP()-1 );
//stack.binaryOperation( "GE", op1>op2 ? 1 : 0 );
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().binaryOperation( "GE", op1>op2 ? 1 : 0 );
}
......
......@@ -12,7 +12,6 @@ public class GEQ extends MainCommand
{
int op2 = memory.getIntValue( SP() );
int op1 = memory.getIntValue( SP()-1 );
//stack.binaryOperation( "GEQ", op1>=op2 ? 1 : 0 );
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().binaryOperation( "GEQ", op1>=op2 ? 1 : 0 );
}
......
......@@ -12,7 +12,6 @@ public class GR extends MainCommand
{
int op2 = memory.getIntValue( SP() );
int op1 = memory.getIntValue( SP()-1 );
//stack.binaryOperation( "GR", op1>op2 ? 1 : 0 );
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().binaryOperation( "GR", op1>op2 ? 1 : 0 );
}
......
......@@ -23,48 +23,50 @@ public class INITSTACK extends MainCommand{
public void execute()
{ Thread threadOld = Threadtable.threadlist.get(MainCommand.CT.get());
threadOld.getStack().push("",""); // neue Zelle auf dem alten Stack anlegen
int oldSP = SP.get();
int oldCT = CT.get();
count = MainCommand.TC.get()+1; // neuen Wert ft TC berechnen
int newstackSP = (count*stackspace); // neuen Stackpointer berechnen
MainCommand.CT.set(count); //muss kurzfristig auf den neuen Stack gesetzt werden zur Berechnung der Koordinante
Thread thread = new Thread(count);
Threadtable.threadlist.add(thread);
//Berechnen des neuen Stackpointers (in Abhngigkeit des Stackspaces) und Setzen der Werte
//int newSP = ((count+1)*stackspace); // neuen Stackpointer berechnen
MainCommand.TC.set(count);
//3 neue Zellen auf dem neuen Stack anlegen und fllen
{ Thread threadOld = Threadtable.threadlist.get(MainCommand.CT.get());
count = MainCommand.TC.get()+1; // neuen Wert ft TC berechnen
if(MainCommand.getStacknumber() <= count){
MainCommand.viewMachine.output("stacknumber exceeded");
PC(-1);
}
else{
threadOld.getStack().push("",""); // neue Zelle auf dem alten Stack anlegen
int oldSP = SP.get();
int oldCT = CT.get();
int newstackSP = (count*stackspace); // neuen Stackpointer berechnen
MainCommand.CT.set(count); //muss kurzfristig auf den neuen Wert gesetzt werden zur Berechnung der Koordinante
Thread thread = new Thread(count);
Threadtable.threadlist.add(thread);
MainCommand.TC.set(count); //muss kurzfristig auf den neuen Wert gesetzt werden zur Berechnung der Koordinante
memory.setValue( newstackSP,""); //evtl warten um besser darzustellen?
memory.setIntValue(newstackSP,memory.getIntValue(oldSP-1));
//thread.stack.stackGroup.add(memory.getCell(newstackSP));
memory.setIntValue(newstackSP+1,-1);
//thread.stack.stackGroup.add(memory.getCell(newstackSP+1));
if(MainCommand.viewMachine.labels.containsKey("f")){
int label = ((Integer)MainCommand.viewMachine.labels.get("f")).intValue();
memory.setIntValue(newstackSP+2,label);}
//thread.stack.stackGroup.add(memory.getCell(newstackSP+2));}
else {
memory.setIntValue(newstackSP+2,0);}
memory.setIntValue( oldSP-1, newstackSP+2 );
memory.pointer( oldSP );
MainCommand.TC.set(count-1);
thread.getStack().stackGroup.add( memory.getCell( newstackSP ));
thread.getStack().stackGroup.add( memory.getCell( newstackSP+1 ));
thread.getStack().stackGroup.add( memory.getCell( newstackSP+2 ));
MainCommand.CT.set(oldCT);
threadOld.getStack().pop();
memory.pointer( oldSP-1 );
}
//3 neue Zellen auf dem neuen Stack anlegen und fllen
memory.setValue( newstackSP,"");
memory.setIntValue(newstackSP,memory.getIntValue(oldSP-1));
memory.setIntValue(newstackSP+1,-1);
// Abfrage nach dem Terminierungscode f und setzen der Werte
if(MainCommand.viewMachine.labels.containsKey("f")){
int label = ((Integer)MainCommand.viewMachine.labels.get("f")).intValue();
memory.setIntValue(newstackSP+2,label);}
else {
memory.setIntValue(newstackSP+2,0);}
memory.setIntValue( oldSP-1, newstackSP+2 );
memory.pointer( oldSP );
MainCommand.TC.set(count-1);
thread.getStack().stackGroup.add( memory.getCell( newstackSP ));
thread.getStack().stackGroup.add( memory.getCell( newstackSP+1 ));
thread.getStack().stackGroup.add( memory.getCell( newstackSP+2 ));
MainCommand.CT.set(oldCT);
threadOld.getStack().pop();
memory.pointer( oldSP-1 );
}
}
}
......@@ -16,24 +16,20 @@ public class INITTHREAD extends MainCommand{
int oldSP = MainCommand.SP.get();
int count = MainCommand.TC.get();
//Anlegen eines neuen Threads und Einreihen in die ReadyQueue
//Einreihen des neuen Threads in die ReadyQueue
MainCommand.TC.set(count+1);
Thread thread = Threadtable.threadlist.get(MainCommand.TC.get());
ReadyQueue.enqueue(thread.getTid());
//Berechnen des neuen Stackpointers (in Abhngigkeit des Stackspaces) und Setzen der Werte
int newSP = ((count+1)*stackspace); // neuen Stackpointer berechnen
thread.SP = newSP+2;
thread.PC = memory.getIntValue(oldSP-1);
thread.FP = newSP+2;
Thread threadold = Threadtable.threadlist.get(MainCommand.CT.get());
memory.setIntValue(oldSP-1, count+1);
threadold.getStack().pop(); // die oberste Zeile des aufrufenden Stacks wird gepoppt
threadold.getStack().pop();
//anlegen des JTable Eintrags
JTableElement jt = new JTableElement(count+1);
......
......@@ -28,7 +28,6 @@ public class JOIN extends MainCommand {
if(!ReadyQueue.readyQueue.isEmpty()){
int threadnewTid = ReadyQueue.readyQueue.get(0).getIntValue();
ReadyQueue.next();
Thread threadnew = Threadtable.threadlist.get(threadnewTid);
threadold.save();
CT.set(threadnew.tid);
......
package vam.machines.tma;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.awt.Point;
import javax.swing.*;
import vam.base.*;
public class JTableElement{
......@@ -17,7 +13,7 @@ public class JTableElement{
ReadyQueue threadID;
String name;
int value;
public List<ReadyQueue> waitingQueueList;
public List<ReadyQueue> elementList;
public static List<JTableElement> jTable = new LinkedList<JTableElement>();
......@@ -31,21 +27,20 @@ public class JTableElement{
public JTableElement( int tid)
{
waitingQueueList = new LinkedList<ReadyQueue>();
elementList = new LinkedList<ReadyQueue>();
this.nextLocation = startLocation.getLocation();
this.nextLocation.translate(0,Cell.stdHeight*tid*2+Cell.stdHeight);
threadID = new ReadyQueue ("TID: ", "JTable", this.nextLocation,true);
threadID.setValue(tid);
waitingQueueList.add(threadID);
elementList.add(threadID);
this.nextLocation.translate(40,0);
ReadyQueue rv = new ReadyQueue("RV: ", "Register", this.nextLocation,true);
rv.setValue(-1);
waitingQueueList.add(rv);
//wq = new ArrayList<ReadyQueue>();
elementList.add(rv);
this.nextLocation = startLocation.getLocation();
this.nextLocation.translate(0, Cell.stdHeight*tid*2+2*Cell.stdHeight);
ReadyQueue wq = new ReadyQueue("WQ: ", "JTable",this.nextLocation,true);
waitingQueueList.add(wq);
elementList.add(wq);
this.nextLocation.translate(40,0);
}
......@@ -56,28 +51,29 @@ public class JTableElement{
*/
public JTableElement(int tid, List<Integer> values) {
waitingQueueList = new LinkedList<ReadyQueue>();
elementList = new LinkedList<ReadyQueue>();
this.nextLocation = startLocation.getLocation();
this.nextLocation.translate(0,Cell.stdHeight*tid*2+Cell.stdHeight);
ReadyQueue t = new ReadyQueue ("TID: ", "JTable", this.nextLocation,true);
t.setValue(tid);
waitingQueueList.add(t);
elementList.add(t);
this.nextLocation.translate(40,0);
ReadyQueue rv = new ReadyQueue("RV: ", "Register", this.nextLocation,true);
rv.setValue(values.get(1));
waitingQueueList.add(rv);
elementList.add(rv);
this.nextLocation = startLocation.getLocation();
this.nextLocation.translate(0, Cell.stdHeight*tid*2+2*Cell.stdHeight);
ReadyQueue wq = new ReadyQueue("WQ: ", "JTable",this.nextLocation,true);
waitingQueueList.add(wq);
elementList.add(wq);
this.nextLocation.translate(40,0);
int i = 0;
// Aufbau der Waiting-Queue
for(Integer current:values){
if(i++<3){continue;}
ReadyQueue q = new ReadyQueue("","RQ2",this.nextLocation,true);
this.nextLocation.translate(20,0);
q.setIntValue(values.get(i-1));
this.waitingQueueList.add(q);
q.setIntValue(current);
this.elementList.add(q);
}
}
......@@ -92,15 +88,15 @@ public class JTableElement{
ReadyQueue r = new ReadyQueue("","RQ2",this.nextLocation,true);
this.nextLocation.translate(20,0);
r.setIntValue(value);
this.waitingQueueList.add(r);
this.elementList.add(r);
}
// nimmt das erste Element aus der WQ und baut die Liste neu auf
public void next(){
List<Integer> restore = new LinkedList<Integer>();
int tid = this.waitingQueueList.get(0).getIntValue();
for(ReadyQueue current:this.waitingQueueList){
int tid = this.elementList.get(0).getIntValue();
for(ReadyQueue current:this.elementList){
restore.add(current.get());
ReadyQueue.rqGroup.remove(current);
current.remove();
......
......@@ -12,6 +12,7 @@ public class JUMPI extends MainCommand
public void execute()
{
PC(address + parseInt(stack.pop()));
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
PC(address + parseInt(thread.getStack().pop()));
}
}
......@@ -13,7 +13,6 @@ public class JUMPZ extends MainCommand
public void execute()
{
//if( parseInt(thread.stack.pop()) == 0 ) PC(address);
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
if( parseInt(thread.getStack().pop()) == 0 ) PC(address);
......
......@@ -13,7 +13,6 @@ public class LE extends MainCommand
{
int op2 = memory.getIntValue( SP() );
int op1 = memory.getIntValue( SP()-1 );
//stack.binaryOperation( "LE", op1<op2 ? 1 : 0 );
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().binaryOperation( "LE", op1<op2 ? 1 : 0 );
}
......
......@@ -15,7 +15,6 @@ public class LEQ extends MainCommand
int op2 = memory.getIntValue( SP() );
int op1 = memory.getIntValue( SP()-1 );
int result = ( op1<=op2 ? 1 : 0 );
//stack.binaryOperation( "LEQ", op1<=op2 ? 1 : 0 );
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().binaryOperation( "LEQ", op1<=op2 ? 1 : 0 );
}
......
package vam.machines.tma;
public class LOAD extends MainCommand
{ // l�dt den Wert der Speicherzelle, deren Adresse oben auf dem Stack liegt,
{ // ldt den Wert der Speicherzelle, deren Adresse oben auf dem Stack liegt,
// in die oberste Stackzelle
public LOAD()
{
......
......@@ -13,7 +13,6 @@ public class LOADC extends MainCommand
public void execute()
{
//stack.push( argument );
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().push( argument );
}
......
......@@ -14,7 +14,8 @@ public class LOADR extends MainCommand
public void execute()
{
int absoluteAddress = FP()+address; // Adresse berechnen
stack.push( absoluteAddress ); // Adresse auf den Stack legen
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().push( absoluteAddress ); // Adresse auf den Stack legen
memory.pointer( SP() ); // top als Zeiger markieren
memory.store( absoluteAddress, SP() ); // top durch Kopie der Zelle mit Adresse 'address' ersetzen
if(memory.isPointer(absoluteAddress)) {
......
......@@ -18,7 +18,7 @@ public class LOCK extends MainCommand {
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().pop();
}
else{for (int i = 0; i<MainCommand.getStacknumber()-1;i++){
else{for (int i = 0; i<MainCommand.getStacknumber();i++){
if (memory.getValue(pointer+i+1)==""){
memory.setIntValue(pointer+i+1, MainCommand.CT.get());
break;
......@@ -29,7 +29,7 @@ public class LOCK extends MainCommand {
Thread thread = Threadtable.threadlist.get(MainCommand.CT.get());
thread.getStack().pop();
//next
//nchsten Thread aktiv setzen
Thread threadold = Threadtable.threadlist.get(MainCommand.CT.get());
int threadnewTid = ReadyQueue.readyQueue.get(0).getIntValue();
ReadyQueue.next();
......
package vam.machines.tma;
import java.awt.Point;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
......@@ -7,201 +9,188 @@ import vam.base.*; // Basispaket zur Visualisierung
import vam.util.Stack; // Kellerspeicher