2 ms·
I mean it’s not that hard even on non-rt preemptive schedulers. You can’t avoid false negatives because you could be preempted after func completes but before t
by Spivak 5y ago
I mean it’s not that hard even on non-rt preemptive schedulers. You can’t avoid false negatives because you could be preempted after func completes but before the time is fetched but if you get a result it will be valid.
def must_complete_before(func, deadline):
result = func()
lower, upper = time.now()
if upper < deadline:
return result
else:
throw MissedDeadlineException(“Can’t guarantee func completed before deadline”)
- deleted 5y ago[deleted]
- Psyonic 5y agoAssuming func() doesn’t have side effects, sure. But if the point was to gate func() to only run before deadline this doesn’t really help.
- jeffbee 5y agoYeah but that doesn’t have anything to do with this API. If you want to use it that way, obviously the reasoning is defective. This API is to determine if something that happened at a given instant is definitely in the past. That’s it!