找个问题后发现这个问题很简单,但就是好几百行的代码一点点去找浪费了好几个小时。
本来是对俩个任务数组分别进行判断,不知道开始脑子在想什么,我竟然用了用了一个if和四个else if去判断,这样如果前面的一个判断对一个任务数组判断后,其他的就不会再对第二个任务数组进行判断了。如果是在一个小程序里这个错误太好发现了,但是代码行一多,我足足找了三四个小时。改成了五个if或者改成2个if和elseif结构也可以。还是基础有问题。下面贴错误代码。(简洁以后的,原来的太长了)
if(T7[0].getState()==1&&(T7[0].getEndtime()==-2)){ if (T7[0].getCpus() <= (newVM->unUseVM(newVM))) { int temp = T7[0].getCpus(); int proc[100][2]; for (int l = 0; l < 100; ++l) { for (int k = 0; k < 2; ++k) { proc[l][k] = -1; } } VM_WAIT1=0; }else{ VM_WAIT1=1; cout<<"@@@@@111"<<endl; cout<<T7[0].getTid()<<endl; } }else if(T7[0].getState()==2&&(T7[0].getEndtime()==-2)){ if (T7[0].getCpus() <= (newVM->unUseVM(newVM))) { int temp = T7[0].getCpus(); int proc[100][2]; for (int l = 0; l < 100; ++l) { for (int k = 0; k < 2; ++k) { proc[l][k] = -1; } } VM_WAIT1=0; } else{ VM_WAIT1=1; cout<<"@@@@@222"<<endl; cout<<T7[0].getTid()<<endl; } }else if(T7[1].getState()==3&&(T7[1].getEndtime()==-2)){ if (T7[1].getCpus() <= (newCluster->unUseCluster(newCluster))) { int temp = T7[1].getCpus(); int proc[100][2]; for (int l = 0; l < 100; ++l) { for (int k = 0; k < 2; ++k) { proc[l][k] = -1; } } Node_WAIT3=0; } else{ Node_WAIT3=1; cout<<"@@@@@333"<<endl; cout<<T7[1].getTid()<<endl; } }else if(T7[0].getState()==4&&(T7[0].getEndtime()==-2)){ if (T7[0].getCpus() <= (newVM->unUseVM(newVM))) { int temp = T7[0].getCpus(); int proc[100][2]; for (int l = 0; l < 100; ++l) { for (int k = 0; k < 2; ++k) { proc[l][k] = -1; } } VM_WAIT1=0; } else{ VM_WAIT1=1; cout<<"@@@@@444"<<endl; cout<<T7[0].getTid()<<endl; } }else if(T7[1].getState()==5&&(T7[1].getEndtime()==-2)){ if (T7[1].getCpus() <= (newCluster->unUseCluster(newCluster))) { int temp = T7[1].getCpus(); int proc[100][2]; for (int l = 0; l < 100; ++l) { for (int k = 0; k < 2; ++k) { proc[l][k] = -1; } } Node_WAIT3=0; } else{ Node_WAIT3=1; cout<<"@@@@@555"<<endl; cout<<T7[1].getTid()<<endl; } } }