bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/4] Monotonic clock device in GNU Mach


From: Samuel Thibault
Subject: Re: [PATCH 0/4] Monotonic clock device in GNU Mach
Date: Thu, 5 Apr 2012 21:56:53 +0200
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Pino Toscano, le Mon 02 Apr 2012 22:33:36 +0200, a écrit :
> @@ -103,6 +104,16 @@
>               mtime->microseconds = (time)->microseconds;     \
>               asm volatile("":::"memory");                    \
>               mtime->seconds = (time)->seconds;               \
> +             asm volatile("":::"memory");                    \
> +             mtime->clock_rt.seconds = (time)->seconds;      \
> +             asm volatile("":::"memory");                    \
> +             mtime->clock_rt.nanoseconds =                   \
> +                     (time)->microseconds * 1000;            \
> +             asm volatile("":::"memory");                    \
> +             mtime->clock_mt.seconds = (monotonic)->seconds; \
> +             asm volatile("":::"memory");                    \
> +             mtime->clock_mt.nanoseconds =                   \
> +                     (monotonic)->microseconds * 1000;       \
>       }                                                       \
>  MACRO_END
>  

This does not actually bring read safety. The original code uses
memory barriers to make sure that microsecond update happens
between check_seconds and seconds are updated, so that code like
record_time_stamp works. That part needs to be kept as is for
compatibility, and additions need to implement something similar. Just
putting memory barriers will not work, you'd also need a similar
check_foo field, and test it in the reader part; or use a generation
number, like xnu's commpage_set_nanotime, something like:

sav = mtime->generation;
mtime->generation = 0
asm volatile("":::"memory");
mtime->clock_rt.seconds = (time)->seconds
mtime->clock_rt.nanoseconds = (time)->microseconds * 1000.
mtime->clock_mt.seconds = (monotonic)->seconds
mtime->clock_mt.nanoseconds = (monotonic)->microseconds * 1000.
asm volatile("":::"memory");
mtime->generation = sav+1;

Samuel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]