Skip to main content
GameDev.net gamedev.net
🔒 Locked

Thread angst in Windows

Started by Truckhunter Oct 15, 2001 at 2:29 PM 3 replies 550+ views
Original Post
Truckhunter
Truckhunter
I''m working on an interesting project right now that involves some multi-threaded stuff for game development. However, I''m running into some blocks with the win32 API. I''m using the standard API with CreateThread/SuspendThread/ResumeThread/... for my thread manager. What I want to be able to do is, given a thread handle or thread id, find out if that current thread is blocked (specifically, waiting on a semaphore.) Does anyone know how to do this with the Windows Thread API? Or are there any other thread API''s that can be used under Windows that might allow this kind of functionality?
Anon Mike
Anon Mike
Ick, what are you really trying to do that you need this level of info? I don''t think there is a standard way to determine if a thread is blocked. You might be able to play games with GetThreadContext but there won''t be any guarantees.

I believe that SuspendThread is really only meant to be used by debuggers - at least I''ve never needed it.

-Mike
-Mike
Shannon Barber
Shannon Barber
If you need to know that, threading hasn''t made your life any easier :p

To detect a stalled thread you can use global watch-dog counters. Each thread gets a global hole that it increments while it''s running (in lingo "kicks the dog"). Then you decide on a time-out, and if the watch-dog doesn''t twiddling in that time-out perdio you assume it has stalled.
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
noparity
noparity
What technique/API(s) are you using for syncronization (i.e. are you calling WaitForSingleObject etc. to obtain a lock on a semaphore)?
Truckhunter
Truckhunter
I guess I''ll clarify why I need this information a bit more. What I''m working on is a research project to see what possible benefits could be found by applying a few different Real-time scheduling algorithms to interactive multimedia applications (games being one, but not the only, example of this.) So what I need to write is my own thread manager that will be responsible for managing the threads belonging to the tasks that it is given. Because I''m working on a reusable API, I won''t know for sure what kind of synchronization methods the application will use, so I can''t rely on any of that information. I may be able to adapt the watchdog approach, but I''m not sure if it would be the most efficient. If I can''t get that to work, I''ll post something new with more details about the specific situation

Thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.