diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-15 11:03:41 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-15 11:03:41 +0100 |
commit | 4fc6cb13da6628fef1ce2e3a45a036cc3804b93e (patch) | |
tree | 23fee1b7c0dfa12832311a215f3035a23958cacb | |
parent | 7526fd0cf744be598be1cc6cd7c6e1b894735283 (diff) | |
download | gnumach-4fc6cb13da6628fef1ce2e3a45a036cc3804b93e.tar.gz gnumach-4fc6cb13da6628fef1ce2e3a45a036cc3804b93e.tar.bz2 gnumach-4fc6cb13da6628fef1ce2e3a45a036cc3804b93e.zip |
timer: Fix atomicity of timer reads
Similarly to update_mapped_time/read_mapped_time, one need to
synchronize the writes and read to make sure they are performed in the
expected order.
-rw-r--r-- | kern/timer.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/kern/timer.c b/kern/timer.c index af6d4b28..3b81ab79 100644 --- a/kern/timer.c +++ b/kern/timer.c @@ -334,7 +334,9 @@ void timer_normalize(timer_t timer) high_increment = timer->low_bits/TIMER_HIGH_UNIT; timer->high_bits_check += high_increment; + __sync_synchronize(); timer->low_bits %= TIMER_HIGH_UNIT; + __sync_synchronize(); timer->high_bits += high_increment; } @@ -356,7 +358,9 @@ static void timer_grab( #endif do { (save)->high = (timer)->high_bits; + __sync_synchronize (); (save)->low = (timer)->low_bits; + __sync_synchronize (); /* * If the timer was normalized while we were doing this, * the high_bits value read above and the high_bits check |