add random scheduler

This commit is contained in:
Csaba Kiraly 2023-02-14 02:18:37 +01:00
parent 0f4883bf26
commit 1403ca7ad0
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
1 changed files with 29 additions and 0 deletions

View File

@ -321,6 +321,35 @@ class Validator:
self.sendQueue.popleft()
tries = 100
while tries:
if self.rowIDs:
rID = random.choice(self.rowIDs)
cID = random.randrange(0, self.shape.blockSize)
if self.block.getSegment(rID, cID) :
neigh = random.choice(list(self.rowNeighbors[rID].values()))
if not neigh.sent[cID] and not neigh.receiving[cID] :
neigh.sent[cID] = 1
neigh.node.receiveSegment(rID, cID, self.ID)
self.statsTxInSlot += 1
tries = 100
if self.statsTxInSlot >= self.bwUplink:
return
if self.columnIDs:
cID = random.choice(self.columnIDs)
rID = random.randrange(0, self.shape.blockSize)
if self.block.getSegment(rID, cID) :
neigh = random.choice(list(self.columnNeighbors[cID].values()))
if not neigh.sent[rID] and not neigh.receiving[rID] :
neigh.sent[rID] = 1
neigh.node.receiveSegment(rID, cID, self.ID)
self.statsTxInSlot += 1
tries = 100
tries -= 1
if self.statsTxInSlot >= self.bwUplink:
return
return
for n in self.sched:
neigh = n.neigh
toSend = n.toSend