Research Article

An Application-Level QoS Control Method Based on Local Bandwidth Scheduling

Algorithm 2

Bandwidth dynamic scheduling method (the second allocation).
Input: The unallocated tokens after the first allocation ()
Output: The second token allocation policy ()
(1) SecondAllocation ()
(2) Obtain the running Web processes not listed in
(3) the priority database and mark them as
(4) Initialize the second allocation policy
(5) FOR i=0 to COUNT()-1 // Retrieve each process
(6) Mark the bucket of process in as Bi
(7) IF ((Bi) < (Bi)) // Bucket is not full
(8) // Ti is the remaining capacity of Bi
(9) Ti = (Bi) - (Bi)
(10) Initialize the allocation policy (allocation) for Bi
(11) // Set the BUCKET member of allocation (token ID)
(12) allocation.BUCKET = Bi
(13) // Set the TOKEN member of allocation (token count).
(14) // This value may be modified in the following steps.
(15) allocation.TOKEN = allocation.TOKEN + Ti
(16) Add allocation into the second allocation policy
(17) Delete allocated tokens from
(18)
(19)
(20) // Calculate how many tokens each process can get
(21) // using average allocation policy
(22) IF (COUNT() > 0)
(23) AVE = COUNT() / COUNT()
(24)
(25) // Loop through to update the token count for
(26) // each allocation
(27) FOR k=0 to COUNT()-1
(28) Mark the item of as Ak
(29) // update the token count using the average value
(30) Ak.TOKEN = Ak.TOKEN +
(31) MIN((Ak) - (Ak), AVE)
(32) Delete the allocated tokens from
(33)
(34) IF (COUNT() == 0) // Token allocation finished
(35) RETURN
(36)
(37) ELSE // Still have unallocated tokens
(38) // Try to allocate the remaining tokens to all the running
(39) // Web processes regardless of their existence in the
(40)// priority database through token borrowing
(41) Get all the running Web process Lp and sort it in descending order of priority
(42) FOR j=0 to COUNT(Lp)-1
(43) Mark the bucket of the jth process in Lp as Mj
(44) IF ((Mj) < (Mj)) // Bucket is not full
(45) Get the maxBorrow of the current bucket ()
(46) IF ( > 0) // Can borrow more tokens
(47) // Tj is the remaining capacity of Mj
(48) Tj = (Mj) - (Mj)
(49) Initialize allocation for Mj
(50) // Set the BUCKET member of allocation (token ID)
(51) allocation.BUCKET = Mj
(52) // Set the TOKEN member of allocation (token count)
(53) allocation.TOKEN = allocation.TOKEN +
(54) MIN(COUNT(), Tj, )
(55) Add allocation into the second allocation policy
(56) Subtract the count of allocated tokens from the token
(57) borrowing parameter ()
(58) Delete the allocated tokens from
(59) IF (COUNT() == 0) // Token allocation finished
(60) RETURN
(61)
(62)
(63)
(64)
(65)
(66) RETURN null
(67)