Research Article

Dynamic Resource Allocation for Load Balancing in Fog Environment

Algorithm 4

Load-balance driven global resource allocation.
Input: The fog service set
Output: The resource allocation records
    The occupation records on computing nodes
(1) Obtain fog service subset by Algorithm 1
(2) for to do
(3)  for to do
(4)   Algorithm 3 Static resource allocation for
(5)   Calculate
// CT is the competition time list
// CT =
(6)   for to do
(7)    Update the current run list in
(8)    for to do
(9)     Get spare space by Algorithm 2 at
(10)     if has spare space and is not empty then
(11)      Add to
(12)     end if
(13)    end for
(14)    Sort SL in increasing order of spare space
(15)    flag = 1,
(16)    while flag == 1 do
(17)       Get the occupied resources sets on
(18)      for each occupied resource set do
(19)       Confirm the destination PM
(20)      end for
(21)      if the resource sets can be moved then
(22)       
(23)       Update the relevant allocation records
(24)       Update the occupation records
(25)      else flag = 0
(26)      end if
(27)    end while
(28)   end for
(29)  end for
(30) end for