Fix execution

This commit is contained in:
Quentin Legot 2023-04-07 09:28:10 +02:00
parent 4093336d40
commit de59bc8047
6 changed files with 19 additions and 30 deletions

View File

@ -11,7 +11,7 @@ plugins {
} }
run { run {
args = ["10000", "20"] args = ["10000", "40"]
} }
application { application {

View File

@ -24,11 +24,10 @@ public class AccessPoint {
cell1.updateBandwidth(ticks); cell1.updateBandwidth(ticks);
cell2.updateBandwidth(ticks); cell2.updateBandwidth(ticks);
for(int ts = 0; ts < 2; ts++) { cell1.preScheduling();
for (int sp = 0; sp < 100; sp++) { cell2.preScheduling();
cell1.preScheduling(); for(int ts = 0; ts < Cell.getTimeSlotNb(); ts++) {
cell2.preScheduling(); for (int sp = 0; sp < Cell.getSubCarrierNb(); sp++) {
User user1 = cell1.schedule(ticks, ts, sp); User user1 = cell1.schedule(ticks, ts, sp);
User user2 = cell2.schedule(ticks, ts, sp); User user2 = cell2.schedule(ticks, ts, sp);
if(user1 == user2 && user1 != null) { if(user1 == user2 && user1 != null) {

View File

@ -76,18 +76,19 @@ public class Cell {
public void consumeResource(int tick, int ts, int sp) { public void consumeResource(int tick, int ts, int sp) {
ResourceBlock rb = frame[ts][sp]; ResourceBlock rb = frame[ts][sp];
User user = rb.getUser(); User user = rb.getUser();
Packets p = user.getPacketsToSend().get(user.getPacketsToSend().size()-1); if(user != null && !user.getPacketsToSend().isEmpty()) {
p.decreaseBitsNumberRemaining((int) user.getBandwidthTable()[ts][sp]); Packets p = user.getPacketsToSend().get(0);
if(p.getBitsNumberRemaining() <= 0) { p.decreaseBitsNumberRemaining((int) rb.getBandwidth());
if(tick == 0){ if(p.getBitsNumberRemaining() <= 0) {
p.setDurationSending(1); if(tick == 0){
}else { p.setDurationSending(1);
p.setDurationSending(tick); }else {
p.setDurationSending(tick);
}
user.getPacketsSent().add(p);
user.getPacketsToSend().remove(p);
} }
user.getPacketsSent().add(p);
user.getPacketsToSend().remove(p);
} }
} }
public void analyseData(int tick) throws IOException { public void analyseData(int tick) throws IOException {

View File

@ -110,7 +110,8 @@ public class Main {
System.exit(1); System.exit(1);
} }
} }
executor.close(); executor.close();
System.out.println("Executor closed");
} }
else { else {
System.err.println("Please give launch arguments"); System.err.println("Please give launch arguments");

View File

@ -25,7 +25,6 @@ public class RoundRobin extends Scheduler {
*/ */
@Override @Override
public User scheduling(int ticks, int ts, int sp) { public User scheduling(int ticks, int ts, int sp) {
if(userCopy.isEmpty()) { if(userCopy.isEmpty()) {
return null; return null;
} }
@ -36,7 +35,7 @@ public class RoundRobin extends Scheduler {
@Override @Override
public void postScheduling(User userSelected) { public void postScheduling(User userSelected) {
if(!userSelected.getPacketsToSend().isEmpty()) if(userSelected != null && !userSelected.getPacketsToSend().isEmpty())
userCopy.add(userSelected); userCopy.add(userSelected);
} }

View File

@ -21,17 +21,6 @@ public abstract class Scheduler {
public void allocateRessource(User userMax, int ts, int sp, int ticks) { public void allocateRessource(User userMax, int ts, int sp, int ticks) {
if (userMax != null && !userMax.getPacketsToSend().isEmpty()) { if (userMax != null && !userMax.getPacketsToSend().isEmpty()) {
/* Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1);
p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]);
if(p.getBitsNumberRemaining() <= 0) {
if(ticks == 0){
p.setDurationSending(1);
}else {
p.setDurationSending(ticks);
}
userMax.getPacketsSent().add(p);
userMax.getPacketsToSend().remove(p);
} */
myFrame[ts][sp].setUser(userMax); myFrame[ts][sp].setUser(userMax);
myFrame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]); myFrame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
} }