Re: Simple Flag on SMP
From: Thomas Richter (thor_at_cleopatra.math.tu-berlin.de)
Date: 11/04/03
- Next message: Neil Horman: "Re: Simple Flag on SMP"
- Previous message: Frank A. Uepping: "Simple Flag on SMP"
- In reply to: Frank A. Uepping: "Simple Flag on SMP"
- Next in thread: Neil Horman: "Re: Simple Flag on SMP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 4 Nov 2003 12:42:33 GMT
Hi,
> suppose I have a simple flag (a boolean) that is being operated on by
> multiple CPUs (SMP system) concurrently. The flag is of type int and
> accessing a int is guaranteed to be atomic on Linux (isn't it?).
I don't see why it should in general.
Even here you should make this "volatile" if you access it from different
threads since the compiler might change the order of accesses.
> I am concerned about, that the flag's status, when changed, becomes not
> immediately visible to other CPUs (because of caching or whatever).
> Maybe qualifying the flag as volatile would do, but I have read that
> volatile is to weak for SMP, is that true?
Yes.
> What are other alternatives to volatile?
Using a construction like semaphores or mutex's to represent your
data, for example. It is then the matter of the stdlib to implement
the gory details.
So long,
Thomas
- Next message: Neil Horman: "Re: Simple Flag on SMP"
- Previous message: Frank A. Uepping: "Simple Flag on SMP"
- In reply to: Frank A. Uepping: "Simple Flag on SMP"
- Next in thread: Neil Horman: "Re: Simple Flag on SMP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|