Click here to Skip to main content
14,303,515 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: I wish... Pin
Nish Nishant26-Apr-19 8:38
sitebuilderNish Nishant26-Apr-19 8:38 
GeneralRe: I wish... Pin
Slacker00724-Apr-19 8:40
professionalSlacker00724-Apr-19 8:40 
GeneralRe: I wish... Pin
Matthew Dennis24-Apr-19 9:56
adminMatthew Dennis24-Apr-19 9:56 
GeneralRe: I wish... Pin
Graham Cottle24-Apr-19 19:28
professionalGraham Cottle24-Apr-19 19:28 
GeneralRe: I wish... Pin
Rage24-Apr-19 20:15
professionalRage24-Apr-19 20:15 
GeneralRe: I wish... Pin
Chris Losinger25-Apr-19 4:58
professionalChris Losinger25-Apr-19 4:58 
GeneralRe: I wish... Pin
MadMyche25-Apr-19 7:09
mveMadMyche25-Apr-19 7:09 
Rant@§$%& time management - edited Pin
Nelek24-Apr-19 2:51
protectorNelek24-Apr-19 2:51 
I am using something like
std::this_thread::sleep_for(std::chrono::microseconds(toWait));

where toWait is dynamic, depending on frequency and desired time minus the used time for the data processing.

I am aware of:
Blocks the execution of the current thread for at least the specified sleep_duration.

This function may block for longer than sleep_duration due to scheduling or resource contention delays.


but I would at least have expected that the scheduling or resource contention is something that can come but that goes again as fast as it gets solved but...

NO, it isn't.

Example:
1 minute à 250 Hz (4 ms period) --> 15000 expected ticks.
toWait = [3700, 3980] us depending on what it is done in each tick

30% of the tests working fine, sleeping the correct toWait --> 60.000xxx execution time, 15001 ticks Thumbs Up | :thumbsup: Thumbs Up | :thumbsup:

70% of the tests going wrong, because it adds 6 ms to the wait time (toWait [9700, 9950] us) and the elephanting offset remains for the whole execution --> 60.000xxx execution time, 6001 ticks

Mad | :mad: Mad | :mad: Mad | :mad: Mad | :mad: Dead | X| Dead | X| Dead | X| Dead | X|

Sorry... but I had to "shout"
Thanks for "listening"


EDIT (New day, new perspective):
I have just dumped the sleep_for(toWait);.
I am now using my own check using the QueryPerformanceCounter and comparing it to the period I want to use.
So far... performing good.
If my long time performance tests are successful and I get the time to do it right... I might put a bit order, create a helper class and write an article / tip about it.
M.D.V. Wink | ;)

If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.


modified 25-Apr-19 3:30am.

GeneralRe: @§$%& time management Pin
  Forogar  24-Apr-19 3:10
professional  Forogar  24-Apr-19 3:10 
GeneralRe: @§$%& time management Pin
den2k8824-Apr-19 3:27
professionalden2k8824-Apr-19 3:27 
GeneralRe: @§$%& time management Pin
Nelek24-Apr-19 9:53
protectorNelek24-Apr-19 9:53 
GeneralRe: @§$%& time management Pin
theoldfool24-Apr-19 3:48
professionaltheoldfool24-Apr-19 3:48 
GeneralRe: @§$%& time management Pin
den2k8824-Apr-19 3:52
professionalden2k8824-Apr-19 3:52 
GeneralRe: @§$%& time management Pin
Munchies_Matt24-Apr-19 4:29
memberMunchies_Matt24-Apr-19 4:29 
GeneralRe: @§$%& time management Pin
den2k8824-Apr-19 5:18
professionalden2k8824-Apr-19 5:18 
GeneralRe: @§$%& time management Pin
Munchies_Matt24-Apr-19 6:03
memberMunchies_Matt24-Apr-19 6:03 
GeneralRe: @§$%& time management Pin
theoldfool24-Apr-19 5:02
professionaltheoldfool24-Apr-19 5:02 
GeneralRe: @§$%& time management Pin
den2k8824-Apr-19 5:13
professionalden2k8824-Apr-19 5:13 
GeneralRe: @§$%& time management Pin
Daniel Pfeffer24-Apr-19 5:15
professionalDaniel Pfeffer24-Apr-19 5:15 
GeneralRe: @§$%& time management Pin
Nelek24-Apr-19 19:12
protectorNelek24-Apr-19 19:12 
GeneralRe: @§$%& time management Pin
Daniel Pfeffer24-Apr-19 21:45
professionalDaniel Pfeffer24-Apr-19 21:45 
GeneralRe: @§$%& time management Pin
Nelek24-Apr-19 23:51
protectorNelek24-Apr-19 23:51 
GeneralRe: @§$%& time management Pin
Sander Rossel24-Apr-19 9:32
professionalSander Rossel24-Apr-19 9:32 
GeneralRe: @§$%& time management Pin
Nelek24-Apr-19 10:00
protectorNelek24-Apr-19 10:00 
GeneralAs If You Didn't Already Know Pin
W Balboos24-Apr-19 2:18
mveW Balboos24-Apr-19 2:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.