Re: shared memory between processes
From: Peter T. Breuer (ptb_at_lab.it.uc3m.es)
Date: 05/09/05
- Next message: Kasper Dupont: "Re: Memory testing in a kernel thread"
- Previous message: Todd Knarr: "Re: shared memory between processes"
- In reply to: Todd Knarr: "Re: shared memory between processes"
- Next in thread: David Schwartz: "Re: shared memory between processes"
- Reply: David Schwartz: "Re: shared memory between processes"
- Reply: Todd Knarr: "Re: shared memory between processes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 9 May 2005 19:03:27 +0200
Todd Knarr <tknarr@silverglass.org> wrote:
> Conclusion: both interlocking via mutexes _and_ instruction to the
> compiler to always refer to the actual memory location are neccesary.
No mutexes are proved to be necessary by your evidence. Yes, you
need volatile (or anything else that causes reread on access). The
range of result values comes from reading registers, presumably.
The assembler will say.
The experiment did not seem very controlled to me. Can you please show:
1) no mutex or volatile
2) no mutex and yes, volatile
3) no mutex and static, not volatile
4) no mutex and static plus volatile.
At -O0, -O1 and -O2.
You can repeat with mutex if you like, but logically it is not
necessary since an integer read/write is atomic anyway. I don't believe
it would do anything one way or the other, except possibly make the
compiler treat the global as volatile under low optimizations.
> What bothers me about this whole conversation is that, the way I read
> it, people are claiming that, if a mutex protects memory location X, you
> can and should ignore the fact that the code may be referring to memory
> location Y _not_ protected by the mutexes.
?? I don't follow.
> It seems clear to me that,
> no matter what the Posix standard says about the mutex functions, you
> _can't_ simply ignore what the C and C++ standards say about the use
> of volatile as related to variables that may be asynchronously modified
> when you intend to asynchronously modify those variables.
Well, I still maintain that C says that it reads the value in a
variable when you ask it to! Not the value in a register that it may
have once used to hold the variable, and which now contains some other
value. I don't think volatile should be needed if you use -O0, and/or
tell the compiler not to use registers for globals (somehow).
Peter
- Next message: Kasper Dupont: "Re: Memory testing in a kernel thread"
- Previous message: Todd Knarr: "Re: shared memory between processes"
- In reply to: Todd Knarr: "Re: shared memory between processes"
- Next in thread: David Schwartz: "Re: shared memory between processes"
- Reply: David Schwartz: "Re: shared memory between processes"
- Reply: Todd Knarr: "Re: shared memory between processes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|