Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduling rework #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

dimbleby
Copy link

The motivation here is that I want to be able to apply quite low amounts of lag, and variation in lag - and in the current code the value of CLOCK_WAITMS at 40ms, and the associated Sleep(), is high enough to prevent this from being accurate.

Eg if I set lag to 50ms, what I actually see is lag varying from 50-90ms.

So what I've done is this:

  • In the first commit on this pull request, simplify the processing so that all interference happens on just one thread
    • the thread that reads packets only reads packets and puts them on the queue - it no longer does any processing. Instead it just sets an event to signal to the other thread to indicate that there's work to do.
    • that thread wakes up either on timeout or on being signaled, and processes queued packets
  • In the second commit, I allow modules to indicate how long a delay they want before being rescheduled, and have the processing thread use a shorter timeout if requested
    • in particular, lag now indicates when it would like to be rescheduled to send lagged packets - rather than having to wait and be up to CLOCK_WAITMS late

This version of the pull request is against master - if you take #33, then there's a trivial one-line change needed to lags calculation of the delay. I'd be happy to re-submit this one after #33 is merged, if that's more convenient.

- divertReadLoop just puts packets on the queue
- divertClockLoop takes packets off the queue and processes them
In particular, 'lag' now indicates that it wants to be rescheduled
in time to send lagged packets
@jagt
Copy link
Owner

jagt commented Jul 29, 2016

Great I'll be checking this out tomorrow when I get home :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants