   SDL multithreading not taking advantage of my dual core?
  I've been using some Windows specific threading code before, and now decided to go with SDL's threading implementation. With the Windows specific code I got my application to use both CPU cores on my computer, however with the SDL implementation it only uses one core - which in a few of my cases makes it worthless.I'm using a little threading class which is inherited by a class when a seperate thread is needed for it:Thread.h#ifndef SDL_THREAD_PARENT#define SDL_THREAD_PARENT#include <SDL_Thread.h>class Thread {public:Thread();virtual ~Thread();void start();virtual void codeToRun() { }bool isRunning() { return (t != NULL); }void decapitate();   void wait(); //waits for the thread to end its run and returns.void nullify();private:SDL_Thread *t;    };#endifThread.cpp#include "Thread.h"extern "C" {int _ou_thread_proc(void* param) {Thread* tp = (Thread*)param;tp->codeToRun();tp->nullify();return 0;}}void Thread::nullify() {t = NULL;}Thread::Thread() {t = NULL;}Thread::~Thread() {if (t != NULL)SDL_KillThread(t);t = NULL;}void Thread::decapitate() {if (t != NULL)SDL_KillThread(t);}void Thread::wait() {if (t != NULL)SDL_WaitThread(t, NULL);t = NULL;}void Thread::start() {t = SDL_CreateThread (_ou_thread_proc, (Thread*)this); }EDIT: Added source. Maybe it wasnt necessary... but anything that helps you help me :D   
  I'm using SDL threads, both cores get used.I dislike the look of your Thread class, it appears that it will leak memory, unless you always call SDL_WaitThread. Given that your thread function nullifies the thread variable before returning, this can never happen.Have you considered boost.thread?   ;  When you use SDL on Win32, all it does is call the Win32 threading functions (CreateThread, WaitForSingleObject, etc.).  The only thing SDL could do to throw  a wrench in the works would be would be if (for some reason) it messed with process affinities or thread affinities.  Setting process affinity causes a process and all it's child thread to only execute on a specified CPU, while setting thread affinity does the same for threads. I did a quick look through the SDL source and didn't see this anywhere, but I didn't have time to do a thorough search.   ;  Or it could just be that the way the threads are being used cannot be done in parallel. How do you even know it only uses one core? (Not that you can guarantee that it'll use 2 cores - the OS decides which CPU gets a thread.)   ;Quote:Original post by rip-offHave you considered boost.thread?No, I have not. I might check it out, thanks for the tip.Quote:Original post by MJPSetting process affinity causes a process and all it's child thread to only execute on a specified CPU, while setting thread affinity does the same for threadsOk, well when I check the process in the process manager it says both CPU's are set for affinity.Quote:Original post by KylotanOr it could just be that the way the threads are being used cannot be done in parallel. How do you even know it only uses one core? (Not that you can guarantee that it'll use 2 cores - the OS decides which CPU gets a thread.)Some of the things I do can be done in parallel and has been done in parallel on both cores before when I used the Win32 threading functions. I know that only one core is being used because the program should run at 100% CPU usage, but is only running at 50% constantly. The only difference from that time I can think of now is that I've activated some "optimize for windows" option in the Visual Studio project settings.   ;Quote:Original post by AlexanderLThe only difference from that time I can think of now is that I've activated some "optimize for windows" option in the Visual Studio project settings.It's "Optimize for Windows 98", isn't it? Shouldn't be related to threading at all, but still a pretty pointless option if you aren't actually targeting win98.   ;Quote:Original post by SpoonbenderIt's "Optimize for Windows 98", isn't it?No, it's not that option - it's /GA, http://msdn2.microsoft.com/en-us/library/yetwazx6(VS.80).aspx