If have a very large array, Arr [255]. I'm writing a function which should perform a task whenever any one or more byte in this array has been updated by other functions. Could you help me with the best possible method?
For any change in first 3 bytes of Arr, I can call the function Task() like the following.
int main (void)
{
while (1)
{
CheckArrayUpdated ();
}
}
void CheckArrayUpdated (void)
{
static char ArrPre [3];
if (
(ArrPre [0] != Arr [0]) ||
(ArrPre [1] != Arr [1]) ||
(ArrPre [2] != Arr [2])
)
{
Task ();
ArrPre [0] = Arr [0];
ArrPre [1] = Arr [1];
ArrPre [2] = Arr [2];
}
else;
}
How can I do this for the entire array, without consuming much of processing time and increasing the length and size of code?
Aucun commentaire:
Enregistrer un commentaire