03-18-2009 09:08 PM
Nubie -
I am not familiar with the NI thread pool functions, sorry. Yup, the help is limited.
I am familiar with threading concepts and regulalry write muilti-threaded code, but I use Win32 calls directly, not the NI thread functions.
One way is to have a mutex or semaphore that must be "owned" by a thread before it can read / write to the buffer. A thread can wait for and become owner of a mutex or semaphore in Win32 with a WaitForSingleObject call, and release it with a ReleaseMutex() call (for a mutex anyway).
I create threads with the Win32 CreateThread () function.
There's quite a bit to all of this, writing a correct multi-threaded program isn't necessarily easy.
There are a couple of threads here on the forum dealing with multi-threading, and there's an NI whitepaper on how to use their threading functions. The Win32 SDK has quite a bit on multi-threading too.
Beveridge & Weiner, ISBN 0-201-44234-5 is a bit dated but still a good reference.
Menchar
03-19-2009 09:11 AM
The serial comm callbacks as suggested will work for getting the data from the serial port. Use them to stuff the data into a Thread Safe Queue. This is a buffer structure available in CVI that can replace your global buffers. They implement a ring buffer and handle all the thread safe aspects for you. Your main thread can then use an async timer or whatever method you choose to access the data from the output side of the Thread Safe Queue for processing as needed. You can implement all of this without the need to handle thread pools at all.
There is also a Thread Safe Variable which can be used as a type of semaphore or flag if you need to pass additional information between threads that does not easily work with a queue type structure.
03-19-2009 11:24 AM
Hi.
The thread safe Queue is the way to go.
However the embedded Help shows no hits as to how to write the code base.
So far LabWindows Help leaves little to be desired. What I would like is a Programmers Reference Guide but it seems one does not exist.
I have used the Help alot but most of the time I do not know the correct keywords and usually cannot find the information until I post and a kind soul responds with the correct information.
For example your mention of thread safe Queue did not result with any useful information such as:
1. How to set up the thread safe Queues.
2. How to access the treadsafe Queues both in the RxData interrupt (insert items) and the timer routine that processes the data (remove items).
3. Any overhead required with the Queues.
This kind of information is what I would expect in a 300-400 page Programmers Reference Guide (there are lots of books for LabView).
Trying to find this type of information in Help is next to impossible.
Any ideas where I can find the answers to these questions would be greatly appreciated.
03-19-2009 11:48 AM
03-19-2009 11:54 AM
Hi mvr.
I found the samples.
Again, THANKS very much.