AW: AW: [PATCH 05/12] kern_tc.c: Replace atomic functions required by PPS API

Gabriel.Moyano at dlr.de Gabriel.Moyano at dlr.de
Thu Apr 7 13:14:11 UTC 2022


> On 07/04/2022 11:55, Gabriel.Moyano at dlr.de wrote:
> >> On 07/04/2022 10:36, Gabriel Moyano wrote:
> >>> ---
> >>>    cpukit/include/sys/timepps.h | 4 ++++
> >>>    cpukit/score/src/kern_tc.c   | 7 +++++++
> >>>    2 files changed, 11 insertions(+)
> >>>
> >>> diff --git a/cpukit/include/sys/timepps.h
> >>> b/cpukit/include/sys/timepps.h index 621afb08ec..5703381ffa 100644
> >>> --- a/cpukit/include/sys/timepps.h
> >>> +++ b/cpukit/include/sys/timepps.h
> >>> @@ -32,7 +32,11 @@
> >>>
> >>>    typedef int pps_handle_t;
> >>>
> >>> +#ifndef __rtems__
> >>>    typedef unsigned pps_seq_t;
> >>> +#else /* __rtems__ */
> >>> +typedef Atomic_Uint	pps_seq_t;
> >>> +#endif /* __rtems__ */
> >>>
> >>>    typedef struct ntp_fp {
> >>>    	unsigned int	integral;
> >>> diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
> >>> index e57da2c0ca..77f7a9212c 100644
> >>> --- a/cpukit/score/src/kern_tc.c
> >>> +++ b/cpukit/score/src/kern_tc.c
> >>> @@ -1932,10 +1932,17 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps)
> >>>    			tv.tv_usec = fapi->timeout.tv_nsec / 1000;
> >>>    			timo = tvtohz(&tv);
> >>>    		}
> >>> +#ifndef __rtems__
> >>>    		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)) {
> >>> +#else /* __rtems__ */
> >>> +		aseq = atomic_load_acq_int(&pps->ppsinfo.assert_sequence);
> >>> +		cseq = atomic_load_acq_int(&pps->ppsinfo.clear_sequence);
> >>> +		while (aseq == atomic_load_acq_int(&pps->ppsinfo.assert_sequence) &&
> >>> +		    cseq == atomic_load_acq_int(&pps->ppsinfo.clear_sequence)) {
> >>> +#endif /* __rtems__ */
> >>>    			if (abi_aware(pps, 1) && pps->driver_mtx != NULL) {
> >>>    				if (pps->flags & PPSFLAG_MTX_SPIN) {
> >>>    					err = msleep_spin(pps, pps->driver_mtx,
> >> Why do you need this change?
> >>
> > If you mean why atomic_load_int() was replaced by atomic_load_acq_int(), it is because atomic_load_int()  is not defined in rtems
> but in rtems-libbsd.
> 
> In FreeBSD, it seems the sequence is sometimes incremented using a normal increment, for example:
> 
> 	*pcount = pps->capcount;
> 	(*pseq)++;
> 	*tsp = ts;
> 
> So, just add the atomic_load_int() as an relaxed atomic load to the other inline functions at the top of the file.

atomic_load_acq_int() is defined also at the beginning of the file. Do you want to repeat the function but with other name (atomic_load_int()) ? 


> I guess the synchronization needs a review in FreeBSD.
> 


More information about the devel mailing list