## 4 Proposed Work
### Optimal Threshold  
In this section, a detailed approach for finding optimal threshold has been described. A threshold is a number which indicates that within available resources the task set can be executed and real-time requirements of tasks can be safely ensured. It is crucial as if this threshold is not carefully designed devices will run out of clock cycles and as a result, the CPU will not be able to schedule one or more tasks. In this paper, we introduce the concept of resource-aware threshold selection which will set the threshold according to IoT resources. The threshold can be adjusted in case a resource is registered or deleted from the IoT server. The system maintains the threshold in a bounded interval \([Th^{min},Th^{max}]\). \(Th^{min}\) is the minimum threshold while \(Th^{max}\) is the maximum value after which the system can not safely schedule tasks. The correct value of the threshold can be determined by investigating the profiles of embedded devices and available resources attached to them. For each device, semantic ontologies are maintained which help in dynamically finding attributes of the device that cater to the threshold and compute the threshold from the actual values of these attributes. In recent times, a diverse number of IoT devices has been employed in RT-IoT applications each having distinguished characteristics. Some of the notable hardware include Raspberry Pi, Edison Development Board and Arduino. These are such powerful toolkits that they can be used as IoT gateways and servers. In contrast, some devices are fabricated for a dedicated purpose and have limited memory and other resources. These can only be used as edge-nodes in a typical IoT scenario [46]. Let's assume \(D\) represents a set of IoT devices \(\{D_{1},D_{2},\ldots,D_{n}\}\) that interconnects to make a mashup of heterogeneous IoT devices. For every device \(D_{i}\), ontologies are maintained keeping the information about device type, device memory, flash memory and the number of resources connected to it. This information is stored and often referred to as Device Profile. The threshold \(Th_{i}\) of an individual device \(D_{i}\) depends on the CPU speed \(C_{i}\), Main Memory \(MM_{i}\), Flash Memory \(FM_{i}\) and The number of resources connected to it \(R_{i}\). Lemma 1: _Threshold \(Th_{i}\) of an embedded device \(D_{i}\) is directly proportional to the speed of CPU \(C_{i}\), the memory it contains and the flash memory it has._  
Lemma 2: _Threshold \(Th_{i}\) of an embedded device \(D_{i}\) is inversely proportional to the number of physical resources \(R_{i}\) connected to it._  
**Lemma 3**. : _The minimum threshold \(Th^{min}\) of the system is the value which can be satisfied using only flash memory._  
**Lemma 4**. : _The maximum threshold \(Th^{max}\) of the system is the value which if increased can move the system into an unsafe state and thus the possibility of failing the deadline of one or more tasks does exist._  
Based on the above lemmas, the minimum threshold and the maximum threshold can be determined using Equations (15) and (16):  
\[Th_{i}^{min}=C_{i}*FM_{i}/R_{i}\left\{\forall 1\leq i\leq n,\right. \tag{15}\]  
\[Th_{i}^{max}=C_{i}*MM_{i}/R_{i}\left\{\forall 1\leq i\leq n.\right. \tag{16}\]  
The total minimum threshold for the system is defined by Equations (17) and (18):  
\[Th^{min}=\sum_{i=1}^{n}Th_{i}^{min}\left\{\forall 1\leq i\leq n,\right. \tag{17}\]  
\[Th^{max}=\sum_{i=1}^{n}Th_{i}^{max}\left\{\forall 1\leq i\leq n.\right. \tag{18}\]  
\(Th^{max}\) and \(Th^{min}\) are seeded to Algorithms 1 and 2, and the threshold is adjusted based on the overhead of the algorithm. The overhead represents the mode of input tasks. In a scenario, when the algorithm's overhead is high, it means that tasks are coming with high values of periods or the system is accepting more input tasks. In this situation, the threshold is dynamically adjusted to minimise the failure rate of tasks' acceptance and decrease the rate of increase in overhead.