The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
How many threads / mutexes can we use?
ShiroAisu


Joined: 09 Jun 2010
Posts: 42
Hello.

I'm creating a heavily threaded game and I wanted to know: is there a limit for the amount of mutexes and threads we can use / define / start?

Thank you for the attention
How many threads / mutexes can we use?
Ryan C. Gordon
Guest

Quote:
I'm creating a heavily threaded game and I wanted to know: is there a
limit for the amount of mutexes and threads we can use / define / start?

There's no limit to the number of threads in SDL, and it doesn't look
like most modern OSes have serious limits either (but if nothing else,
you can easily run out of address space for each thread's stack in a
32-bit process, etc).

For Windows:

http://blogs.msdn.com/b/oldnewthing/archive/2005/07/29/444912.aspx

For Linux:


http://stackoverflow.com/questions/344203/maximum-number-of-threads-per-process-in-linux


But I would say if you're spinning this many threads, reconsider. Most
of the time, one thread doing heavy work per CPU core can be a win (at a
cost of having to maintain multithreaded code), but most things after
that turn out to be a design mistake, if having threads at all isn't one
in itself.

--ryan.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
How many threads / mutexes can we use?
Jorge Rodriguez
Guest

I'm hardly an expert in parallel programming but in my experience the benefit of more threads drops drastically after it begins to exceed the number of physical processor cores. After a while the overhead of more threads will exceed any benefits.
If your goal is to have something that's always responsive to eg network traffic or sound then a better solution may be to scatter NetworkUpdate () etc calls around your frame (and not do any blocking operations in that function) to make sure you don't miss anything. El jul 26, 2014 8:32 PM, "Ryan C. Gordon" escribió:
Quote:

Quote:
I'm creating a heavily threaded game and I wanted to know: is there a
limit for the amount of mutexes and threads we can use / define / start?

There's no limit to the number of threads in SDL, and it doesn't look like most modern OSes have serious limits either (but if nothing else, you can easily run out of address space for each thread's stack in a 32-bit process, etc).

For Windows:

    http://blogs.msdn.com/b/oldnewthing/archive/2005/07/29/444912.aspx

For Linux:


http://stackoverflow.com/questions/344203/maximum-number-of-threads-per-process-in-linux


But I would say if you're spinning this many threads, reconsider. Most of the time, one thread doing heavy work per CPU core can be a win (at a cost of having to maintain multithreaded code), but most things after that turn out to be a design mistake, if having threads at all isn't one in itself.

--ryan.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org