Multithreading in S function
5 次查看(过去 30 天)
显示 更早的评论
Hello All,
I am trying to create a S function in matlab which will read data from a video file and send the frame data via the output port.
The each and every frame information is read using a thread (External framework thread invoked through c++)and the information is sent to in the output pin using mdlOutputs.
The S function I created starts the read thread in mdlStart, but the mdlOutputs is called only after the read thread is stopped. hence mdlOutputs give me only the last frame information for every simulation time step.
I would like to know if it is possible to explicitly invoke mdlOutputs from read thread to receive the each and every frame information.
Thank you very much.
Please suggest if Multithreading is possible with S functions.
Regards Sarfraaz
0 个评论
采纳的回答
Kaustubha Govind
2011-4-5
mdlOutputs must be invoked by the Simulink engine, because it needs the current SimStruct passed in. It is never advisable to call S-function call-back methods from another callback method.
mdlStart is called only once during model execution (at the beginning), whereas mdlOutputs is called at every time step - it seems like you should really be doing your reading in mdlOutputs directly, and not in mdlStart. Is there a reason you chose your current workflow?
14 个评论
Kaustubha Govind
2011-4-8
The above doc page has a link titled "Creating Pause Blocks": http://www.mathworks.com/help/toolbox/simulink/ug/f11-31373.html#bq0ht63
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!