Original Post
Hi All, I am trying to code an engine (as everybody else here) and I have a problem. My engine is supposed to be threaded. One thread is for display & graphics etc. usual tasks and the other thread is (there are exactly 2 threads) for the scripting VM. I have a dual core processor, so supposedly, both threads should be running on their own processor. That is why I am expecting the scripting thread should not drop FPS. When I disable scripting and just go with single thread, I got FPS about 40. When I enable scripting, and go with 2 threads, I get 15 to 20. There are 2 places which might be responsible from this, I think. One is the thread affinity setting used in QueryPerformanceCounter function, (to prevent bugs in dual core systems.. mentioned in some other thread in gamedev) And the other one is the WinAPI mutex thing I am using. (Scripting system can send data to display on screen, so there is some amount of shared data. And I am using it to prevent concurrent access to the data.) So, I commented out the timer call from the scripting thread, so it will not change the thread affinity. But this did not seemed to help. So, I assume the problem is with mutex.. (other ideas are also welcome) So, I decided to write my own mutex. Since I am only trying to sync 2 threads, no interprocess things etc, a very lightweight thing would be enough.. But before beginning on that, I wanted to ask you, which libraries do you use for that and is there any lightweight libraries you can recommend? (I do not use boost, and I am not planning to use it for this project only for mutex) (I also do not use/do not plan to use pthreads or any other threading libraries.) By the way, I am coding in C++. (using OpenGL) Any help/idea/references appreciated..