LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Feasibility of Multiple Threads Accessing same file

Hello,

 

I'm designing an application in which there are two threads. The first thread would create a TDMS file and will keep on writing data acquired from multiple sensors to the file until the program exits. I'am keeping the file handle as a global variable acessible to any thread.

 

The second thread should use the same file handle(static global variable) and has to continously read data from the file in chunks and do some processing.

 

Will there be any problem with file acess if i go ahead with this method?.

 

Note: I cannot keep the data written to file on PC RAM for processing as the size of data is in GB's.

 

 

-----------------------------------------------------------------------------------------------------------------------------
Waiting For the inner calling 🙂


0 Kudos
Message 1 of 3
(2,747 Views)

It is probably not a good idea. The pointer to the file location will move around between read write operations and overwrite chunks of data and you will probably have to spend time developing features similar to database like functionality to achieve your goals.  

I would use a database that is designed for this type of functions,  like SQL express or MySQ and have multiple threads access the data in a controlled fashion without redesigning the wheel. 

 

Jattie van der Linde
Engineering Manager, Software & Automation
TEL Magnetic Solutions Ltd
0 Kudos
Message 2 of 3
(2,705 Views)

Ditto. If not a fifo frame buffer,  than SQLITE can do the job. 

0 Kudos
Message 3 of 3
(2,697 Views)