Break out of while loop after certain timeout

In reply to nik_88:

You use fork/join_any for this

fork 
   looping_code; //process 1
   #120us;       //process 2
join_any
global_stop_request();

The statement after the join_any starts when any one of the processes inside the fork/joia_any completes. You can also use disable fork to kill any remaining processes.

There is a problem with your while loop though - it will gointo an infinite 0 delay loop when signal_val == 0 is true. You need a blocking statement inside the loop so time can advance.