# Scalable Fog Computing Orchestration for Reliable Cloud Task Scheduling
## 3 The Proposed Fog Computing Orchestration Mechanism
```
Input:Tuple_i Output:Map_i = (Tuple_i, Edge_i, Container_k) Initialization:location \(\leftarrow\) get_location (Tuple_i); requirement \(\leftarrow\) get_requirement (Tuple_i);
1:call assign_tuple (Tuple_i);
2:functionassign_tuple (Tuple_i)
3:signal_strength \(\gets\) 0;
4:target_edge \(\leftarrow\) null;
5:target_container \(\leftarrow\) null;
6:found \(\leftarrow\) false;
7:for all\(\textit{Edge}\_i\in\textit{Set}\_\textit{Edge}\) (location)do
8:current_signal_strength \(\leftarrow\) get_edge_info (Edge_i, signal);
9:if (current_signal_strength > signal_strength)then
10:signal_strength \(\leftarrow\) current_signal_strength;
11:target_edge \(\leftarrow\) Edge_i;
12:endif
13:endfor
14:for all\(\textit{Container}\_i\in\textit{target}\_\textit{edge}\)do
15:if (Container_i meets requirement) then
16:target_container \(\leftarrow\) Container_i;
17:assign_info \(\leftarrow\) assign_tuple (Tuple_i, target_edge, target_container);
18:found \(\leftarrow\) true;
19:endif
20:endfor
21:if (found == false)then
22:target_container \(\leftarrow\) provision_container (target_edge);
23:assign_info \(\leftarrow\) assign_tuple (Tuple_i, target_edge, target_container);
24:endif
25:return assign_info;
26:endfunction
```  
**Algorithm 1** Task Scheduling Algorithm. ```
1:Input\(Map\_i\) (Tuple_i, Edge_j, Container_k)
2:Output:New_Map_i = (Tuple_i, Edge_j, Container_k)
3:Initialization:location \(\leftarrow\) get_location (Tuple_i);
4:signal_strength \(\leftarrow\) get_signal_info (Map_j);
5:mobility_speed \(\leftarrow\) get_mobility_speed (Map_i);
6:mobility_property \(\leftarrow\) get_mobility_property (Map_i);
7:target_edge \(\leftarrow\) null;
8:bool_migration \(\leftarrow\) false;
9:call check_condition (Map_i);
10:if (bool_migration) then
11:call perform_migration (Map_i, target_edge);
12:endif
13:endfor
14:if (migratability (target_edge, mobility_property)) then
15:bool_migration \(\leftarrow\) true;
16:endif
17:endfunction
18:function perform_migration (Map_i, target_edge)
19:handoff (Map_i, target_edge);
20:for allContainer_i \(\in\) target_edge do
21:if (Container_i meets _requirement_) then
22:target_container \(\leftarrow\) Container_i;
23:assign_info \(\leftarrow\) assign_tuple (Tuple_i, target_container);
24:found \(\leftarrow\) true;
25:endif
26:endfor
27:if (found \(==\) false) then
28:target_container \(\leftarrow\) provision_container (Edge_i);
29:assign_info \(\leftarrow\) assign_tuple (Tuple_i, target_container);
30:endif
31:migrate_tuple (Map_i, target_container);
32:migrate_data (Map_i, target_container);
33:sync (Map_i, target_container);
34:returnNew_Map_i = (Tuple_i, target_edge, target_container)
35:endfunction
```  
**Algorithm 2** Task Migration Algorithm. With _target_edge_ and _mobility_property_, _bool_migration_ can be true if the _migratability_ function returns true. When _bool_migration_ is true after calling the _check_condition_ function, the _perform_migration_ function is called. The _perform_migration_ function does handoff, container selection, and task migration (tuples and data). Note that the container selection phase is similar to that of the task scheduling algorithm. The task migration phase calls three additional functions: _migrate_tuple_, _migrate_data_, and _sync_. Then, it returns _New_Map_i_.