Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Feb 2022 17:18:29 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Sebastian Huber <sebastian.huber@embedded-brains.de>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: ntp_init() looks like a nop
Message-ID:  <YgE4RaZVZhOlhJHW@kib.kiev.ua>
In-Reply-To: <ac806cf6-a17f-77ba-5633-0c95eda1f8cf@embedded-brains.de>
References:  <ac806cf6-a17f-77ba-5633-0c95eda1f8cf@embedded-brains.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Feb 07, 2022 at 04:04:56PM +0100, Sebastian Huber wrote:
> Hello,
> 
> I review currently the kern_ntptime.c module since I would like to use it in
> RTEMS. I have a question to ntp_init():
> 
> /*
>  * ntp_init() - initialize variables and structures
>  *
>  * This routine must be called after the kernel variables hz and tick
>  * are set or changed and before the next tick interrupt. In this
>  * particular implementation, these values are assumed set elsewhere in
>  * the kernel. The design allows the clock frequency and tick interval
>  * to be changed while the system is running. So, this routine should
>  * probably be integrated with the code that does that.
>  */
> static void
> ntp_init(void)
> {
> 
> 	/*
> 	 * The following variables are initialized only at startup. Only
> 	 * those structures not cleared by the compiler need to be
> 	 * initialized, and these only in the simulator. In the actual
> 	 * kernel, any nonzero values here will quickly evaporate.
> 	 */
> 	L_CLR(time_offset);
> 	L_CLR(time_freq);
> #ifdef PPS_SYNC
> 	pps_tf[0].tv_sec = pps_tf[0].tv_nsec = 0;
> 	pps_tf[1].tv_sec = pps_tf[1].tv_nsec = 0;
> 	pps_tf[2].tv_sec = pps_tf[2].tv_nsec = 0;
> 	pps_fcount = 0;
> 	L_CLR(pps_freq);
> #endif /* PPS_SYNC */	
> }
> 
> SYSINIT(ntpclocks, SI_SUB_CLOCKS, SI_ORDER_MIDDLE, ntp_init, NULL);
> 
> The ntp_init() function sets a couple of global variables to zero. These
> variables should be in the .bss section. Are they not already cleared during
> the kernel loading?
This is nop indeed, be it linked in kernel, or loaded as a module.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YgE4RaZVZhOlhJHW>