Creating threads.

Discussion about everything. New games, 3d math, development tips...
Post Reply
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Creating threads.

Post by 3DModelerMan »

What happens when you try to create a thread on a single core? Does it create a fake thread? Or does it return an error? I don't have a single core, so I can't tell.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

You can always create multiple threads, no matter which cpu you have.
The OS manages the threads itself, having multiple cores is just a bonus so each thread is likely to be executed on a different core.
Never take advice from someone who likes to give advice, so take my advice and don't take it.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Each thread is run for very short time. Then the current processor state is saved somewhere and the processor state of another thread is loaded (called a context switch) and then the next thread runs a very short time. So when each thread is using up it's whole slice of time then for x threads each of them will only have 1/x of the available processor time (minus some minor additional time needed for the context switch). But threads can also give up their time earlier, for example with sleep(), if they have nothing to do.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply