How many threads / mutexes can we use?

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

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:

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.

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?:>

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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org