# Two-Stage Optimal Task Scheduling for Smart Home Environment Using Fog Computing Infrastructures
## 3 Proposed Model  
### System Architecture  
In this section, we set up the system architecture for the optimal task allocation with respect to smart homes. We considered a fog-cloud system, which consists of three layers, the IoT sensor layer, the fog layer, and the cloud layer, as shown in Figure 2. The sensor layer comprises intelligent sensor nodes located in different areas of the smart home sending data to the fog layer for further processing. The fog layer contains special network devices such as routers, switches, and virtual network functions, which have better storage and computing capabilities. The last layer, i.e., the cloud layer, also known as the high-performance layer, comprises a high-performance server with a large storage and high processing power. The IoT layer forwards the data to the fog layer in terms of the task requests. The fog layer further processes those tasks using the machine learning model shown in Figure 2 and returns the results to the IoT layer. The set of tasks in the smart home are in the form of sensors generating datasets such as a real-time camera, smoke detector, humidity sensor, water leak sensor, motion sensor, electricity usage sensor, and light sensor. The objective of the proposed machine-learning-based task allocation is to provide the optimal allocation of the fog nodes, to improve the resource utilization, to make the response time faster, and to improve the overall cost. Delay-sensitive tasks such as the smoke detector and water leaks need be given priority in the service queue, which would be allocated first on the fog nodes. To add these tasks into the priority queue, we propose an intensity-based task allocation model, which works as follows:  
* A virtual node is assigned to the fog layer for a smart home application in order to check the intensity of every incoming task. * This virtual node monitors every generated task from the intelligent devices of the smart home. * The virtual node will rank every task according to its intensity level (example: T1\(\rightarrow\)R1, i.e., Rank 1 is given to Task 1). * Here, intensity means how much computing resource (CR) a task will use, how much delay (DL) a particular task can tolerate while performing the task, and how much memory (M) space is required by every task. Rank 1 will be given to the task that requires less computing resource, that requires less memory, and that is not delay-tolerant. \begin{table}
\begin{tabular}{p{128.0 pt} p{128.0 pt} p{128.0 pt} p{128.0 pt}} \hline \hline
**Author’s Name** & **Type of Algorithm** & **Workflow** & **Findings** & **Simulation Environment** \\ \hline [PERSON] et al. [28] & Static & Task scheduling & Tradeoff between total cost and makespan & iFogSim \\ \hline [PERSON] et al. [8] & Static & Task scheduling & Reducing network delay, wait time, and network usage & iFogSim \\ \hline [PERSON] et al. [17] & Static & Resource allocation & Providing a fast convergence speed & MATLAB \\ \hline [PERSON] et al. [15] & Dynamic & Task scheduling & Optimal resource utilization and reducing execution time & Java \\ \hline [PERSON] [18] & Dynamic & Resource allocation & Reducing energy consumption in the fog environment & iFogSim \\ \hline [PERSON] [16] & Hybrid & Task scheduling & Reducing compilation time and energy consumption and making the fog environment more reliable & MATLAB \\ \hline [PERSON] et al. [29] & Hybrid & Resource allocation & Optimizing resource utilization and minimizing processing cost and response time & iFogSim \\ \hline [PERSON] et al. [13] & Static & Workflow scheduling & Reducing the task’s execution time and makespan & Java \\ \hline [PERSON] et al. [30] & Hybrid & Workflow scheduling & Reducing the task completion time & MATLAB \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Comparison of the existing state-of-the-art solutions. * Tasks will be added to the priority queue according to their ranks and assigned accordingly over the fog nodes; thus, this allocation policy results in the optimal allocation of the tasks.