A periodic interrupt has been programmed to go off every 50ms and is handled by the ISR
`interrupt_handler()`. With a 100 kHz clock, consider the code sequence below that uses the global
variable `pProcessInterrupt` as a flag to tell the main thread to process some data every time the
interrupt is triggered. How many times will the main thread read "0" for `*pProcessInterrupt` before it
calls `process()`? The initial conditions are `*pProcessInterrupt = 0;` Assume that when the interrupt
returns, the program is set to execute the `while (1)` (line 1) statement.
Hint: Assume the program has been running for a while, and ignore the time before the first
interrupt goes off.
// Main thread
/*Line No.*/
/*01:*/`while (1)` { // 1 cycle to loop
/*02:*/ if (1 == `*pProcessInterrupt`) { // 1 cycle to check the flag
/*03:*/ `process()`; // 93 cycles to run the processing
/*04:*/
`*pProcessInterrupt = 0;` // 1 cycle to set the flag back to 0
/*05:*/ } // assume 0 cycles for this line
/*06:*/ } // assume 0 cycles for this line
// Assume 1 cycle to transition to the interrupt
/*07:*/`void interrupt_handler()` {
/*08:*/ // interrupt takes 2 cycles
/*09:*/ `*pProcessInterrupt = 1;`
/*10:*/ `*interruptPending = 0;`
/*11:*/ } // Assume 1 cycle to transition back to the main program