[rtems commit] Use atomic_load(9) to read ppsinfo sequence numbers.

Sebastian Huber sebh at rtems.org
Mon Nov 15 08:15:16 UTC 2021


Module:    rtems
Branch:    master
Commit:    118208b1f1107d0688543688c2c9c80b7477c178
Changeset: http://git.rtems.org/rtems/commit/?id=118208b1f1107d0688543688c2c9c80b7477c178

Author:    Konstantin Belousov <kib at FreeBSD.org>
Date:      Tue Dec 19 10:05:45 2017 +0000

Use atomic_load(9) to read ppsinfo sequence numbers.

In this case volatile qualifiers enusre that a compiler does not
optimize the accesses out.

Reviewed by:	alc, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D13534

---

 cpukit/score/src/kern_tc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index 5fd318e..ec30d81 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -1816,10 +1816,10 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps)
 			tv.tv_usec = fapi->timeout.tv_nsec / 1000;
 			timo = tvtohz(&tv);
 		}
-		aseq = pps->ppsinfo.assert_sequence;
-		cseq = pps->ppsinfo.clear_sequence;
-		while (aseq == pps->ppsinfo.assert_sequence &&
-		    cseq == pps->ppsinfo.clear_sequence) {
+		aseq = atomic_load_int(&pps->ppsinfo.assert_sequence);
+		cseq = atomic_load_int(&pps->ppsinfo.clear_sequence);
+		while (aseq == atomic_load_int(&pps->ppsinfo.assert_sequence) &&
+		    cseq == atomic_load_int(&pps->ppsinfo.clear_sequence)) {
 			if (abi_aware(pps, 1) && pps->driver_mtx != NULL) {
 				if (pps->flags & PPSFLAG_MTX_SPIN) {
 					err = msleep_spin(pps, pps->driver_mtx,



More information about the vc mailing list