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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? nt_clockstuff.c

?? Network time protocol source study
?? C
字號(hào):
/* Windows NT Clock Routines * * * Revision History: * $Log$ * Revision 1.9  2000/11/19 09:02:12  dietrich * From: Ron Thornton [rthornto@pictel.com] * Sent: Thu 11/16/00 8:51 AM * On Windows 2000 it requires a privilege on the current process token * that is disabled by default on Windows 2000. * * I set the token by adding the following code at the beginning of the * init_winnt_time() function in nt_clockstuff.c. * * Revision 1.8  2000/11/19 08:03:20  dietrich * From: "Colin Dancer" <colin.dancer@pyrochrome.net> * To: <bugs@ntp.org> * Sent: 10 November 2000 12:59 * Subject: NT bug in NTP 4.0.99j * * I've found a bug in (and produced a fix for) the NT clock interpolation * code in NTP 4.0.99j. * * The symptoms of the problem are that gettimeofday() function on NT * can be wrong by hundreds of seconds if, while a gettimeofday() call * is being processed, an APC completes after the query of the performance * counter but before the lock is grabbed.  The most obvious fix is to move * the lock to include the querying of the performance counter, but this * could affect the predictability of the timestamp so I have instead * tweaked the code to detect and sidestep the duff calculation. * * I've also found that on a loaded system the execution of the APC can be * delayed, leading to errors of upto 10ms.  There is no easy fix to this, * but I do have code for an alternative interpolation scheme which avoids * the problem on single processor systems. I'm currently integrating this * along with code for deciding which algorithm to use based on whether * the system is SP or MP. * * Created by Sven Dietrich  sven@inter-yacht.com * */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include "ntp_stdlib.h"#include "clockstuff.h"#include "ntp_timer.h"extern double sys_residual;	/* residual from previous adjustment */static long last_Adj = 0;static CRITICAL_SECTION TimerCritialSection; /* lock for LastTimerCount & LastTimerTime */static ULONGLONG RollOverCount = 0;static ULONGLONG LastTimerCount = 0;static ULONGLONG LastTimerTime = 0;static HANDLE ClockThreadHandle = NULL;static HANDLE TimerThreadExitRequest = NULL;static DWORD every = 0;static DWORD initial_units_per_tick = 0;static DWORD lastLowTimer = 0;ULONGLONG PerfFrequency = 0;static DWORD units_per_tick = 0;static DOUBLE ppm_per_adjust_unit = 0.0;/* * adj_systime - called once every second to make system time adjustments. * Returns 1 if okay, 0 if trouble. */intadj_systime(	double now	){	double dtemp;	u_char isneg = 0;	int rc;   long dwTimeAdjustment;	/*	 * Add the residual from the previous adjustment to the new	 * adjustment, bound and round.	 */	dtemp = sys_residual + now;	sys_residual = 0;	if (dtemp < 0) {		isneg = 1;		dtemp = -dtemp;	}	if (dtemp > NTP_MAXFREQ)		dtemp = NTP_MAXFREQ;	dtemp = dtemp * 1e6;	if (isneg)		dtemp = -dtemp;	/* dtemp is in micro seconds. NT uses 100 ns units,	 * so a unit change in dwTimeAdjustment corresponds	 * to slewing 10 ppm on a 100 Hz system.	 * Calculate the number of 100ns units to add,	 * using OS tick frequency as per suggestion from Harry Pyle,	 * and leave the remainder in dtemp */	dwTimeAdjustment = (DWORD)( dtemp / ppm_per_adjust_unit + (isneg ? -0.5 : 0.5)) ;	dtemp += (double) -dwTimeAdjustment * ppm_per_adjust_unit;		/* only adjust the clock if adjustment changes */	if (last_Adj != dwTimeAdjustment) { 				last_Adj = dwTimeAdjustment;# ifdef DEBUG		if (debug > 1)			printf("SetSystemTimeAdjustment( %ld) + (%ld)\n", dwTimeAdjustment, units_per_tick);			# endif			dwTimeAdjustment += units_per_tick;			rc = !SetSystemTimeAdjustment(dwTimeAdjustment, FALSE);	}	else rc = 0;	if (rc)	{		msyslog(LOG_ERR, "Can't adjust time: %m");		return 0;	}	else {		sys_residual = dtemp / 1000000.0;	}#ifdef DEBUG	if (debug > 6)		printf("adj_systime: adj %.9f -> remaining residual %.9f\n", now, sys_residual);#endif	return 1;}void init_winnt_time(void) {	BOOL noslew;	HANDLE hToken;	TOKEN_PRIVILEGES tkp;	/*	 * Get privileges needed for fiddling with the clock	  */	  /* get the current process token handle */	if (!OpenProcessToken(GetCurrentProcess(),	  TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {		  msyslog(LOG_ERR, "OpenProcessToken failed: %m");		  exit(-1);		  }	  /* get the LUID for system-time privilege. */	LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);	tkp.PrivilegeCount = 1;  /* one privilege to set */	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;	/* get set-time privilege for this process. */	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,	 	(PTOKEN_PRIVILEGES) NULL, 0);	/* cannot use return value of AdjustTokenPrivileges. */	/* (success does not indicate all privileges were set) */	if (GetLastError() != ERROR_SUCCESS) 		{	  	msyslog(LOG_ERR, "AdjustTokenPrivileges failed: %m");	 	/* later set time call will probably fail */	  	}	/* Reset the Clock to a reasonable increment */	if (!GetSystemTimeAdjustment(&initial_units_per_tick, &every,&noslew))		{		msyslog(LOG_ERR, "GetSystemTimeAdjustment failed: %m\n");		exit (-1);		}	units_per_tick = initial_units_per_tick;	/* Calculate the time adjustment resulting from incrementing	 * units per tick by 1 unit for 1 second */	ppm_per_adjust_unit = 1000000.0 / (double) every;#ifdef DEBUG	msyslog(LOG_INFO, "Initial Clock increment %7.1f us",			(float) (units_per_tick / 10));	msyslog(LOG_INFO, "Adjustment rate %5.3f ppm/s", ppm_per_adjust_unit);#endif}void reset_winnt_time(void) {	/* restore the clock frequency back to its original value */	if (!SetSystemTimeAdjustment(initial_units_per_tick, FALSE)) {		msyslog(LOG_ERR, "Failed to reset clock frequency, SetSystemTimeAdjustment(): %m");	}	if (!SetSystemTimeAdjustment(0, TRUE)) {		msyslog(LOG_ERR, "Failed to reset clock state, SetSystemTimeAdjustment(): %m");	}}intgettimeofday(	struct timeval *tv	){	/*  Use the system time (roughly synchronised to the tick, and	 *  extrapolated using the system performance counter.	 */	ULONGLONG Count;	LARGE_INTEGER LargeIntNowCount;	ULONGLONG Time;	ULONGLONG NowCount;   ULONGLONG PreCount;                                                  /*FIX*/	LONGLONG TicksElapsed;	LONG time_adjustment;	/*  Mark a mark ASAP. The latency to here should	 *  be reasonably deterministic	 */   PreCount = LastTimerCount;                                           /*FIX*/	if (!QueryPerformanceCounter(&LargeIntNowCount)) {		msyslog(LOG_ERR, "QueryPeformanceCounter failed: %m");		exit(1);	}	NowCount = LargeIntNowCount.QuadPart;	/*  Get base time we are going to extrapolate from	 */		EnterCriticalSection(&TimerCritialSection);		Count = LastTimerCount;		Time = LastTimerTime;	LeaveCriticalSection(&TimerCritialSection);	/*  Calculate when now is.	 *	 *  Result = LastTimerTime +  (NowCount - LastTimerCount) / PerfFrequency	 */	if (NowCount >= Count)   {	    TicksElapsed = NowCount - Count; /* linear progression of ticks */   }	else   {     /************************************************************************/     /* Differentiate between real rollover and the case of taking a         */     /* perfcount then the APC coming in.                                    */     /************************************************************************/     if (Count > PreCount)                                              /*FIX*/     {                                                                  /*FIX*/       TicksElapsed = 0;                                                /*FIX*/     }                                                                  /*FIX*/     else                                                               /*FIX*/     {                                                                  /*FIX*/       TicksElapsed = NowCount + (RollOverCount - Count);               /*FIX*/     }                                                                  /*FIX*/   }	/*  Calculate the new time (in 100's of nano-seconds)	 */    time_adjustment = (long) ((TicksElapsed * HECTONANOSECONDS) / PerfFrequency);	Time += time_adjustment;	/* Convert the hecto-nano second time to tv format	 */	Time -= FILETIME_1970;	tv->tv_sec = (LONG) ( Time / 10000000ui64);	tv->tv_usec = (LONG) (( Time % 10000000ui64) / 10);	return 0;}static void CALLBACKTimerApcFunction(	LPVOID lpArgToCompletionRoutine,	DWORD dwTimerLowValue,	DWORD dwTimerHighValue	){	LARGE_INTEGER LargeIntNowCount;	(void) lpArgToCompletionRoutine; /* not used */	if (dwTimerLowValue == lastLowTimer) return;		/* Grab the counter first of all */	QueryPerformanceCounter(&LargeIntNowCount);	/* Save this for next time */	lastLowTimer = dwTimerLowValue;	/* Check to see if the counter has rolled. This happens	   more often on Multi-CPU systems */	if ((ULONGLONG) LargeIntNowCount.QuadPart < LastTimerCount) {		/* Counter Rolled - try and estimate the rollover point using		  the nominal counter frequency divided by an estimate of the		  OS frequency */		RollOverCount = LastTimerCount + PerfFrequency * every /  HECTONANOSECONDS -			(ULONGLONG) LargeIntNowCount.QuadPart;#ifdef DEBUG		msyslog(LOG_INFO,			"Performance Counter Rollover %I64u:\rLast Timer Count %I64u\rCurrent Count %I64u",				RollOverCount, LastTimerCount, LargeIntNowCount.QuadPart);#endif	}	/* Now we can hang out and wait for the critical section to free up;	   we will get the CPU this timeslice. Meanwhile other tasks can use	   the last value of LastTimerCount */			EnterCriticalSection(&TimerCritialSection);	LastTimerCount = (ULONGLONG) LargeIntNowCount.QuadPart;	LastTimerTime = ((ULONGLONG) dwTimerHighValue << 32) +				(ULONGLONG) dwTimerLowValue;	LeaveCriticalSection(&TimerCritialSection);}DWORD WINAPI ClockThread(void *arg){	LARGE_INTEGER DueTime;	HANDLE WaitableTimerHandle = CreateWaitableTimer(NULL, FALSE, NULL);	(void) arg; /* not used */	if (WaitableTimerHandle != NULL) {		DueTime.QuadPart = 0i64;		if (SetWaitableTimer(WaitableTimerHandle, &DueTime, 1L /* ms */, TimerApcFunction, &WaitableTimerHandle, FALSE) != NO_ERROR) {			for(;;) {				if (WaitForSingleObjectEx(TimerThreadExitRequest, INFINITE, TRUE) == WAIT_OBJECT_0) {					break; /* we've been asked to exit */				}			}		}		CloseHandle(WaitableTimerHandle);		WaitableTimerHandle = NULL;	}	return 0;}static void StartClockThread(void){	DWORD tid;	FILETIME StartTime;	LARGE_INTEGER Freq = { 0, 0 };		/* get the performance counter freq*/    if (!QueryPerformanceFrequency(&Freq)) {		msyslog(LOG_ERR, "QueryPerformanceFrequency failed: %m\n");		exit (-1);	}	PerfFrequency = Freq.QuadPart;	/* init variables with the time now */	GetSystemTimeAsFileTime(&StartTime);	LastTimerTime = (((ULONGLONG) StartTime.dwHighDateTime) << 32) +		(ULONGLONG) StartTime.dwLowDateTime;	/* init sync objects */	InitializeCriticalSection(&TimerCritialSection);	TimerThreadExitRequest = CreateEvent(NULL, FALSE, FALSE, NULL);	ClockThreadHandle = CreateThread(NULL, 0, ClockThread, NULL, 0, &tid);	if (ClockThreadHandle != NULL) {		/* remember the thread priority is only within the process class */		  if (!SetThreadPriority(ClockThreadHandle, THREAD_PRIORITY_TIME_CRITICAL)) {#ifdef DEBUG			printf("Error setting thread priority\n");#endif		  }	}}static void StopClockThread(void){		if (SetEvent(TimerThreadExitRequest) &&	    WaitForSingleObject(ClockThreadHandle, 10000L) == 0) {		CloseHandle(TimerThreadExitRequest);		TimerThreadExitRequest = NULL;		CloseHandle(ClockThreadHandle);		ClockThreadHandle = NULL;		DeleteCriticalSection(&TimerCritialSection);		msyslog(LOG_INFO, "The Network Time Protocol Service has stopped.");	}	else		msyslog(LOG_ERR, "Network Time Protocol Service Failed to Stop");}typedef void (__cdecl *CRuntimeFunction)(void);#pragma data_seg(".CRT$XIY")	CRuntimeFunction _StartClockThread = StartClockThread;#pragma data_seg(".CRT$XTY")	CRuntimeFunction _StopClockThread = StopClockThread;#pragma data_seg()  /* reset */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区欧美亚洲| 91猫先生在线| 国产一区二区福利视频| 日韩福利电影在线观看| 五月激情六月综合| 日韩电影在线一区二区| 肉丝袜脚交视频一区二区| 天天综合网天天综合色| 男男成人高潮片免费网站| 免费欧美高清视频| 国产综合久久久久影院| 国产精品69毛片高清亚洲| 成人免费观看男女羞羞视频| 成人综合在线观看| 99在线精品免费| 欧美少妇xxx| 91精品国产入口在线| 欧美电视剧在线看免费| 久久久国产精品麻豆| 国产精品久久久久久久裸模| 亚洲欧美另类在线| 亚洲成av人片在线| 久久99国内精品| 国产一区二区福利| 99国产精品久| 欧美色图12p| 欧美精品一区二区三区在线 | 欧美疯狂性受xxxxx喷水图片| 欧美疯狂性受xxxxx喷水图片| 日韩欧美一级二级| 国产日韩精品视频一区| 日韩一区日韩二区| 午夜欧美大尺度福利影院在线看 | 欧美色大人视频| 日韩精品专区在线影院重磅| 欧美国产日产图区| 亚洲va天堂va国产va久| 激情小说亚洲一区| 91色九色蝌蚪| 91精品国产综合久久久久久漫画 | 欧美激情自拍偷拍| 亚洲国产中文字幕在线视频综合| 青青草原综合久久大伊人精品| 国产.精品.日韩.另类.中文.在线.播放| 99久久国产免费看| 欧美一三区三区四区免费在线看 | 日韩精品中文字幕在线不卡尤物| 欧美国产日产图区| 性做久久久久久免费观看| 国产一区亚洲一区| 欧美日韩视频在线第一区 | 日韩天堂在线观看| 国产精品亲子伦对白| 亚洲成人精品一区二区| 国产精品18久久久久久久久| 日本电影欧美片| 久久久精品影视| 同产精品九九九| 国产盗摄精品一区二区三区在线| 在线免费观看日本欧美| 国产亚洲1区2区3区| 亚洲国产欧美一区二区三区丁香婷| 国产电影精品久久禁18| 777亚洲妇女| 亚洲色图丝袜美腿| 国产一区二区三区久久悠悠色av| 欧美亚洲图片小说| 国产精品女人毛片| 国内精品嫩模私拍在线| 欧美色男人天堂| 亚洲日本乱码在线观看| 国产一区二区在线电影| 欧美久久免费观看| 亚洲欧美日韩国产中文在线| 国产精品夜夜嗨| 日韩欧美在线不卡| 亚洲成人免费电影| 一本到不卡免费一区二区| 国产欧美日韩精品在线| 青青草97国产精品免费观看无弹窗版| 色94色欧美sute亚洲13| 国产精品每日更新| 国产精品一区二区久久精品爱涩| 正在播放一区二区| 五月激情综合婷婷| 欧美日韩在线播放三区| 亚洲精品精品亚洲| av电影在线观看不卡| 久久伊人中文字幕| 久久99精品久久久久婷婷| 51精品久久久久久久蜜臀| 亚洲综合激情小说| 在线观看视频一区二区欧美日韩| 中文字幕一区二区三区视频| 国产精品小仙女| 国产亚洲精久久久久久| 国产自产视频一区二区三区| 精品入口麻豆88视频| 美腿丝袜亚洲一区| 日韩欧美一区电影| 久久精品国产第一区二区三区| 日韩欧美亚洲另类制服综合在线| 人人爽香蕉精品| 日韩欧美一区二区三区在线| 久久99精品久久久久| 精品91自产拍在线观看一区| 精品一区二区三区免费播放| 日韩视频一区在线观看| 美国精品在线观看| 日韩精品中文字幕一区二区三区| 麻豆精品久久精品色综合| 精品国产自在久精品国产| 九九久久精品视频| 亚洲精品一区二区三区精华液| 国产精品一线二线三线| 国产日韩欧美制服另类| 成人精品在线视频观看| 中文字幕在线视频一区| 91美女在线视频| 亚洲国产精品综合小说图片区| 欧美日韩国产综合一区二区| 日韩电影在线一区二区三区| 精品久久久网站| www.爱久久.com| 一区二区三区不卡视频| 91精品免费在线观看| 精品一区二区三区的国产在线播放 | 欧美在线观看一区| 日韩一区欧美二区| 精品女同一区二区| 风间由美一区二区三区在线观看| 亚洲免费视频成人| 7777精品伊人久久久大香线蕉的| 久久er精品视频| 成人免费在线观看入口| 8v天堂国产在线一区二区| 极品美女销魂一区二区三区免费| 久久午夜免费电影| 在线影院国内精品| 蜜臀av一区二区三区| 国产精品麻豆一区二区| 欧美色综合久久| 国产一区欧美日韩| 亚洲精品乱码久久久久久日本蜜臀| 在线不卡免费av| 粉嫩一区二区三区在线看| 亚洲一区二区三区中文字幕| 欧美成人综合网站| 91色九色蝌蚪| 极品少妇xxxx偷拍精品少妇| 亚洲伦在线观看| 精品国产一区二区亚洲人成毛片| av高清久久久| 久久99精品久久只有精品| 日韩一区中文字幕| 精品久久久三级丝袜| 91成人国产精品| 国产精品一二三四区| 亚洲成a人片综合在线| 国产蜜臀av在线一区二区三区| 欧美日韩一区三区四区| 国产91精品一区二区麻豆网站| 亚洲小说欧美激情另类| 久久精品亚洲麻豆av一区二区| 欧美视频在线一区| 成人一级片网址| 99在线热播精品免费| 日韩国产一二三区| 亚洲欧洲99久久| 26uuu亚洲综合色| 欧美日韩另类国产亚洲欧美一级| 从欧美一区二区三区| 久久精品国产77777蜜臀| 亚洲在线观看免费视频| 欧美国产精品一区二区| 日韩视频一区二区三区| 在线免费观看成人短视频| 高清beeg欧美| 国内精品嫩模私拍在线| 日韩电影免费一区| 一区二区久久久久| 国产精品久久久久影视| 精品国产凹凸成av人导航| 欧美高清性hdvideosex| 色久综合一二码| 成人看片黄a免费看在线| 国内精品久久久久影院色| 视频一区视频二区中文| 一区二区三区四区av| 国产精品乱码一区二三区小蝌蚪| 日韩亚洲欧美一区| 8v天堂国产在线一区二区| 欧美午夜精品久久久久久孕妇| www.欧美日韩| av在线播放成人| 成人激情综合网站| 丁香天五香天堂综合| 国内精品免费**视频| 国产资源精品在线观看| 久久 天天综合|