I understand the need of EnterCriticalSection() if both threads sharing memory, but if for example one thread is calling a function that is only reading the memory, and the other thread updates it, is EnterCriticalSection() still needed as only one is updating it?
Neil
----- Original Message ----- From: "Jason Teagle" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, April 30, 2005 5:30 PM
Subject: RE: [msvc] Posting a message
As I am using 2 processors, and having 4 threads in my IOCP. If for example 4 threads do a Postmessages with he same message,(for example the above message). When the system comes to execute the function 4 times, does it wait until one is finished before doing the next one? If not, suppose I am better doing a EnterCriticalSection(..) and LeaveCriticalSection(..) withn the routine?
Unfortunately I do not know the answer to that, but as far as I am aware,
there is no reason for any of the threads to wait for another to finish the
message handler - the message queues work independently, I believe. However,
since you call AllocBuffer() each time (from each separate thread), my basic
knowledge of thread behaviour says it should be OK, since they each have
their own memory to work on. Critical sections are usually only needed when
you are having multiple threads access shared data. Dev or Ehsan can correct
me on that if it's wrong...
-- Jason Teagle [EMAIL PROTECTED]
_______________________________________________
msvc mailing list
[email protected]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.
_______________________________________________ msvc mailing list [email protected] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.
