
Dear all, i am new to threading. i want to know the following. Given a shared object which is accessed by more than one process, where should we implement the mutex locking? Is it in the shared object or in the critical section of the Processes? If locking is done in process, will it work having different names for the locks in the processes? class A { .......... ........ public: execute() { ......... lock(mutex1) //write data to shared object unlock(mutex1) ......... } }; class B { .......... ........ public: execute() { ......... lock(mutex2) //write data to shared object unlock(mutex2) ......... } }; SharedObject { ........... .......... }; -- Wesley K

Wesley Khandavalli wrote:
Given a shared object which is accessed by more than one process, where should we implement the mutex locking? Is it in the shared object or in the critical section of the Processes?
you lock where the data is being accessed.
If locking is done in process, will it work having different names for the locks in the processes?
I'm not sure what you mean. You might also want to take a look at this article: http://www.ddj.us/cpp/211600441?pgno=3 -- alfonso e. urdaneta _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the originator of the message. This footer also confirms that this e-mail message has been scanned for the presence of computer viruses. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Indra Systems, Inc.
participants (2)
-
Alfonso Urdaneta
-
Wesley Khandavalli