Input: The tokens generated by generator (Ltoken) |
Output: The first token allocation policy (Lallocation) |
(1) FirstAllocation (Ltoken) |
(2) Obtain the running Web process list Lprocess |
(3) Query the priorities of processes in Lprocess in the |
(4) priority database |
(5) Sort Lprocess in descending order of priority |
(6) Initialize the first allocation policy Lallocation |
(7) FOR i=0 to COUNT(Lprocess)-1 |
(8) Mark the bucket of process in Lprocess as Bi |
(9) IF ((Bi) < (Bi)) |
(10) // Non-full bucket |
(11) Get the bandwidth Vi for the corresponding |
(12) process in the priority database |
(13) IF (Vi != null) // Process exists in the priority database |
(14) // Ti is the remaining capacity of Bi |
(15) Ti = (Bi) - (Bi) |
(16) Initialize the allocation policy (allocation) for Bi |
(17) // Set the bucket member of allocation (token ID) |
(18) allocation.BUCKET = Bi |
(19) // Set the TOKEN member of allocation (token count) |
(20) // Add the smaller one between 1.2Vi and Ti to the |
(21) // current token bucket |
(22) allocation.TOKEN = allocation.TOKEN+MIN(Ti, 1.2Vi) |
(23) Add allocation into the first allocation policy Lallocation |
(24) Delete the allocated tokens from Ltoken |
(25) |
(26) ELSE // All processes in priority database checked |
(27) // A null value of Vi means that the corresponding process |
(28) // of Bi does not exist in the priority database and the |
(29) // remaining processes do not exist in the database |
(30) // either.These processes won’t be allocated any tokens |
(31) // in the first allocation. |
(32) RETURN Lallocation |
(33) |
(34) |
(35) |
(36) RETURN Lallocation // All processes checked |
(37) |