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

Multithreading considerations...

Started by Noods Aug 25, 2008 at 9:43 PM 0 replies 900+ views
Original Post
Noods
Noods
I have recently implemented a C++/Win32 multimedia timer which is working well. The callback function for this runs in a different thread. I have not experienced any bugs due to this multithreading but I would like to put some synchronization protection in place to prevent any hiccups. I have read up on multithreading a bit. This seems to be a pretty good article. http://paulbridger.net/node/17 However, I have never really implemented multithreading. Is it safe to say that multithread protection is basically synchronization protection for resources? Are there any other considerations I should keep in mind before diving in?
losethos
losethos
As far as I know, the multimedia timer is a hardware timer and in Visual C you call a routine to read it. Some timers are accessed from multiple I/O ports in the process of reading them and must be read atomically. I'd be surprised if Visual C didn't do that for you. Sometimes, a timer overflows at a periodic rate and the OS must keep track of the most significant bytes. (An interrupt will occur at overflow and the OS will increment the high bytes implemented as an internal variable to the OS.)

When in doubt, make two threads that read it over and over and see if it gets corrupted. If it's okay, you're not absolutely sure it's correct, but if it fails, you know it doesn't work.

Topic Locked

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

Sign in to reply to this topic.