...
Code Block |
---|
NextSite(A,i) if i is equal to length_of(A) then return A[1] else return A[i+1] |
Code Block |
---|
ChangePriority(A){
x = A[lengthOf(A)]
for i = lengthOf(A)-1 down to 1
A[i+1] = A[i]
i = i -1
A[1] = x
}
|
Wiki Markup |
---|
ChangePriority takes an array as argument and change its priority from N to 1 and increase the other consecutive elements priority by 1. It actually treats an index of an element as its priority. Hence, It copy A\[N\] at A\[1\] and A\[i\] at A\[i+1\] |
Code Block |
---|
GetMaxPriorityElement(A){ return A[lengthOf(A)] } |
Code Block |
---|
Schedule(M,T,X){
while isTokenRecieved() is false
// wait 1 sec for another check
totalBytes = B // B is the total no. of bytes received in Token
while totalBytes > 0
tool = GetHighestPriorityElement(T)
target = GetHighestPriorityElement(X)
exec (tool,target)
totalBytes = totalbytes - tool.bytesRequired
ChangePriority(T)
ChangePriority(X)
sendToken(NextSite(M,i),B)
}
|