Input :  :jobs running in fg VMs;
     :jobs running in bg VMs;
     :jobs waiting in the queue.
(1) begin
(2) / * Make reservation for the first job in , then backfill */
(3)  let = 0 (shadow time), = 0 (extra fg VM number);
(4)   first job in ; process number of ;
(5)   current idle fg VM number;
(6)  if     then
(7)   Sort in ascending order of their termination time;
(8)    for     do
(9)    processe number in ; ;
(10)   if     then
(11)       = the termination time of ; = ;
(12)     break;
(13)  else
(14)     the jobs running in the foreground VMs of ;
(15)     the size sum of jobs in ;
(16)     = last termination time of jobs in ;
(17)     = + ;
(18)  / * Backfill runnable jobs */
(19)  for     do
(20)     processe number ; idle fg VM number;
(21)    if     then
(22)   continue;
(23)     the runtime of ; current time;
(24)    if   ( ) or   then
(25)   if Deploy (j, 'R')  then
(26)     remove from or , insert it into ;
(27)   if      then
(28)      = ;
Algorithm 3: REASY Backfilling.