Why aren't you using timers? They're simple. You don't even need an event loop. It can be as simple as:
You're currently assuming al_rest has both high enough precision (5 ms vs 5.00023 ms) to compare the floats, and, enough repeatability (5 ms = 5.012341ms then 5.023 ms then 5.2 ms then ...)) to be consistant.
al_rest per the docs is not a high precision delay function.
With some operating systems, the accuracy can be in the order of 10ms.
that's a huge difference if you're running a high frame rate. For example, 60 FPS is 16 milliseconds per frame. If you can only select 10 ms, or 20 ms, you're never going to hit it correctly and constantly be over-correcting.
If you need high precision, use a C library that offers it. Or... just use events like you're supposed to which have no problem even at 120 hz and higher. (Note: You can still use "events" exactly like the above code, just to trigger a frame every X milliseconds when a timer fires off. It's not complex.)