LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Example of explicitly setting the "reserve" state in DAQmx-tasks

Dear LabVIEW forum,

 

I've browsed the LabVIEW help to the "Taking Measurements" > "NI-DAQmx Key Concepts" > "Tasks in NI-DAQmx" > "Task State Model" > "Explicit Versus Implicit State Transitions". In this section I find some notes on when to attempt an explicit state transitions within a DAQmx task. Specifically, regarding the "Reserve" state I can read:

 

"Reserve—If the following is true, explicitly reserve a task: your application contains many different tasks that use the same set of resources, one of these tasks repeatedly performs its operation, and you want to ensure that none of the other tasks acquires these resources after the task begins its sequence of operations. Reserving the task exclusively acquires the resources that the task uses, ensuring that other tasks cannot acquire these resources. For example, if your application contains two tasks that each perform a sequence of measurements and you want to ensure that each sequence is completed before the other sequence begins, you can explicitly reserve each task before it begins its sequence of measurements."

 

As this seem to closely describe a scenario I'd be interested in implementing, I'd like to try this approach. However, I cannot find examples where I see this specific method utilized. Can you help me with some link or a VI snippet or similar?

 

Best regards,

Oscar

 

 

 

0 Kudos
Message 1 of 2
(2,208 Views)

I would suggest that explicitly setting the state to "commit" will usually be the preferable option.  It moves the task through the "reserve" state and beyond so it not only reserves the resources, it actually starts taking ownership of them (such as allocating memory buffers, etc.).  One of the best uses I know of for explicitly committing a task is to be able to stop and restart it with minimal overhead.  This seems to be particularly helpful with finite sampling tasks.

 

There may be better examples, I just searched my own threads b/c I *knew* I'd find some things that way.  Here's one.  It uses "commit" rather than reserve and it's specifically for the purpose of low overhead stop-and-restarts.

 

I found one long-ago thread where I may have had a use case for reserving instead of committing.  It's more than a little bit of a slog to read the thread, so consider yourself forewarned.  The gist of it is that I wanted to reserve certain signal-routing resources manually ahead of time so that other tasks that wanted to do auto-routing wouldn't stomp on the resources I knew I was going to want to grab in the future.

 

It's kind of an odd use case, and I'm not convinced that reserving instead of committing was what I actually needed way back then when I was first learning about the DAQmx task state model.  Odds are you'll be better off with a "commit".   Can you describe more about your intended usage?

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 2
(2,174 Views)