Re: semaphore question




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

.



Relevant Pages

  • How do you want to access shared resources?
    ... We need opinions of embedded or real-time software designers ... introducing a shared resource protection mechanism to our kernel. ... We are considering choices to express resource locking: ...
    (comp.realtime)
  • Re: Program protection manual for the C-64
    ... but it's probably the best resource on copy protection I've ... Would you consider photocopying and posting to someone willing to scan ...
    (comp.sys.cbm)
  • Re: Program protection manual for the C-64
    ... but it's probably the best resource on copy protection I've ... Would you consider photocopying and posting to someone willing to scan ...
    (comp.sys.cbm)
  • Re: Program protection manual for the C-64
    ... I can keep this link up for awhile. ... David Haynes ... but it's probably the best resource on copy protection I've ...
    (comp.sys.cbm)
  • Re: Venting on .NET
    ... the Dialog editor spits out a .rc file. ... as not properly naming a control), hand-editing the generated code to rename a control is ... the field of cognitive psyhcology, Alan Newell and Herb Simon], I can state that NO design ... >That's certainly true is we're talking about resource templates in the Win32 ...
    (microsoft.public.vc.mfc)