Rewrite realtime mode scheduler loop in a way such that synchronization of event-queue access should be easier to implement