|
-
August 17th, 2010, 08:33 PM
#6
Re: Multi-threading and Accessing a Mutex
 Originally Posted by Shard
I'm spawning concurrent threads thats do the same task on different pieces of data with a shared source.
For example, I have a 3x3 grid that needs to be worked on.
I spawn a new thread for each of the nodes in that grid.
But, they share a common piece of data as well, in this case a deqeue that is in the class.
Thus, there needs to be opening of the mutex in the thread so that the cocurrent threads don't try to work on the data at the same time.
Understand that you may not need to use a mutex and can use critical sections. Like I mentioned, critical sections are ideal for in-process synchronization tasks (and they're faster than the kernel mode mutex).
You can use a critical section to control access to the dequeue. If each 'grid node' thread only ever operates on a single node (without any node overlap), then you may not need to synchronize thread access to each node.
Of course, you know what you need to do better than I.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|