Thread Programming & Matlab
-
Hi All, Attached is a simple c++ code that is to be, after compilation, called from MATLAB. When the line "afxbeginthread" is removed every thing is ok. When the line is re-placed the code compile but does not execute. Any suggestions? Regards Sam, Melbourne #include "c:\temp\stdafx.h" #include "c:\temp\mex.h" /********************************************************************/ UINT THREADD1(LPVOID pParam) { printf(" %10.1f\n", 5.5); return 0; } /*********************************************************************/void init_rt_pars ( void ) { printf(" %10.1f\n", 3.3); } /*********************************************************************//* The GateWay Routine */ /* /********************************************************************/ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { /*************************************************************/ init_rt_pars(); AfxBeginThread(THREADD1,NULL); init_rt_pars(); /*************************************************************/ return; }
-
Hi All, Attached is a simple c++ code that is to be, after compilation, called from MATLAB. When the line "afxbeginthread" is removed every thing is ok. When the line is re-placed the code compile but does not execute. Any suggestions? Regards Sam, Melbourne #include "c:\temp\stdafx.h" #include "c:\temp\mex.h" /********************************************************************/ UINT THREADD1(LPVOID pParam) { printf(" %10.1f\n", 5.5); return 0; } /*********************************************************************/void init_rt_pars ( void ) { printf(" %10.1f\n", 3.3); } /*********************************************************************//* The GateWay Routine */ /* /********************************************************************/ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { /*************************************************************/ init_rt_pars(); AfxBeginThread(THREADD1,NULL); init_rt_pars(); /*************************************************************/ return; }
Try CreateThread and _beginThread! A. Riazi
-
Try CreateThread and _beginThread! A. Riazi
Hi A. Riazi, Many thanks for your reponse. I have tried CreateThread with no success. I have also eliminated MATLAB now (ie the function that initiates the thread is main() not mexFunction) and the problem is still there. Any further suggestions? Regards, Sam
-
Hi All, Attached is a simple c++ code that is to be, after compilation, called from MATLAB. When the line "afxbeginthread" is removed every thing is ok. When the line is re-placed the code compile but does not execute. Any suggestions? Regards Sam, Melbourne #include "c:\temp\stdafx.h" #include "c:\temp\mex.h" /********************************************************************/ UINT THREADD1(LPVOID pParam) { printf(" %10.1f\n", 5.5); return 0; } /*********************************************************************/void init_rt_pars ( void ) { printf(" %10.1f\n", 3.3); } /*********************************************************************//* The GateWay Routine */ /* /********************************************************************/ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[] ) { /*************************************************************/ init_rt_pars(); AfxBeginThread(THREADD1,NULL); init_rt_pars(); /*************************************************************/ return; }