Re: semaphore question
- From: "Jack" <junw2000@xxxxxxxxx>
- Date: 16 Aug 2006 09:22:19 -0700
David Schwartz wrote:
Thinking about mutexes as protecting code leads to people putting
mutexes around code that has no need to be protected. Only shared data
(or resources of some kind) requires protection.
Code never needs to be protected. Concurrent accesses of the same code
is totally safe and permitted.
Thanks. But my understanding is that mutex/semaphore protects a
resource through code. For example, user A uses code1 below to control
the access of resource R:
while(1){
wait(mutex1); //LINE0
access resource R;
signal(mutex1);
}
User B uses code2 below to control the access of resource R:
while(1){
wait(mutex2); //LINE1
access resource R;
signal(mutex2);
}
Since user A and user B use different mutex, they can not prevent each
other from accessing the common resource R. Am I right?
Jack
.
- Follow-Ups:
- Re: semaphore question
- From: 42Bastian Schick
- Re: semaphore question
- References:
- semaphore question
- From: Jack
- Re: semaphore question
- From: 42Bastian Schick
- Re: semaphore question
- From: Josef Moellers
- Re: semaphore question
- From: David Schwartz
- semaphore question
- Prev by Date: Re: Inject a shared library or DLL into a running process in Linux
- Next by Date: Re: unwanted double reads in /proc routines
- Previous by thread: Re: semaphore question
- Next by thread: Re: semaphore question
- Index(es):
Relevant Pages
|