From 3a438472d0fc26b40496fd72ede8122f0b6e0bfe Mon Sep 17 00:00:00 2001 From: Tr1xt4n Date: Tue, 28 Mar 2023 08:39:19 +0200 Subject: [PATCH] scheduleing +1param --- src/main/java/fr/ntr/scheduler/MaxSNR.java | 13 ++++++------- .../java/fr/ntr/scheduler/ProportionalFair.java | 4 +++- src/main/java/fr/ntr/scheduler/RoundRobin.java | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/fr/ntr/scheduler/MaxSNR.java b/src/main/java/fr/ntr/scheduler/MaxSNR.java index a76961e..d1f7e40 100644 --- a/src/main/java/fr/ntr/scheduler/MaxSNR.java +++ b/src/main/java/fr/ntr/scheduler/MaxSNR.java @@ -26,13 +26,12 @@ public class MaxSNR extends Scheduler { if (userMax.getPacketsToSend().size() != 0) { Packets p = userMax.getPacketsToSend().get(0); userMax.getPacketsSent().add(p); - if(p.getDurationSending() != 0){ - if(p.getBitsNumberRemaining() > 0){ - p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]); - } else { - p.setDurationSending(ticks); - } - } + if(p.getBitsNumberRemaining() > 0){ + p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]); + } else { + p.setDurationSending(ticks); + } + userMax.getPacketsToSend().remove(p); frame[ts][sp].setUser(userMax); frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]); diff --git a/src/main/java/fr/ntr/scheduler/ProportionalFair.java b/src/main/java/fr/ntr/scheduler/ProportionalFair.java index 7ce759e..e7cd1fe 100644 --- a/src/main/java/fr/ntr/scheduler/ProportionalFair.java +++ b/src/main/java/fr/ntr/scheduler/ProportionalFair.java @@ -7,6 +7,8 @@ import fr.ntr.ResourceBlock; import fr.ntr.User; public class ProportionalFair extends Scheduler { + + private List users; private ResourceBlock[][] frame; @@ -17,7 +19,7 @@ public class ProportionalFair extends Scheduler { } @Override - public void scheduling() { + public void scheduling(int ticks) { ArrayList averageBandwiths = new ArrayList(); for(User u : users){ double avg = 0d; diff --git a/src/main/java/fr/ntr/scheduler/RoundRobin.java b/src/main/java/fr/ntr/scheduler/RoundRobin.java index db4a3e5..6ba2cb8 100644 --- a/src/main/java/fr/ntr/scheduler/RoundRobin.java +++ b/src/main/java/fr/ntr/scheduler/RoundRobin.java @@ -28,7 +28,7 @@ public class RoundRobin extends Scheduler { * Return */ @Override - public void scheduling() { + public void scheduling(int ticks) { //selection aleatoire du premier utilisateur Random random = new Random(); index = random.nextInt(users.size());