[Reviewer Andy] Add locking to deadlock detection

Andy

As discussed, this fix adds locking to the deadlock detection code to avoid the issues we've seen with it triggering incorrectly.  This avoids us having to allow a grace period for the detection to allow for case where we only read a partially updated service time.  As we discussed, the locking isn't a problem because the intent of the function is to detect deadlocks in code servicing an event queue, not deadlocks in the event queue code itself.

Mike