亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ktime.c

?? 內核中關于nano計時的功能
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*********************************************************************** *								       * * Copyright (c) David L. Mills 1993-2001			       * *								       * * Permission to use, copy, modify, and distribute this software and   * * its documentation for any purpose and without fee is hereby	       * * granted, provided that the above copyright notice appears in all    * * copies and that both the copyright notice and this permission       * * notice appear in supporting documentation, and that the name	       * * University of Delaware not be used in advertising or publicity      * * pertaining to distribution of the software without specific,	       * * written prior permission. The University of Delaware makes no       * * representations about the suitability this software for any	       * * purpose. It is provided "as is" without express or implied	       * * warranty.							       * *								       * **********************************************************************/#include "kern.h"/* * Generic NTP kernel interface * * These routines constitute the Network Time Protocol (NTP) interfaces * for user and daemon application programs. The ntp_gettime() routine * provides the time, maximum error (synch distance) and estimated error * (dispersion) to client user application programs. The ntp_adjtime() * routine is used by the NTP daemon to adjust the system clock to an * externally derived time. The time offset and related variables set by * this routine are used by other routines in this module to adjust the * phase and frequency of the clock discipline loop which controls the * system clock. * * When the kernel time is reckoned directly in nanoseconds (NTP_NANO * defined), the time at each tick interrupt is derived directly from * the kernel time variable. When the kernel time is reckoned in * microseconds, (NTP_NANO undefined), the time is derived from the * kernel time variable together with a variable representing the * leftover nanoseconds at the last tick interrupt. In either case, the * current nanosecond time is reckoned from these values plus an * interpolated value derived by the clock routines in another * architecture-specific module. The interpolation can use either a * dedicated counter or a processor cycle counter (PCC) implemented in * some architectures. * * Note that all routines must run at priority splclock or higher. *//* * Phase/frequency-lock loop (PLL/FLL) definitions * * The nanosecond clock discipline uses two variable types, time * variables and frequency variables. Both types are represented as 64- * bit fixed-point quantities with the decimal point between two 32-bit * halves. On a 32-bit machine, each half is represented as a single * word and mathematical operations are done using multiple-precision * arithmetic. On a 64-bit machine, ordinary computer arithmetic is * used. * * A time variable is a signed 64-bit fixed-point number in ns and * fraction. It represents the remaining time offset to be amortized * over succeeding tick interrupts. The maximum time offset is about * 0.5 s and the resolution is about 2.3e-10 ns. * *			1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |s s s|			 ns				   | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |			    fraction				   | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * * A frequency variable is a signed 64-bit fixed-point number in ns/s * and fraction. It represents the ns and fraction to be added to the * kernel time variable at each second. The maximum frequency offset is * about +-500000 ns/s and the resolution is about 2.3e-10 ns/s. * *			1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |s s s s s s s s s s s s s|	          ns/s			   | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |			    fraction				   | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ *//* * The following variables establish the state of the PLL/FLL and the * residual time and frequency offset of the local clock. */#define SHIFT_PLL	4	/* PLL loop gain (shift) */#define SHIFT_FLL	2	/* FLL loop gain (shift) */int time_state = TIME_OK;	/* clock state */int time_status = STA_UNSYNC;	/* clock status bits */long time_tai;			/* TAI offset (s) */long time_monitor;		/* last time offset scaled (ns) */long time_constant;		/* poll interval (shift) (s) */long time_precision = 1;	/* clock precision (ns) */long time_maxerror = MAXPHASE / 1000; /* maximum error (us) */long time_esterror = MAXPHASE / 1000; /* estimated error (us) */long time_reftime;		/* time at last adjustment (s) */long time_tick;			/* nanoseconds per tick (ns) */#if !defined(NTP_NANO)long time_nano;			/* nanoseconds past last tick */#endif /* NTP_NANO */l_fp time_offset;		/* time offset (ns) */l_fp time_freq;			/* frequency offset (ns/s) */l_fp time_adj;			/* tick adjust (ns/s) */l_fp time_phase;		/* time phase (ns) */#ifdef PPS_SYNC/* * The following variables are used when a pulse-per-second (PPS) signal * is available and connected via a modem control lead. They establish * the engineering parameters of the clock discipline loop when * controlled by the PPS signal. */#define PPS_FAVG	2	/* min freq avg interval (s) (shift) */#define PPS_FAVGDEF	8	/* default freq avg int (s) (shift) */#define PPS_FAVGMAX	15	/* max freq avg interval (s) (shift) */#define PPS_PAVG	4	/* phase avg interval (s) (shift) */#define PPS_VALID	120	/* PPS signal watchdog max (s) */#define PPS_MAXWANDER	100000	/* max PPS wander (ns/s) */#define PPS_POPCORN	2	/* popcorn spike threshold (shift) */struct timespec pps_tf[3];	/* phase median filter */l_fp pps_freq;			/* scaled frequency offset (ns/s) */long pps_lastfreq;		/* last scaled freq offset (ns/s) */long pps_fcount;		/* frequency accumulator */long pps_jitter;		/* nominal jitter (ns) */long pps_stabil;		/* nominal stability (scaled ns/s) */long pps_lastcount;		/* last counter offset */long pps_lastsec;		/* time at last calibration (s) */int pps_valid;			/* signal watchdog counter */int pps_shift = PPS_FAVG;	/* interval duration (s) (shift) */int pps_shiftmax = PPS_FAVGDEF;	/* max interval duration (s) (shift) */int pps_intcnt;			/* wander counter *//* * PPS signal quality monitors */long pps_calcnt;		/* calibration intervals */long pps_jitcnt;		/* jitter limit exceeded */long pps_stbcnt;		/* stability limit exceeded */long pps_errcnt;		/* calibration errors */#endif /* PPS_SYNC *//* * End of phase/frequency-lock loop (PLL/FLL) definitions */void hardupdate();/* * ntp_gettime() - NTP user application interface * * See the timex.h header file for synopsis and API description. Note * that the TAI offset is returned in the ntvtimeval.tai structure * member.  */intntp_gettime(tp)	struct ntptimeval *tp;	/* pointer to argument structure */{	struct ntptimeval ntv;	/* temporary structure */	struct timespec atv;	/* nanosecond time */	int s;			/* caller priority */	s = splclock();	nano_time(&atv);#ifdef NTP_NANO	ntv.time.tv_sec = atv.tv_sec;	ntv.time.tv_nsec = atv.tv_nsec;#else	if (!(time_status & STA_NANO))		atv.tv_nsec /= 1000;	ntv.time.tv_sec = atv.tv_sec;	ntv.time.tv_usec = atv.tv_nsec;#endif /* NTP_NANO */	ntv.maxerror = time_maxerror;	ntv.esterror = time_esterror;	ntv.tai = time_tai;	splx(s);	*tp = ntv;		/* copy out the result structure */	/*	 * Status word error decode. If any of these conditions occur,	 * an error is returned, instead of the status word. Most	 * applications will care only about the fact the system clock	 * may not be trusted, not about the details.	 *	 * Hardware or software error	 */	if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) ||	/*	 * PPS signal lost when either time or frequency synchronization	 * requested	 */	    (time_status & (STA_PPSFREQ | STA_PPSTIME) &&	    !(time_status & STA_PPSSIGNAL)) ||	/*	 * PPS jitter exceeded when time synchronization requested	 */	    (time_status & STA_PPSTIME &&	    time_status & STA_PPSJITTER) ||	/*	 * PPS wander exceeded or calibration error when frequency	 * synchronization requested	 */	    (time_status & STA_PPSFREQ &&	    time_status & (STA_PPSWANDER | STA_PPSERROR)))		return (TIME_ERROR);	return (time_state);}/* * ntp_adjtime() - NTP daemon application interface * * See the timex.h header file for synopsis and API description. Note * that the timex.constant structure member has a dual purpose to set * the time constant and to set the TAI offset. */intntp_adjtime(tp)	struct timex *tp;	/* pointer to argument structure */{	struct timex ntv;	/* temporary structure */	long freq;		/* frequency ns/s) */	int modes;		/* mode bits from structure */	int s;			/* caller priority */	ntv = *tp;		/* copy in the argument structure */	/*	 * Update selected clock variables - only the superuser can	 * change anything. Note that there is no error checking here on	 * the assumption the superuser should know what it is doing.	 * Note that either the time constant or TAI offset are loaded	 * from the ntv.constant member, depending on the mode bits. If	 * the STA_PLL bit in the status word is cleared, the state and	 * status words are reset to the initial values at boot.	 */	modes = ntv.modes;	if (ROOT)		return (EPERM);	s = splclock();	if (modes & MOD_MAXERROR)		time_maxerror = ntv.maxerror;	if (modes & MOD_ESTERROR)		time_esterror = ntv.esterror;	if (modes & MOD_STATUS) {		if (time_status & STA_PLL && !(ntv.status & STA_PLL)) {			time_state = TIME_OK;			time_status = STA_UNSYNC;#ifdef PPS_SYNC			pps_shift = PPS_FAVG;#endif /* PPS_SYNC */		}		time_status &= STA_RONLY;		time_status |= ntv.status & ~STA_RONLY;	}	if (modes & MOD_TIMECONST) {		if (ntv.constant < 0)			time_constant = 0;		else if (ntv.constant > MAXTC)			time_constant = MAXTC;		else			time_constant = ntv.constant;	}	if (modes & MOD_TAI) {		if (ntv.constant > 0)			time_tai = ntv.constant;	}#ifdef PPS_SYNC	if (modes & MOD_PPSMAX) {		if (ntv.shift < PPS_FAVG)			pps_shiftmax = PPS_FAVG;		else if (ntv.shift > PPS_FAVGMAX)			pps_shiftmax = PPS_FAVGMAX;		else			pps_shiftmax = ntv.shift;	}#endif /* PPS_SYNC */	if (modes & MOD_NANO)		time_status |= STA_NANO;	if (modes & MOD_MICRO)		time_status &= ~STA_NANO;	if (modes & MOD_CLKB)		time_status |= STA_CLK;	if (modes & MOD_CLKA)		time_status &= ~STA_CLK;	if (modes & MOD_OFFSET) {		if (time_status & STA_NANO)			hardupdate(&TIMEVAR, ntv.offset);		else			hardupdate(&TIMEVAR, ntv.offset * 1000);	}	if (modes & MOD_FREQUENCY) {		freq = ntv.freq / SCALE_PPM;		if (freq > MAXFREQ)			L_LINT(time_freq, MAXFREQ);		else if (freq < -MAXFREQ)			L_LINT(time_freq, -MAXFREQ);		else			L_LINT(time_freq, freq);#ifdef PPS_SYNC		pps_freq = time_freq;#endif /* PPS_SYNC */	}	/*	 * Retrieve all clock variables. Note that the TAI offset is	 * returned only by ntp_gettime();	 */	if (time_status & STA_NANO)		ntv.offset = time_monitor;	else		ntv.offset = time_monitor / 1000;	ntv.freq = L_GINT(time_freq) * SCALE_PPM;	ntv.maxerror = time_maxerror;	ntv.esterror = time_esterror;	ntv.status = time_status;	ntv.constant = time_constant;	if (time_status & STA_NANO)		ntv.precision = time_precision;	else		ntv.precision = time_precision / 1000;	ntv.tolerance = MAXFREQ * SCALE_PPM;#ifdef PPS_SYNC	ntv.shift = pps_shift;	ntv.ppsfreq = L_GINT(pps_freq) * SCALE_PPM;	if (time_status & STA_NANO)		ntv.jitter = pps_jitter;	else		ntv.jitter = pps_jitter / 1000;	ntv.stabil = pps_stabil;	ntv.calcnt = pps_calcnt;	ntv.errcnt = pps_errcnt;	ntv.jitcnt = pps_jitcnt;	ntv.stbcnt = pps_stbcnt;#endif /* PPS_SYNC */	splx(s);	*tp = ntv;		/* copy out the result structure */	/*	 * Status word error decode. See comments in	 * ntp_gettime() routine.	 */	if ((time_status & (STA_UNSYNC | STA_CLOCKERR)) ||	    (time_status & (STA_PPSFREQ | STA_PPSTIME) &&	    !(time_status & STA_PPSSIGNAL)) ||	    (time_status & STA_PPSTIME &&	    time_status & STA_PPSJITTER) ||	    (time_status & STA_PPSFREQ &&	    time_status & (STA_PPSWANDER | STA_PPSERROR)))		return (TIME_ERROR);	return (time_state);}/* * ntp_tick_adjust() - called every tick for precision time adjustment * * This routine is ordinarily called from the tick interrupt routine * hardclock(). To minimize the jitter that might result when a higher * priority interrupt occurs after the tick interrupt is taken and * before the system clock is updated, this routine (and the following * routine second_overflow()) should be called early in the hardclock() * code path.  */voidntp_tick_adjust(tvp, tick_update)#ifdef NTP_NANO	struct timespec *tvp;	/* pointer to nanosecond clock */	int tick_update;	/* residual from adjtime() (ns) */#else	struct timeval *tvp;	/* pointer to microsecond clock */	int tick_update;	/* residual from adjtime() (us) */#endif /* NTP_NANO */{	long ltemp, time_update;	/*	 * Update the nanosecond and microsecond clocks. If the phase	 * increment exceeds the tick period, update the clock phase.	 */#ifdef NTP_NANO	time_update = tick_update;	L_ADD(time_phase, time_adj);	ltemp = L_GINT(time_phase) / hz;	time_update += ltemp;	L_ADDHI(time_phase, -ltemp * hz);	tvp->tv_nsec += time_update;#else	time_update = tick_update;	L_ADD(time_phase, time_adj);	ltemp = L_GINT(time_phase) / (1000 * hz);	time_update += ltemp;	L_ADDHI(time_phase, -ltemp * (1000 * hz));	tvp->tv_usec += time_update;	time_nano = L_GINT(time_phase) / hz;#endif /* NTP_NANO */}/* * second_overflow() - called after ntp_tick_adjust() * * This routine is ordinarily called immediately following the above * routine ntp_tick_adjust(). While these two routines are normally * combined, they are separated here only for the purposes of * simulation. */voidsecond_overflow(tvp)#ifdef NTP_NANO	struct timespec *tvp;	/* pointer to nanosecond clock */#else	struct timeval *tvp;	/* pointer to microsecond clock */#endif /* NTP_NANO */{	l_fp ftemp;		/* 32/64-bit temporary */	/*	 * On rollover of the second both the nanosecond and microsecond	 * clocks are updated and the state machine cranked as	 * necessary. The phase adjustment to be used for the next	 * second is calculated and the maximum error is increased by	 * the tolerance.	 */#ifdef NTP_NANO	if (tvp->tv_nsec >= NANOSECOND) {		tvp->tv_nsec -= NANOSECOND;#else	if (tvp->tv_usec >= 1000000) {		tvp->tv_usec -= 1000000;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区二区三区四区 | 日韩一区二区中文字幕| 91精品国产91久久综合桃花| 国产三区在线成人av| 一区二区三区视频在线看| 精品在线播放午夜| 欧美在线观看一二区| 国产女主播一区| 奇米一区二区三区| 在线精品国精品国产尤物884a | 欧美片在线播放| 亚洲天堂成人网| 成人av在线影院| 国产亚洲一二三区| 免费成人在线视频观看| 欧美日韩一本到| 亚洲综合在线电影| eeuss鲁片一区二区三区| 日韩视频中午一区| 亚洲一区二区三区三| 91在线观看污| 国产精品国产三级国产aⅴ中文| 国产在线播放一区三区四| 5858s免费视频成人| 一区二区日韩av| 日韩西西人体444www| 亚洲少妇中出一区| 国产成人午夜精品5599| 欧美一区二区三区白人| 午夜日韩在线观看| 欧美色爱综合网| 亚洲黄色小视频| 日本大香伊一区二区三区| 亚洲天堂av一区| 91福利国产成人精品照片| 最好看的中文字幕久久| www.欧美色图| 中文字幕在线观看一区二区| 97久久精品人人做人人爽| 国产精品久久久久婷婷| 99热这里都是精品| 亚洲摸摸操操av| 欧美图片一区二区三区| 亚洲在线视频免费观看| 欧美精品色一区二区三区| 天天综合天天综合色| 欧美一区二区三区色| 国产综合色视频| 中文字幕亚洲在| 欧美日韩在线一区二区| 日本人妖一区二区| 亚洲精品在线免费观看视频| 国产成人午夜精品影院观看视频 | 欧美日韩一卡二卡三卡| 午夜精品久久久久久久久| 91麻豆精品国产综合久久久久久| 蜜桃av一区二区| 久久久久久久久99精品| 成人av片在线观看| 亚洲自拍偷拍av| 日韩欧美国产午夜精品| 处破女av一区二区| 一区二区三区电影在线播| 337p亚洲精品色噜噜噜| 国产精品白丝av| 亚洲一区二区三区中文字幕在线| 欧美一区二区三区四区五区 | 风间由美中文字幕在线看视频国产欧美| 国产激情视频一区二区在线观看| 国产精品美女久久久久久久久 | 2020国产成人综合网| 成人福利视频网站| 亚洲大尺度视频在线观看| 久久人人超碰精品| 欧美亚洲日本国产| 国产一区久久久| 亚洲最大的成人av| 久久久91精品国产一区二区三区| 在线影院国内精品| 国产精品99久| 麻豆精品一区二区三区| 亚洲欧美成aⅴ人在线观看 | 狠狠色丁香久久婷婷综合丁香| 亚洲日本电影在线| 欧美videossexotv100| 欧美伊人久久大香线蕉综合69| 国产美女精品一区二区三区| 亚洲成人三级小说| 亚洲欧洲日韩在线| 日韩精品中午字幕| 91浏览器入口在线观看| 国产另类ts人妖一区二区| 日韩高清欧美激情| 综合久久给合久久狠狠狠97色| 欧美精品一区二区三区视频| 欧美精品色一区二区三区| 色婷婷综合久久久久中文一区二区| 国产成人综合在线观看| 免费久久99精品国产| 亚洲午夜免费电影| 亚洲人一二三区| 国产欧美日韩精品一区| 欧美大片顶级少妇| 884aa四虎影成人精品一区| 成人毛片在线观看| 国产盗摄精品一区二区三区在线| 日av在线不卡| 视频一区二区三区入口| 亚洲小说欧美激情另类| 亚洲欧美日韩电影| 国产精品久久久99| 国产精品伦一区| 国产精品你懂的| 国产精品理伦片| 中文字幕不卡一区| 国产精品免费视频一区| 国产日韩欧美精品在线| 国产天堂亚洲国产碰碰| 国产色91在线| 成人欧美一区二区三区视频网页| 欧美激情一区二区| 国产区在线观看成人精品| 久久精品人人做人人爽97 | 欧美一区二区高清| 91精品久久久久久久99蜜桃 | 国产一区二区影院| 国产九九视频一区二区三区| 国产高清视频一区| 成人免费电影视频| 91视频一区二区| 欧美色男人天堂| 91精品在线免费观看| 日韩欧美一卡二卡| 久久久噜噜噜久噜久久综合| 国产精品成人午夜| 亚洲黄色小视频| 老司机精品视频一区二区三区| 国产一区久久久| 色综合久久久久综合体| 这里是久久伊人| 欧美激情资源网| 亚洲一区二区三区四区中文字幕 | 亚洲一区二区高清| 日韩电影免费在线| 国内精品伊人久久久久av一坑 | 6080午夜不卡| 国产色婷婷亚洲99精品小说| 亚洲品质自拍视频| 蜜桃av一区二区| 91啪亚洲精品| 日韩午夜av电影| 自拍偷拍亚洲激情| 奇米精品一区二区三区四区 | 国产精品美女久久久久久久| 婷婷国产v国产偷v亚洲高清| 国产精品一二三四| 色香色香欲天天天影视综合网| 欧美一级生活片| 亚洲欧洲一区二区三区| 免费成人美女在线观看.| 成人av片在线观看| 91精品国产麻豆| 日韩毛片精品高清免费| 日本不卡一二三区黄网| 91在线精品秘密一区二区| 日韩三级视频在线看| 一区二区三区久久| 国产精品一级片在线观看| 欧美日韩国产免费| 国产精品美女久久久久久久久| 精品福利一二区| 亚洲靠逼com| 久久99久久99| 欧美日韩你懂的| 一区二区三区成人| 风间由美一区二区三区在线观看 | 国产亚洲美州欧州综合国| 国产精品免费视频网站| 麻豆成人久久精品二区三区红| 99视频精品全部免费在线| 日韩欧美卡一卡二| 亚洲小说欧美激情另类| 99国产精品一区| 国产日韩欧美一区二区三区乱码 | 日韩电影在线免费看| 色哟哟精品一区| 中文字幕一区二区三区在线观看| 精品亚洲成a人| 日韩欧美你懂的| 麻豆国产精品一区二区三区| 欧美电影影音先锋| 亚洲午夜电影网| 欧美日精品一区视频| 亚洲三级电影网站| av不卡在线观看| 国产精品传媒视频| www.久久久久久久久| 中文字幕国产一区| 国产成人av电影在线播放| 精品国产一区二区在线观看|