Abstract:
A multi processor task allocation method is described that considers task dependencies while performing task allocation in order to avoid blocking of a task&#39;s execution while waiting for the resolution of the dependency. While allocating the tasks to the processors the potential blocking time is considered, and the best allocation that will have the least amount of blocking time is found.

Description:
BACKGROUND OF THE INVENTION 
       [0001]    This invention considers the task allocation problem in a multi-processor system. Given a set of software tasks to be run in a multi-processor system, the software tasks are normally distributed to the individual processors. The tasks allocation is usually done statically, and tasks do not migrate across the processors. 
         [0002]    The task allocation algorithms attempt to maximize aggregate performance of task executions of the multiple processors while performing task allocation. Traditional algorithms for task allocation have dealt mostly with independent tasks with no interactions. However, in real life scenarios, tasks are dependent on each other and such dependencies slow down the progress of task execution especially if the tasks reside in different processors. As a result, the aggregate performance of M processors does not converge to M times the performance of a single processor, which is well known limitation of multi-processor systems. 
         [0003]    The task allocation method described in this invention considers task dependencies while performing task allocation. The task dependency can cause blocking of a task execution while waiting for the resolution of the dependency. While allocating the tasks to the processors, the potential blocking time is considered, and finding the best allocation that will have least blocking time is attempted to achieve maximum system performance. 
       SUMMARY OF THE INVENTION 
       [0004]    If two tasks sharing the same resource are allocated to different processors, blocking of a task execution can occur if the two tasks try to access the shared resource at the same time. On the other hand, if the tasks are allocated to the same processor, only one of those two tasks is executed at a time—because they are in a single processor, and the access to the shared resource access is naturally arbitrated. 
         [0005]    A novel task allocation method is shown that analyzes the worst-case blocking time of tasks considering the dependencies and minimizes it by assigning tasks depending on each other to the same processor. In addition, we also try to balance the utilization of the processors, which is the goal of conventional load-balancing based task allocation algorithms. 
         [0006]    The invention consists of two parts: A method of analyzing the blocking time of each task, and a method of task allocation based on the analyzed blocking time. 
     
    
     DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS 
       [0007]    A uniform multi-processor architecture is assumed, where all processors have equal processing capabilities, and that task allocation is done statically at once and tasks do not migrate across the processors. 
         [0008]    The processors are assumed to use Multi-processor Priority Ceiling Protocol (MPCP) in order to provide resource sharing across tasks. The goal of this protocol is to prevent the formation of deadlocks and of chained blocking. The underlying idea of this protocol is to ensure that when a job J preempts the critical section of another job and executes its own critical section z, the priority at which this new critical section z will execute is guaranteed to be higher than the inherited priorities of all the preempted critical sections. If this condition cannot be satisfied, job J is denied entry into the critical section z and suspended, and the job that blocks J inherits J&#39;s priority. This idea is accomplished by first assigning a priority ceiling to each semaphore, which is equal to the highest priority task that may use this semaphore. We then allow a job J to start a new critical section only if J&#39;s priority is higher than all priority ceilings of all the semaphores locked by jobs other than J. 
         [0009]    Unless we assume the use of MPCP, the system can be placed in deadlock situation if multiple tasks try to access the same shared resource. In consequence, we cannot bound the blocking time, in other words, the worst-case blocking time is infinite. 
         [0010]    Two different types of execution control policies are considered: MPCP-suspend and MPCP-spinning. In MPCP-suspend, a task will be suspended if the task fails to gain the shared resource. With this policy, another task can be executed while the task that has failed to access the shared resource is suspended. In MPCP-spinning, a task will be polling the shared resource until it succeeds to gain the access of the shared resource. With this policy, the processor is held by the task so only a higher priority task can preempt the task. The blocking time for those two different policies are analyzed. 
         [0011]    We consider periodic real-time tasks τ={τ 1 , . . . , τ n }. Each task τ i =(C i , T i , D i ) is characterized by three parameters: the worst-case execution time (WCET) C i , period T i , and deadline D i . The following is assumed:
       The C, T, and D parameters are known a priori.   The scheduler uses fixed-priority scheduling with tasks having conventional deadline monotonic scheduling priorities.       
 
         [0014]    While a task is being executed, it may access a global shared resource. We call such section of a task a critical section. The rest of the typical execution part is called normal section. A critical section of a task is the part which can generate contention due to shared resource access. We will assume that a task may have multiple critical sections, and we assume that the critical sections are not nested. Based on these assumptions, we can model the execution time of a task, C, as an alternating sequence of normal execution sections and critical sections as shown below. 
         [0000]      τ i : ((C 1,1 , C′ i,1 , C i,2 , C′ i,2 , . . . , C′ i,s(i)-1 , C i,s(i) ), T i )
       where,   s(i): number of normal execution segments of τ i .   s(i)−1: is the number of critical section execution segments of τ i .   C i,j : WCET of the jth normal execution of τ i .   C′ i,k : WCET of the kth critical section of τ i .   T i  denotes the period of τ i  (with implicit deadline).   τ i,j  denotes the j-th normal execution segment of task τ i .   τ′ i,j  denotes the j-th critical section of task τ i .       
 
         [0023]    We assume that the tasks are ordered in increasing order of priorities i.e. i&lt;j implies that τ j  has higher priority than τ i . 
         [0024]    The following symbols are used as defined below.
       P i =i-th processor   P(□ i )=The processor index assigned to □ i      R(□′ i,j )=The resource accessed in a critical section □′ i,j      C i =Sum of all the normal and critical sections of ti,       
 
         [0000]    
       
         
           
             
               C 
               i 
             
             = 
             
               
                 
                   ∑ 
                   
                     j 
                     = 
                     1 
                   
                   
                     s 
                      
                     
                       ( 
                       i 
                       ) 
                     
                   
                 
                  
                 
                   C 
                   
                     i 
                     , 
                     j 
                   
                 
               
               + 
               
                 
                   ∑ 
                   
                     k 
                     = 
                     1 
                   
                   
                     
                       s 
                        
                       
                         ( 
                         i 
                         ) 
                       
                     
                     - 
                     1 
                   
                 
                  
                 
                   C 
                   
                     i 
                     , 
                     k 
                   
                   ′ 
                 
               
             
           
         
       
       
         
           
             B r =Remote blocking time 
           
         
       
     
         [0030]    First the MPCP Suspend mode is analyzed. Blocking time is an additional delay while executing a critical section of a task. We will think of an execution time of the k-th critical section of □ i , or □′ i,k . At the time of starting execution of □′ i,k , it will either be started right away or need to wait for some time, depending on whether the global resource the critical section tries to use is locked by another task or not. If the global resource is free to use, the □′ i,k  will start right away. And MPCP guarantees that the task continues execution without interference until the end of the current critical section. 
         [0031]    On the other hand, if the global resource is already locked by another task in another processor, □ i  has to be suspended or blocked until the global resource is released. The blocking can happen either by a lower priority task or by higher priority tasks. 
         [0032]    First, let us consider the blocking by lower priority tasks. In the case of blocking by a lower priority task, the blocking occurs at most one time per each critical section execution and no nested blocking is possible because MPCP prevents any priority inversion. In more detail, the only blocking scenario that can be caused by a lower priority task, say □′ l,u , is the very initial start time of the □′ i,k , where □ l  has already occupied the shared resource, so the □ i  has to wait □ l , which is called a priority inversion scenario. No other lower priority task can win the resource because the scheduler will give the priority to □ i  which is a higher priority task. 
         [0033]    Therefore, the worst case blocking time by lower priority tasks is the maximum critical section response time of all the lower priority tasks. We call the worst case response time of □′ i,k  as W′ i,k . Then, the worst-case blocking time of □′ i,k  caused by lower priority tasks, or B i,k   r     —     low  is represented by the Equation (1). 
         [0000]    
       
         
           
             
               
                 
                   
                     B 
                     
                       i 
                       , 
                       k 
                     
                     
                       r 
                        
                       
                           
                       
                        
                       _ 
                        
                       
                           
                       
                        
                       low 
                     
                   
                   = 
                   
                     
                       max 
                       
                         
                           
                             
                               l 
                               ≤ 
                               
                                   
                               
                                
                               i 
                             
                              
                             
                                 
                             
                             &amp; 
                           
                            
                           
                               
                           
                            
                           
                             ( 
                             
                               τ 
                               
                                 l 
                                 , 
                                 u 
                               
                               ′ 
                             
                             ) 
                           
                         
                         ∈ 
                         
                           R 
                            
                           
                             ( 
                             
                               τ 
                               
                                 i 
                                 , 
                                 k 
                               
                               ′ 
                             
                             ) 
                           
                         
                       
                     
                      
                     
                       ( 
                       
                         W 
                         
                           l 
                           , 
                           u 
                         
                         ′ 
                       
                       ) 
                     
                   
                 
               
               
                 
                   ( 
                   1 
                   ) 
                 
               
             
           
         
       
     
         [0034]    Note that the response time of a critical section, or W′ l,u , in (1) should include both of actual execution time of □′ l,u  and all possible preemption time caused by higher priority task. Because the task □ l  is executing a critical section, the preemption is possible only by same processor tasks in critical mode: a task in a processor cannot preempt a task in another processor, therefore only the same processor tasks can cause preemption. And a task in a critical mode has always higher priority than any other tasks in normal mode by MPCP algorithm. Therefore the preemption is caused by tasks having higher global ceiling priority. In summary, the worst-case response time of □′ i,k , which we call W′ i,k , is represented by Equation (2). 
         [0000]    
       
         
           
             
               
                 
                   
                     W 
                     
                       i 
                       , 
                       k 
                     
                     ′ 
                   
                   = 
                   
                     
                       
                         Pure 
                          
                         
                             
                         
                          
                         execution 
                          
                         
                             
                         
                          
                         time 
                          
                         
                             
                         
                          
                         of 
                          
                         
                             
                         
                          
                         the 
                          
                         
                             
                         
                          
                         critical 
                          
                         
                             
                         
                          
                         section 
                       
                        
                       
                           
                       
                       + 
                       
                           
                       
                        
                       
                         all 
                          
                         
                             
                         
                          
                         possible 
                          
                         
                             
                         
                          
                         preemptions 
                          
                         
                             
                         
                          
                         by 
                          
                         
                             
                         
                          
                         higher 
                          
                         
                             
                         
                          
                         global 
                          
                         
                             
                         
                          
                         ceiling 
                          
                         
                             
                         
                          
                         priority 
                          
                         
                             
                         
                          
                         tasks 
                          
                         
                             
                         
                          
                         in 
                          
                         
                             
                         
                          
                         the 
                          
                         
                             
                         
                          
                         same 
                          
                         
                             
                         
                          
                         processor 
                       
                     
                     = 
                     
                       
                         C 
                         
                           i 
                           , 
                           k 
                         
                         ′ 
                       
                       + 
                       
                         
                           ∑ 
                           
                             
                               τ 
                               u 
                             
                             ∈ 
                             
                               P 
                                
                               
                                 ( 
                                 
                                   τ 
                                   i 
                                 
                                 ) 
                               
                             
                           
                         
                          
                         
                           
                             max 
                             
                               
                                 
                                   
                                     1 
                                     ≤ 
                                     v 
                                     ≤ 
                                     
                                       s 
                                        
                                       
                                         ( 
                                         u 
                                         ) 
                                       
                                     
                                   
                                    
                                   
                                       
                                   
                                   &amp; 
                                 
                                  
                                 
                                     
                                 
                                  
                                 gc 
                                  
                                 
                                     
                                 
                                  
                                 
                                   ( 
                                   
                                     u 
                                     , 
                                     v 
                                   
                                   ) 
                                 
                               
                               &gt; 
                               
                                 gc 
                                  
                                 
                                   ( 
                                   
                                     i 
                                     , 
                                     k 
                                   
                                   ) 
                                 
                               
                             
                           
                            
                           
                             C 
                             
                               v 
                               , 
                               m 
                             
                             ′ 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   2 
                   ) 
                 
               
             
           
         
       
     
         [0035]    Using Equations (1) and (2), we can calculate the blocking time that can be caused by lower priority tasks. 
         [0036]    Next we consider the blocking time that can be caused by higher priority tasks, or B i,k   r     —     high . The key difference from the blocking time by lower priority is that potentially all of the high priority task can cause blocking if all of the high priority tasks compete to gain the same global resource. Therefore, B i,k   r     —     high  is the summation of the possible blockings by all the higher priority tasks as shown Equation (3). 
         [0000]    
       
         
           
             
               B 
               
                 i 
                 , 
                 k 
               
               
                 r 
                  
                 
                     
                 
                  
                 _ 
                  
                 
                     
                 
                  
                 high 
               
             
             = 
             
               
                 ∑ 
                 
                   
                     
                       
                         h 
                         &gt; 
                         
                             
                         
                          
                         i 
                       
                        
                       
                           
                       
                       &amp; 
                     
                      
                     
                         
                     
                      
                     
                       ( 
                       
                         τ 
                         
                           h 
                           , 
                           v 
                         
                         ′ 
                       
                       ) 
                     
                   
                   ∈ 
                   
                     R 
                      
                     
                       ( 
                       
                         τ 
                         
                           i 
                           , 
                           k 
                         
                         ′ 
                       
                       ) 
                     
                   
                 
               
                
               
                 ( 
                 
                   W 
                   
                     h 
                     , 
                     v 
                   
                 
                 ) 
               
             
           
         
       
     
         [0037]    The Equation (3) does not consider a situation where the blocking time is so long that a high priority task may appear multiple times within the blocking time. In other words, if the period of a higher priority task, T h , is longer than the blocking time, the higher priority task can block the □ i  multiple times. Considering this effect, we obtain the Equation (4). 
         [0000]    
       
         
           
             
               
                 
                   
                     
                       B 
                       
                         i 
                         , 
                         k 
                       
                       
                         r 
                          
                         
                             
                         
                          
                         _ 
                          
                         
                             
                         
                          
                         high 
                       
                     
                     = 
                     
                       
                         ∑ 
                         
                           
                             
                               
                                 h 
                                 &gt; 
                                 
                                     
                                 
                                  
                                 i 
                               
                                
                               
                                   
                               
                               &amp; 
                             
                              
                             
                                 
                             
                              
                             
                               ( 
                               
                                 τ 
                                 
                                   h 
                                   , 
                                   v 
                                 
                                 ′ 
                               
                               ) 
                             
                           
                           ∈ 
                           
                             R 
                              
                             
                               ( 
                               
                                 τ 
                                 
                                   i 
                                   , 
                                   k 
                                 
                                 ′ 
                               
                               ) 
                             
                           
                         
                       
                        
                       
                         
                           ( 
                           
                             
                               
                                 ⌈ 
                                 
                                   B 
                                   
                                     i 
                                     , 
                                     k 
                                   
                                   r 
                                 
                                 ⌉ 
                               
                               
                                 T 
                                 h 
                               
                             
                             + 
                             1 
                           
                           ) 
                         
                          
                         
                           ( 
                           
                             W 
                             
                               h 
                               , 
                               v 
                             
                           
                           ) 
                         
                       
                     
                   
                   , 
                 
               
               
                 
                   ( 
                   4 
                   ) 
                 
               
             
           
         
       
     
         [0038]    where B r =B r     —     high +B r     —     low . 
         [0039]    Combining (1) and (4), we obtain the following equation (5). 
         [0000]    
       
         
           
             
               B 
               
                 i 
                 , 
                 k 
               
               r 
             
             = 
             
               
                 
                   max 
                   
                     
                       
                         
                           1 
                           &lt; 
                           i 
                         
                          
                         
                             
                         
                         &amp; 
                       
                        
                       
                           
                       
                        
                       
                         ( 
                         
                           τ 
                           
                             l 
                             , 
                             u 
                           
                           ′ 
                         
                         ) 
                       
                     
                     ∈ 
                     
                       R 
                        
                       
                         ( 
                         
                           τ 
                           
                             i 
                             , 
                             k 
                           
                           ′ 
                         
                         ) 
                       
                     
                   
                 
                  
                 
                   ( 
                   
                     W 
                     
                       l 
                       , 
                       u 
                     
                   
                   ) 
                 
               
               + 
               
                 
                   ∑ 
                   
                     
                       
                         
                           h 
                           &gt; 
                           i 
                         
                         &amp; 
                       
                        
                       
                         ( 
                         
                           τ 
                           
                             h 
                             , 
                             v 
                           
                           ′ 
                         
                         ) 
                       
                     
                     ∈ 
                     
                       R 
                        
                       
                         ( 
                         
                           τ 
                           
                             i 
                             , 
                             k 
                           
                           ′ 
                         
                         ) 
                       
                     
                   
                 
                  
                 
                   
                     ( 
                     
                       
                         
                           ⌈ 
                           
                             B 
                             
                               i 
                               , 
                               k 
                             
                             r 
                           
                           ⌉ 
                         
                         
                           T 
                           h 
                         
                       
                       + 
                       1 
                     
                     ) 
                   
                    
                   
                     ( 
                     
                       W 
                       
                         h 
                         , 
                         v 
                       
                     
                     ) 
                   
                 
               
             
           
         
       
     
         [0040]    Equation (5) is a recursive equation where B r  term is defined by B r . To solve this equation, we convert Equation (5) into a convergence equation (6) as shown below. 
         [0000]    
       
         
           
             
               B 
               
                 i 
                 , 
                 k 
               
               
                 r 
                 , 
                 
                   n 
                   + 
                   1 
                 
               
             
             = 
             
               
                 
                   max 
                   
                     
                       
                         
                           1 
                           &lt; 
                           i 
                         
                          
                         
                             
                         
                         &amp; 
                       
                        
                       
                           
                       
                        
                       
                         ( 
                         
                           τ 
                           
                             l 
                             , 
                             u 
                           
                           ′ 
                         
                         ) 
                       
                     
                     ∈ 
                     
                       R 
                        
                       
                         ( 
                         
                           τ 
                           
                             i 
                             , 
                             k 
                           
                           ′ 
                         
                         ) 
                       
                     
                   
                 
                  
                 
                   ( 
                   
                     W 
                     
                       l 
                       , 
                       u 
                     
                   
                   ) 
                 
               
               + 
               
                 
                   ∑ 
                   
                     
                       
                         
                           h 
                           &gt; 
                           i 
                         
                         &amp; 
                       
                        
                       
                         ( 
                         
                           τ 
                           
                             h 
                             , 
                             v 
                           
                           ′ 
                         
                         ) 
                       
                     
                     ∈ 
                     
                       R 
                        
                       
                         ( 
                         
                           τ 
                           
                             i 
                             , 
                             k 
                           
                           ′ 
                         
                         ) 
                       
                     
                   
                 
                  
                 
                   
                     ( 
                     
                       
                         
                           ⌈ 
                           
                             B 
                             
                               i 
                               , 
                               k 
                             
                             
                               r 
                               , 
                               n 
                             
                           
                           ⌉ 
                         
                         
                           T 
                           h 
                         
                       
                       + 
                       1 
                     
                     ) 
                   
                    
                   
                     ( 
                     
                       W 
                       
                         h 
                         , 
                         v 
                       
                     
                     ) 
                   
                 
               
             
           
         
       
       
         
           where 
         
       
       
         
           
             
               B 
               
                 i 
                 , 
                 k 
               
               
                 r 
                 , 
                 0 
               
             
             = 
             
               
                 max 
                 
                   
                     
                       
                         1 
                         &lt; 
                         i 
                       
                        
                       
                           
                       
                       &amp; 
                     
                      
                     
                         
                     
                      
                     
                       ( 
                       
                         τ 
                         
                           l 
                           , 
                           u 
                         
                         ′ 
                       
                       ) 
                     
                   
                   ∈ 
                   
                     R 
                      
                     
                       ( 
                       
                         τ 
                         
                           i 
                           , 
                           k 
                         
                         ′ 
                       
                       ) 
                     
                   
                 
               
                
               
                 ( 
                 
                   W 
                   
                     l 
                     , 
                     u 
                   
                 
                 ) 
               
             
           
         
       
     
         [0041]    While computing B r,n+1  using B r,n , we stop the iteration when B r,n+1 =B r,n . B r,n  is the solution of equation (5). 
         [0042]    With MPCP spinning the tasks spin while waiting for the shared resource to be released. This avoids further interference from shared resource requests from lower-priority tasks, which may otherwise be issued during task suspension. As a result, the number of priority inversions per task is restricted to one per lower priority task. Under MPCP-spin, the worst-case computation time of task τ i  is bounded by the convergence of W i  of: 
         [0000]    
       
         
           
             
               
                 
                   
                     W 
                     i 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     
                       C 
                       i 
                       * 
                     
                     + 
                     
                       
                         ∑ 
                         
                           
                             
                               
                                 h 
                                 &lt; 
                                 i 
                               
                               &amp; 
                             
                              
                             
                               τ 
                               h 
                             
                           
                           ∈ 
                           
                             P 
                              
                             
                               ( 
                               
                                 τ 
                                 i 
                               
                               ) 
                             
                           
                         
                       
                        
                       
                         
                            
                           
                             
                               W 
                               i 
                               n 
                             
                             
                               T 
                               h 
                             
                           
                            
                         
                          
                         
                           C 
                           h 
                           * 
                         
                       
                     
                     + 
                     
                       
                         ∑ 
                         
                           
                             
                               
                                 l 
                                 &gt; 
                                 i 
                               
                               &amp; 
                             
                              
                             
                               τ 
                               l 
                             
                           
                           ∈ 
                           
                             P 
                              
                             
                               ( 
                               
                                 τ 
                                 i 
                               
                               ) 
                             
                           
                         
                       
                        
                       
                         
                           max 
                           
                             l 
                             ≤ 
                             k 
                             &lt; 
                             
                               s 
                                
                               
                                 ( 
                                 l 
                                 ) 
                               
                             
                           
                         
                          
                         
                           C 
                           
                             l 
                             , 
                             k 
                           
                           ′ 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   7 
                   ) 
                 
               
             
           
         
       
     
         [0043]    As can be seen, spinning reduced the preemptions from global critical sections of lower priority tasks. However, spinning results in additional preemption from higher priority tasks as captured by using the C* h . 
         [0044]    As mentioned earlier global critical sections result in huge penalties on multiprocessor performance. One way to reduce this is to pack synchronizing task together as suggested in the Resource Sharing Aware (RSA) algorithm that bundles tasks sharing resources together to form composite tasks. Then a worst-fit heuristic is applied on the composite as well as the independent tasks. If the composite task does not “fit” into a processor then the tasks are broken apart depending upon the cost of breakage which is the blocking time as given in equation (1). 
         [0045]    The RSA algorithm may be described as follows:
       Inputs:
           ((C i,1 , C′ i,1 , C i,2 , C′ i,2 , . . . , C i,s(i)-1 , C′ i,s(i) ) T i ) of each task τ i , i=1 to n where n is total number of tasks, s(i) is the total number of normal execution segments of τ i , s(i)−1 is the total number of critical section execution segments.   Maximum number of processors ‘m’.   
           Outputs:
           Task allocation TA j  for each of the processors: {M 1 , M 2 , . . . , M m }   
           Algorithm:
           For each task τ i      
               
 
         [0000]      Calculate utilization  u   i   =C   i   /T   i              End for   Combine tasks sharing resources to form composite tasks and calculate the composite task utilization.   Arrange the composite and independent tasks in non-increasing order of their utilization in array ‘A’.   Apply worst-fit-decreasing (WFD) heuristic on the tasks in ‘A’.   Use Response time test for schedulability test.   If schedulability test does not pass for a composite task
               Determine various “breaking costs” of the composite task.   Use equation 1 to determine remote blocking term B r .   Higher the B r , higher the breaking cost.   Break the composite task with lowest B r .