## 3 Materials and Methods
### Proposed Algorithm  
The proposed algorithm targets the dependencies between tasks and the execution times of tasks in order to reduce the makespan and energy consumption and to balance the loads among resources. VMs are allocated to tasks according to the demands of the workflow tasks to ensure a balanced load among the resources. The proposed algorithm reads the workflow tasks and sets thresholds for the depth and length of the tasks, where depth refers to the levels of tasks and length is the execution time of the tasks. The threshold values are used to process tasks according to different priorities during their execution. Tasks with more dependencies create bottlenecks in the system and cause long execution times. Similarly, tasks with longer execution times need to be processed with priority to reduce the overall execution time. These tasks are processed with high priority, i.e., VMs with high processing capabilities are allocated to these tasks. The proposed algorithm also searches for tasks with long execution times and processes these tasks with priority in order to avoid unnecessary waiting of tasks at the same level. Thresholds are defined for both the number of dependencies and the time according to the input data. These steps are used to reduce the execution time, which also leads to reduced energy consumption as resources are utilized efficiently. Algorithm 1 shows the steps involved in the procedure. ```
Input : workflow \(w\) Output :Queues of tasks based on depth and length  Assign thresholds dt for depth of tasks and It for length of tasks for each task \(t\) in the task list do  depth = number of levels dependent on t  length = execution time of t if depth>= dt then  move t to depth queue  end if iflength>= It then  move t to length queue  end if  end for Return queues
```  
**Algorithm 1**Avoid bottleneck tasksIn the next phase, the proposed algorithm uses queues according to the intensities of tasks, i.e., for CPU-intensive tasks and tasks with more dependencies, separate queues are maintained. Putting tasks with different intensities in separate queues saves time in finding the suitable VMs during the VM allocation process. In addition to the intensities of tasks, other information related to tasks, i.e., arrival time and the deadline, is used to store tasks in queues. After classifying tasks into different queues, the next step is to create suitable VMs for the tasks. For this purpose, historical scheduling records (HSRs) are used. If there is no matching record in the HSRs, a new VM is created with the necessary resources needed to process the task, and the HSRs are updated accordingly. The steps involved in the proposed algorithm are shown in Algorithms 2-4. ```
Input :Historical scheduling record (HSRs), task lists (from specified queues), Output :VMs (Types)  N = number of tasks in a queue for(each task \(t\) in \(N\))do  compute P(\(T_{t}\)) (Equation 21)  H = best n P(\(T_{t}\)) end for for(each \(l\) in \(H\))do if(\(t\) found in HSRs)then  allocate \(VM_{j}\) based on type of t else  CreateVM()  end if  Assign \(VM_{j}\) to task t  end for
```  
**Algorithm 2**Create VM types  
```
Input :List of tasks \(L_{t}\) from queues from algorithm 1, list of hosts \(L_{t}\) Output :List of VMs for(each host \(h\) in \(L_{h}\))do  u = resource utilization of h if(host resources are available)then  Create VM  Update HSRs end else  Power on new host Create VM  Update HSR end
```  
**Algorithm 3**Create VMs  
```
Input :Historical scheduling record (HSRs), task lists (from specified queues), Output :VMs (Types)  N = number of tasks in a queue for(each task \(t\) in \(N\))do  compute P(\(T_{t}\)) (Equation 21)  H = best n P(\(T_{t}\)) end for for(each \(l\) in \(H\))do if(\(t\) found in H



In the first phase, the tasks are marked, i.e., suitable VMs are found for the tasks. The types of tasks are classified accordingly, and the VM types are determined. For a set of tasks \(T\) extracted from the historical data, let \(T_{l}\) represent a type \(l\) task in \(T\).