tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: What's an "MPSAFE" driver need to do?
On 28 Feb, 2013, at 15:29 , Mouse <mouse%Rodents-Montreal.ORG@localhost> wrote:
> Also a bit disturbing is that I see memory barriers in various places,
> in particular some parts of the mutex implementation, but the
> documentation is completely silent on whether clients of the mutex
> interface may assume anything memory-barrier-ish.
They can. I think the guarantee is that anything you write before you
release the mutex is what the next guy who acquires the mutex will
read. I'm not sure why it doesn't say this.
> While not directly related, I also note some issues in the memory
> barrier descriptions:
>
> - membar_enter and membar_exit speak of loads "reach[ing] global
> visibility", which makes no sense to me. What does it mean for a
> load to reach global visibility?
I actually have no idea what these do and when one would use them.
> - membar_consumer is described with "All loads preceding the memory
> barrier will complete before any loads after the memory barrier
> complete". That last "complete" needs to be "start" for this to be
> a useful guarantee.
I don't know about this, it seems like you could replace both "complete"s
with "start"s, or either one, and still come out about right. I think
the guarantee is that if one guy does
i = j = 0;
...
i = 1;
membar_producer();
j = 1;
and the other guy does
my_j = j;
membar_consumer();
my_i = i;
then the latter guy will never see
(my_i == 0 && my_j == 1)
It doesn't really matter when the loads "start" and "complete" as long
as the ordering of the writer is observed that way by the reader.
> - membar_sync has each of the above issues (mutatis mutandis).
I think this one guarantees that if one guy does
i = 1;
membar_sync()
my_j = j;
and the other guy does
j = 1;
membar_sync()
my_i = i;
they will never see
(my_i == 0 && my_j == 0)
Also, in the case where one guy does
my_j = j;
membar_sync()
i = 1;
while the other guy does
my_i = i;
membar_sync();
j = 1;
they will never see
(my_i == 1 && my_j == 1)
How would this be better described?
Dennis Ferguson
Home |
Main Index |
Thread Index |
Old Index