From: Jan Simon on
Dear Bruno,

> > BTW, what happens if I start 4 threads in a C-Mex file, which call mexCallMATLAB?

> Matlab is essentially monothreading (excepted some basic low level routines). My guess is that Matlab engine is thread protected, and wait one call to be finished before starting the next one.

While Matlab 6.5 freezes, Matlab 2009a terminates with one message per thread about an unusal request to close the application.
I think I'll avoid calling mexCallMATLAB from multi-threaded MEX functions...

Kind regards, Jan
From: Steven_Lord on


"janas21" <janas21(a)gmail.com> wrote in message
news:e7a8ef94-f051-4626-ae09-25df42b685e9(a)i28g2000yqa.googlegroups.com...
> On Jul 19, 10:00 am, "Jan Simon" <matlab.THIS_Y...(a)nMINUSsimon.de>
> wrote:

*snip*

> Let me describe a little bit the background of the problem, I am
> making a FEM model in MATLAB, the demand is all the preparations,
> which in my case are 4 *.m files, creating geometry, creating the
> mesh, setting DoFs, set the solver, will be made automatically, so
> that the user will not have to interfere with the program but only to
> get the final results. So since it is not able from 1 pushbutton, to
> trigger 4 different *.m files, i can only think 2 other options.
> - either create 4 pushbuttons each of them trigger each of the *.m
> file or
> - the pushbutton will call the first *.m file which then will call
> the second *.m file etc. (--> i already tried and it seems to work).

Option 3, of course, is to have your button's main callback function invoke
each of the four functions in turn. After all, you can't create a mesh
until you know the geometry of the problem, can you?

So if your button's callback is mypushbuttoncallback, then have the body of
that function be:


createGeometry();
createMesh();
setDOF();
setSolver();
solve();


where each of those five functions is called in turn and performs the task
indicated by its name, sharing data using the techniques described in the
documentation if necessary. This will create the geometry, then when the
geometry is in place will create the mesh, then will configure the problem's
DOF and the problem's solver, then finally solve the problem.

> Actually you are right it is not so necessary to be simultaneously
> solved the 4 files, although the 3 first of them can be solved in this
> way. my mistake :)
>
> thanks for your reply and help both of you.
>
> sorry for my English writing

Your English wasn't bad -- I've definitely seen worse :)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com