multi-threading in externals
May 28, 2008 at 2:43pm
multi-threading in externals
I developed an external which connects to a streaming TCP/IP socket. In
I use a circular buffer to pass the data between the Posix thread and the
Can I make use of critical regions or mutexes to protect the data buffer? Is
So yeah, I’m clearly not completely sure:)
In earlier attempts I tried using the scheduler_set() and family to create a
May 28, 2008 at 3:59pm
On 2008 May 28, at 9:43 AM, Thijs Koerselman wrote:
> Dear List,
> Can I make use of critical regions or mutexes to protect the data
It seems like you actually have two issues here: one is working with
There is a Max native way to create and use new threads. You can find
In Tap.Tools 3 there is a new object (tap.svn) which is a Subversion
1. In the struct:
2. In the free routine, you need to make sure that you don’t hang Max:
3. Down in maxsvn_anything() we our flag in the struct and call a
4. When maxsvn_doanything() is done, and thus we don’t need the thread
In your case, you might create the thread with method that implements
// relinquish the processor briefly so Max can do the other things
I hope this helps.
May 28, 2008 at 9:32pm
2008/5/28 Timothy Place
> It seems like you actually have two issues here: one is working with
Thanks a lot! That’s exactly what I need. It looks really similar to what I
I do use an infinite loop, but I don’t need it to sleep. It’s automatically
You didn’t mention critical regions, so just to be clear; I can create a
May 28, 2008 at 9:39pm
On 2008 May 28, at 4:32 PM, Thijs Koerselman wrote:
Great – I’m glad that was helpful. Yes, you can use the global
Apr 11, 2011 at 12:23pm
as mentioned before in this thread I took advantage of the possibility to create a thread inside an external.
Apr 27, 2011 at 5:32pm
Just a quick comment, but it’s hard for anyone to give you informed feedback without and example patch and object.
However, from the above it looks like you are creating a new thread often for every incoming number (that doesn’t match the last). Creating threads is more expensive than reusing them. And even still for something which is only using 3% CPU multithreading probably isn’t going to give you a noticeable improvement, as multithreading has some CPU costs in thread management and synchronization.
I realize that this is just a minimal example you’re using to learn the API, but if you’re going to test efficiency, you should test with computation heavy work.
There’s also some more advanced use of a pool of threads in the SDK “threadpool” example, and if you search the dev forums on “parallel” you’ll find info on using the ext_parallel.h API, but these might be overkill for your purposes.
Dec 6, 2012 at 2:35pm
This is a very interesting topic and because many applications done with max are time-critical due to the focus on realtime capability.
You must be logged in to reply to this topic.