## 3 Latency-Classification-Based Deadline-Aware Task Offloading Algorithm (LCDA)
### Target Edge Cloud Server Selection  
After selecting a task to be offloaded, the next step is to select an appropriate edge cloud server to offload that task, as shown in Algorithm 2. To find an edge cloud server for offloading a task, we apply an edge-cloud server selection algorithm differently based on the task type information from the task analysis.  
First, if the type of task to be offloaded is latency-tolerant, we select the edge cloud server with the smallest number of latency-sensitive VMs for offloading. This is done to minimize interference on edge cloud servers running latency-sensitive VMs when a task is offloaded. If multiple edge cloud servers running the same number of latency-sensitive VMs are identified, we select the edge cloud server with the lowest CPU utilization. In other words, the server with the most available resources is always selected. If there are edge cloud servers with the same utilization, the server closest to the user device is selected. This is consistent with the concept of \"data locality,\" which means that a VM and the disk to be accessed by that VM are placed physically close to each other to improve the performance of cloud computing. This minimizes network congestion and increases the overall throughput of a system. If there is no edge cloud server with sufficient resources in the edge pool, the central cloud server with the most resources in the cloud pool is selected.  
Second, if the type of the task to be offloaded is latency-sensitive, we do not consider different types of VMs when selecting an edge cloud server. Latency-sensitive tasks are always offloaded into the edge cloud server with the greatest available resources without considering the task state of the target server. It is because processing the offloaded latency-sensitive task as quickly as possible is most important. In such cases, the server with the lowest CPU utilization is selected for offloading. If there are multiple servers with the same CPU utilization, the server with the smallest number and size of running VMs is selected as the final target. If all of these conditions are not met, the task cannot be offloaded, and execution continues on the user device. This decision is to minimize the performance degradation of the latency-sensitive tasks during offloading.  
```
1:for all \(\mathit{server}_{i}\) in \(\mathit{edge}_{pool}\), \(\forall_{i}\in\{\)1,2,... \(n\}\);
2:if the type of task to be offloaded is latency-tolerant
3: Find the \(\mathit{server}_{i}\) with the smallest number of latency-sensitive VMs;
4:if There are servers with the same number of latency-sensitive VMs
5: Find the \(\mathit{server}_{i}\) with the lowest CPU utilization;
6:if There are \(\mathit{server}_{i}\) with the same utilization
7: Find the \(\mathit{server}_{i}\) closest to the user device;
8:endif
9:endif
10:else // the type of task to be offloaded is latency-sensitive
11: Find the \(\mathit{server}_{i}\) with the lowest CPU utilization;
12:if There are multiple servers with the same CPU utilization
13: Find the \(\mathit{server}_{j}\) with the smallest number and size of running VMs;
14:endif
15:endif
16:end for
```  
**Algorithm 2**_Server_Selection ()_