kind of statements which wait there until that condition is reached. If you use such statements and if something goes wrong and the condition you were waiting for never occurs, then your system will be hung there forever.
So if have to check such conditions then modify the statement to check only for a certain number of times and return with an error code if the maximum number of counts were reached,
unsigned short count = 0;
while( count < 65000)
What this loop does is it checks the condition only for 65000 times and breaks if the condition which we wanted is reached. You can always workaround and add any return codes/error codes if your want to indicate whether the break out of the loop was due to the count overflow or the flag was set. Later on you can handle these error codes as you want and take appropriate steps.