Scheduling Algorithm: Tasks Scheduling Algorithm for Multiple Processors with Dynamic Reassignment

Distributed computing systems [DCSs] offer the potential for improved performance and resource sharing. To make the best use of the computational power available, it is essential to assign the tasks dynamically to that processor whose characteristics are most appropriate for the execution of the tasks in distributed processing system. We have developed a mathematical model for allocating “M” tasks of distributed program to “N” multiple processors (M > N) that minimizes the total cost of the program. Relocating the tasks from one processor to another at certain points during the course of execution of the program that contributes to the total cost of the running program has been taken into account. Phasewise execution cost [EC], intertask communication cost [ITCT], residence cost [RC] of each task on different processors, and relocation cost [REC] for each task have been considered while preparing a dynamic tasks allocation model. The present model is suitable for arbitrary number of phases and processors with random program structure.


INTRODUCTION
Over the last several years, distributed computing systems have become popular as a very attractive option for fast computing and information processing.Distributed computing system is used to describe a system whenever there are several computers interconnected in some fashion so that a program or procedure runs on the system with multiple processors.In a heterogeneous computing system, the tasks of an application program must be assigned to the heterogeneous processors to utilize the computational capabilities and resources of the system efficiently.However, it is a difficult problem to compute an assignment of tasks to processors for which the total cost of running the program is minimized.Static and dynamic algorithms can be extremely efficient in homogeneous systems.If all processors are identical then the choice "to which node should we assign the next task?"falls on the processor with the fewest outstanding jobs [1].However in heterogeneous distributed environments, where not all nodes have the same parameters, selecting the optimal target processor requires more elaborate algorithms.
Stone [2] has suggested an efficient optimal algorithm for the problem of assigning tasks to two processors by making use of the well-known network flow algorithm in the related two-terminal network graphs.If the structure of a distributed program is constrained in certain ways, it is possible to find the optimal assignment over a system made up of any number of processors in polynomial time.When the structure is constrained to be a tree, the shortest tree algorithm developed by Bokhari [3] yields the optimal assignment.Towsley [4] generalized the results of Bokhari to the case of series-parallel structures.A further generalized program structure is a partial K-tree in which trees are partial l-tree and series-parallel structures are partial 2tree [5] assuming distributed system as fully interconnected, that is, there exists a communication link between any two machines.However, the general N-processors problem (N > 3) in a fully interconnected system is known to be NPcomplete [6,7].Lee et al. [8] and Cho and Park [9] have suggested an optimal algorithm for the general structure problem in a linear array network with any number of processors.
All the above assignment models are static because they assume that once a task is assigned to a processor, it remains there statically during the execution of a distributed program.These models deal with the global information, which is assumed to be constant during the program execution, of program's activity.However the static model assumes that the problem can be partitioned into several tasks each of which contains a unique computational characteristic.In a general case each task may have multiple computational characteristics due to the dynamic control behavior ofthe task.Such tightly and medium-coupled portions of code task will be more difficult to break up and assign to different processors.When the characteristics of the computation change, a new assignment must be computed.By "characteristics of the computation" we mean the ratios of the times that the program spends in different parts of the program.In order to make the best use of computational characteristics and resources in a distributed heterogeneous computing system, it is essential to reassign tasksdynamically during program execution, so asto take advantage of changes in the local reference patterns of the program.Dynamic algorithms are employed more frequently because they offer a better efficiency, having the flexibility of tasks migration.In addition, usually dynamic algorithms are neither very complicated to construct nor costly to run.Hence dynamic algorithms have the potential to outperform static algorithms in general.Clearly, the gains from relocating tasks must outweigh the cost of relocation.For this relocation, detailed information on a program's activity over its lifetime can be collected at each time slot of lifetime.We use phase as the unit of the time slot for gathering more detailed information of program activity.Bokhari [10] analyzed the problem of dynamic assignment in a two-processor system, which permits relocation of tasks from one processor to the other at certain points during the execution of the program.This relocation incurs a predefined relocation cost that contributes to the total cost of running the program and code-conversion overheads.Also it is shown that an optimal dynamic assignment corresponds to a "dynamic" partition imposed by a minimum weight cut in an extended graph.In this paper, we consider the dynamic task assignment problem for a general program structure and a heterogeneous Nprocessors in DCS.
The rest of the paper is organized as follows.Definitions and assumptions are defined first in Section 2. In Section 3, tasks allocation problem has been discussed.The proposed method and algorithm have been explained in Sections 4 and 5 concludes this paper.

Definitions
(i) Phase: a phase of a distributed program is a contiguous period of time during which only one task is executed.During this period, the executing task may communicate with any number of the remaining task.A task may not be moved from one processor to another during a phase; it may be moved only between them.A task may complete its execution in more than two phases; therefore, the number of phases of the executing program is always more than the number of the tasks.(ii) Execution cost: the execution cost e ki j is the amount of the work to be performed by the executing task t i on the processor p i during the kth phase.(iii) Intertask communication cost: the intertask communication cost c ki j is incurred due to the data units exchanged between the executing task t i and residing task t j if they are on different processors during the process of execution in kth phase.(iv) Residence cost: residence cost r ki j (where is the amount of time spent by the residing task (other than executing task) t i on the processor p i in kth phase.These costs may come from the use of storage.(v) Relocation cost: relocation cost rel ik is the cost of reassigning the ith task from one processor to another processor at the end of kth phase.

Assumptions
(i) The program to be executed is assumed to be collection of tasks that are free, in general, to reside on either of the processors.A task may be a module of executable program.(ii) The given program runs in various phases with one of its task executing on a processor in each phase and each of the other tasks residing on any of the processors.(iii) In each phase, execution cost (EC), residence cost (RC) of nonexecuting tasks, intertask communication cost (ITCC) of executing task with nonexecuting tasks, and relocation cost (REC) for reassigning each task from one processor to the others at the end of phases are known.(iv) Some of the tasks have restrictions for being allocated on some particular processor because of the nonavailability of desired facilities which may include access to particular peripheral device, access to a particular task, and high speed arithmetic capability of the processor.The execution costs of such tasks are taken to be infinite on those processors where these tasks can not be executed.

PROBLEM STATEMENT
Consider a distributed program consisting of a set T = {t 1 , t 2 , t 3 , . . ., t M } of M tasks to be allocated to a set The basis for dynamic program model is the concept of the phases of a task program.With each phase the following information is associated: (1) the executing task during this phase and its execution cost on each processor in a heterogeneous system; (2) residence costs of the remaining tasks, except for the executing task, on each processor.These costs may come from the use of storages; Step-1: Input: K, M, N, ECM(, ,), RCM(, ,), RECM( , ), ITCCM(, ,) Step-2: Start with phase k = 1.
Step-4: Assign the executing task t s to processor p r for which cost is minimum say TEC k Step-5: Add the effect of communication cost of executing tasks t s with other residing tasks by adding kth column of ITCCM(, ,) to all the column of NECM(, ,) except the rth column at which this task is assigned.
Step-6: Assign the residing tasks t g (g = 1, 2, . . ., M, g / = s) to processors p h at which time is minimum say TRC(g) k Calculate: Step-7: Store executing and residing tasks and their position on processors in a linear array POSS(, ) k .Calculate: Step-9: Repeat step-3.
Algorithm 1: To assign a distributed program consisting of a set T = {t 1 , t 2 , t 3 , . . ., t M } of M tasks which is divided into K phases to a set of n processors P = {p 1 , p 2 , p 3 , . . ., p N } in order to minimize the total cost.
(3) intertask communication cost between the executing task and all other tasks if they are on different processors; (4) an amount of relocation cost for reassigning each task from one processor to the others at the end of the phases.
In general, the objective of task assignment is to minimize the completion cost of a distributed program by properly mapping the tasks to the processors.The cost of an assignment A, TCOST(A), is the sum of execution, intertask communication, residence, and relocation costs, that is, In order to make the best use of the resources in a DCS, we would like to find an assignment having minimum cost.

PROPOSED METHOD AND ALGORITHM
The problem for allocating a program dynamically that has been divided into K number of phases is to determine the optimal task allocation strategy by considering the phasewise EC for executing task and RC for nonexecuting tasks during the phases.The phasewise processing efficiency of individual processor is given in the form of matrix EMC(, ,) = (e ki j ) of order (K × M × N) and RC of each residing task is reflected through matrix RCM(, ,) = (r ki j ) of order (K × M × N).ITCC between executing task and another tasks is taken in the form of matrix ITCCM(, ,) = (c ki j ) of order (K × M).
The kth column of this matrix represents the ITCC between the executing task and all other residing tasks for the kth phase.Relocation costs for reassigning the tasks from one processor to another at the end of the phases is shown by matrix RECM(, ) = rel ik of order (M × K) where rel ik is the relocation cost for reassigning the ith task from one processor to the another at the end of kth phase.In this paper, we have considered that the relocation cost rel ik is a constant when ith task relocates from one processor to another at the end of the kth phase.The model starts from the first phase for allocating the tasks and moves to the next phase.Let t s be the sth executing task and t g (s / = g) be the gth residing tasks during kth phase.The execution for the executing task t s and residing task t g to the processors in the kth phase have been depicted in Figure 1.
The executing task t s (represented by * ) must be assigned to processor p r during kth phase for which sum of its execution and relocation costs is minimum.This minimum cost for the task t s is represented by TEC k .When residing task t g resides on a processor, it has three-type costs, that is.residing, relocation, and communication cost with the executing task t s .Therefore, the residing task t g must be assigned to that processor p h where it has minimum costs mentioned above.This minimum cost for the task t g is represented by TRC(g) k .Similarly, all other residing tasks are assigned to the processors.The total cost TRC k due to the residing tasks in the kth phase will be: ( The total cost (TCOST) k for the kth phase is the sum of TEC k and TRC k , that is, The total optimal cost, TCOST, for the program will be as follows: Using the arrays representation for the execution, residing, intertask communication, and relocation costs, a mathematical model has been developed for allocating the distributed program dynamically which has been splitting into any number of tasks partition and completing their execution in any number of phases.The process of allocating the tasks to the processors is given in the form of Algorithm 1.

Implementation of the Model
Example 1.Consider a program made up of four tasks {t 1 , t 2 , t 3 , t 4 } to be allocated on two processors {p 1 , p 2 } in five phases.Task t 1 completes its execution in two phases (in phase 1 and phase 5).The various matrices to be taken as input are described phasewise in Tables 1 and 2.
On applying the present tasks allocation model, we get the following optimal assignment as follows:    The result of Example 1 is shown by Figure 2.Here circles labeled with tasks number represent tasks (tasks represented by * are executive task and others are residing tasks).Costs associated with tasks are their execution costs (for tasks represented by * ) or residence costs.The edges connecting the executing task with other residing tasks during the same phase represent the communication and weights of these edges represent communication costs between the executing task and other residing tasks.The edges connecting the task of a phase to the task of the next phase represent the relocation of the tasks and the weights of these edges represent the costs of relocating the tasks.For example, the task t 2 is relocating from processor p 2 to processor p 1 between the phase 2 and phase 3. The above result shows that the assignments of the tasks are changing phase to phase.Optimal cost for this task program is 59.
Example 2. Consider a program made up of seven tasks {t 1 , t 2 , t 3 , t 4 , t 5 , t 6 , t 7 } to be executed on three processors {p 1 , p 2 , p 3 } in eight phases.The various matrices to be taken as input are described phasewise in Tables 3 and 4.
The present tasks allocation model gives the following optimal assignment as follows: The results of Example 2 are shown by Figure 3. Task t 2 completes its execution in two phases (in phase 1 and phase 7).The execution cost for the task t 2 is 2 in phase 1 and 4 in phase 7. The above result for the executing task t 2 shows that the assignments for both the phases are different, that is; it depends on the characteristic of the computation.The optimal cost for tasks program is 185.

CONCLUSION
We  having relocation cost for reassigning each task from one processor to the others at the end of phases.Bokhari [10] has developed a graph theoretical approach for finding out the optimal dynamic assignment of a modular program for the two-processor system considering execution, residence, intertask communication, and relocation costs.The model [10] can not find out the solution when the system is NPhard (N > 2) while the present model is applicable for the DCS having any number of phases and processors with random program structure.The study of the time complexity of the present model has also been made and compared with Bokhari [10] and Cho and Park [9].For Bokhari [10], the time complexity of the solution of the dynamic task assignment problem for the two-processor system is O(M 3 K 3 ).The time complexity of the present tasks model for any number of processors is O(M 2 N 2 K) which is timesaving as compared to O(M 2 N 2 K 2 log NMK) for the Cho and Park [9].
Figure 1: Allocation of the tasks in kth phase.