From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-25-2014 07:09 AM
I have a leak test engine and servo engine that is a consumer loop being called via "Start Asynchronous Call" multiple times for each device. A contractor that I am working with said I need to add a wait timer since the dequeue will tie up the processor. Is this true?
I kind of makes sense that the dequeue is waiting to process anything immediately, but I thought the timeout would release the loop just like a wait timer set to zero. He says it does not since it is still waiting to dequeue something. What does the experts think about this?
Solved! Go to Solution.
08-25-2014 07:28 AM - edited 08-25-2014 07:32 AM
No wait needed. The Dequeue will time your loop. Quickly based on your example, that timeout for the Dequeue isn't even needed.
EDIT: Some additional notes after rereading the original post. The Dequeue will "sleep" while waiting for data to come down the queue. So not processor will be used. And if you have a not in your queue, you really want that consumer to run as fast as it can anyways to try to play catchup.
08-25-2014 07:31 AM
08-25-2014 07:35 AM
Sorry, I took the example to try to show how I was using it, this is part of my real code. When I time out I read the current status and the queue is used to process commands.
08-25-2014 07:44 AM - edited 08-25-2014 07:48 AM
I think he was saying something about releasing a processor thread to allow something else a chance to run. I don't remember exactly how he said it, but it sounded like it could be true at the time. I have another application that could be running up to 50 engines in the background, so I would like to know more about the efficiency of the dequeue.
Edit: He did say he was running on a virtual machine that only used 1 core of the processor and the code we were working on was running slow. He put the wait timer in and it worked fine for him.
08-25-2014 07:49 AM
Well, even then, the CPU will get released a little bit due to the communications happening.
Yeah, things are going to get slowed down with just 1 core. I really hope your systems are not going to be running single core.
08-25-2014 07:58 AM
So the dequeue will normally hold on to the CPU? Is this similar to a empty loop without a wait timer? Not much processing, but taking cpu resources?
The machines are running on new dedicated Core i7's, so I'm not worried about this project. Just wanting to better understand this and looking into the future application that might run 50 engines in the background.
08-25-2014 08:04 AM
@nonecure wrote:
So the dequeue will normally hold on to the CPU? Is this similar to a empty loop without a wait timer? Not much processing, but taking cpu resources?
No. If there is nothing in the queue, the Dequeue Element causes a "sleep". This is similar to your Event Structure while waiting for events. They use no CPU while waiting for a message.
Now if you have a lot of things in your queue, then your loop could be running as fast as possible to play catch up.
08-25-2014 08:11 AM
That is what I always thought, but why would he see a big improvement on his 1 core machine when adding the wait 0ms? We have 7 engines (dequeue loops) running on this machine.
08-25-2014 08:24 AM - edited 08-25-2014 08:25 AM
I guess I read this incorrectly.