How to pass data between parallel tasks that don't terminate?

조회 수: 3 (최근 30일)
Scott Waun
Scott Waun 2016년 12월 2일
댓글: Scott Waun 2016년 12월 6일
I have a data logging & monitoring tool that I've written using the App Designer. It creates a timer object in the background to retrieve data, saves it to a file, and updates the display. Since it's a single-threaded application, I can't save data any faster than I can update the display (which is rather slow). Because of this, my timer can't run faster than about 1x per second. Ideally, I'd like to save data to the file at 10-100x per second, even if the display updates more slowly.
I have the parallel computing toolbox, so I've been looking at running the data collection and plotting as parallel tasks. The app display would refresh using a timer as it does today, but the data collection would run as a background parallel task continuously sampling data (while(1)) as fast as possible.
It appears that the branch and parpool functions both require you to wait until a task is complete before accessing its data. Since the data collection task never ends, I'm not sure what to do.
In summary, here's what I'm looking for:
  • Data collection task - Runs continuously, appends readings to DATA matrix, writes to output file
  • Screen update task - Runs 1/sec, only displays the latest value from DATA matrix

답변 (1개)

Sid Jhaveri
Sid Jhaveri 2016년 12월 6일
If waiting till task is completed is the only issue while using Parallel Computing Toolbox, then you can try using " parfeval " or " parfevalOnAll " functions of Parallel Computing Toolbox.
To learn more about asynchronous parallel programming in MATLAB, refer to the link given below: https://www.mathworks.com/help/distcomp/asynchronous-parallel-programming.html
  댓글 수: 1
Scott Waun
Scott Waun 2016년 12월 6일
Is it possible to access the function's internal variables before it's completed execution? In my case, the function will never end (endlessly collecting data). The parallel thread needs to be able to access its data however. The examples only show a for loop that waits for outputs to become available on completion.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by