Multi-threaded Mex functions in the FEX
Jan Simon asked
on 20 Dec 2011
Latest activity:
Answer by Walter Roberson
on 22 Dec 2011
I've published some C-Mex functions in the FEX, which could benefit from multi-threading. I like to keep the function compatible with Windows, Linux and MacOS. While I have some experiences with using _beginthreadex and _endthreadex under Windows, I have not worked with the pthread libraries under Linux. Although I can use pthread under Windows also, I do not want to increase the requirements for the users any further - even the compilation with the "mex" command is too confusing for some users already. OpenMP is not available in the free MSVC Express compilers. And installing MinGW to compile the Mex files is not trivial also. What are simple solutions for a platform independent multi-threading in C- or C++-Mex-functions? Products |
|---|
pthreads (Posix Threads) is the only standardized and [supposedly] platform-independent threading for C.
pthreads was incorporated in to the POSIX standards as of 1995, so I do not expect it to be available for embedded systems, as a bunch of those pretty much froze as of 1990-ish capabilities (the POSIX standards added after 1900 tend to be relatively high overhead in order to support generality.)
My understanding from when I used to be active in comp.lang.c is that Windows threading is incompatible with POSIX threads, that it is not just a matter of translating calls but that Windows threading does something or other in an way that contradicts POSIX. I was, however, not interested enough to bother to check that out myself.
A list (as of 2006) of all known multithreading libraries for Unix operating systems.
Apache Portable Runtime (APR) offers a portable interface to OS threads
Also, the Netscape Portable Runtime
See also several others (mostly for C++) listed at http://www.shlomifish.org/open-source/portability-libs/
Contact us at files@mathworks.com
1 comment
[BUMP] I admit, I'm not very surprised, that there is no answer, because my corresponding search in the net has not been successful either. I think the 2 votes mean, that there is a need for a solution.