Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 75f102bc8628
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3197fc1569ce
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on May 15, 2019

  1. Added exponential backoff between polling operations to prevent slamm…

    …ing CPUs of slower scopes
    azonenberg committed May 15, 2019
    Copy the full SHA
    3197fc1 View commit details
Showing with 13 additions and 6 deletions.
  1. +13 −6 glscopeclient/main.cpp
19 changes: 13 additions & 6 deletions glscopeclient/main.cpp
Original file line number Diff line number Diff line change
@@ -252,6 +252,7 @@ void ScopeThread(Oscilloscope* scope)
pthread_setname_np(pthread_self(), "ScopeThread");
#endif

uint32_t delay_us = 1000;
while(!g_terminating)
{
//If the queue is too big, stop grabbing data
@@ -263,14 +264,20 @@ void ScopeThread(Oscilloscope* scope)

auto stat = scope->PollTrigger();

//If there's nothing to do, sleep for a bit to avoid hammering the CPU
if(stat == Oscilloscope::TRIGGER_MODE_STOP)
if(stat == Oscilloscope::TRIGGER_MODE_TRIGGERED)
{
usleep(1000);
continue;
//reset delay if it got too long
if(delay_us > 10000)
delay_us = 1000;
scope->AcquireData(true);
}

if(stat == Oscilloscope::TRIGGER_MODE_TRIGGERED)
scope->AcquireData(true);
//Armed, or nothing to do.
//Use exponential back-off to avoid hammering slower hardware.
else
{
usleep(delay_us);
delay_us *= 2;
}
}
}