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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? timer.c

?? uCLinux下的一個(gè)TCP/IP協(xié)議棧源碼
?? C
字號(hào):
/* General purpose software timer facilities
 */
#include <stdio.h>
#include "global.h"
#include "timer.h"
#include "proc.h"
#include "mbuf.h"
#include "commands.h"
#include "daemon.h"
#include "hardware.h"
#include "socket.h"

/* Head of running timer chain.
 * The list of running timers is sorted in increasing order of expiration;
 * i.e., the first timer to expire is always at the head of the list.
 */
static struct timer *Timers;

static void t_alarm(void *x);

/* Process that handles clock ticks */
void
timerproc(i,v1,v2)
int i;
void *v1,*v2;
{
	register struct timer *t;
	register struct timer *expired;
	void (**vf)(void);
	int i_state;
	int tmp;
	int32 clock;

	for(;;){
		/* Atomic read and decrement of Tick */
		for(;;){
			i_state = dirps();
			tmp = Tick;
			if(tmp != 0){
				Tick--;
				restore(i_state);
				break;
			}	
			restore(i_state);
			kwait(&Tick);
		}
		if(!istate()){
			restore(1);
			printf("timer: ints were off!\n");
		}

		/* Call the functions listed in config.c */
		for(vf = Cfunc;*vf != NULL;vf++)
			(*vf)();

		kwait(NULL);	/* Let them all do their writes */

		if(Timers == NULL)
			continue;	/* No active timers, all done */

		/* Initialize null expired timer list */
		expired = NULL;
		clock = rdclock();

		/* Move expired timers to expired list. Note use of
		 * subtraction and comparison to zero rather than the
		 * more obvious simple comparison; this avoids
		 * problems when the clock count wraps around.
		 */
		while(Timers != NULL && (clock - Timers->expiration) >= 0){
			if(Timers->next == Timers){
				printf("PANIC: Timer loop at %lx\n",
				 (long)Timers);
				iostop();
				exit(1);
			}
			/* Save Timers since stop_timer will change it */
			t = Timers;
			stop_timer(t);
			t->state = TIMER_EXPIRE;
			/* Add to expired timer list */
			t->next = expired;
			expired = t;
		}
		/* Now go through the list of expired timers, removing each
		 * one and kicking the notify function, if there is one
		 */
		while((t = expired) != NULL){
			expired = t->next;
			if(t->func){
				(*t->func)(t->arg);
			}
		}
		kwait(NULL);	/* Let them run before handling more ticks */
	}
}
/* Start a timer */
void
start_timer(t)
struct timer *t;
{
	register struct timer *tnext;
	struct timer *tprev = NULL;

	if(t == NULL)
		return;
	if(t->state == TIMER_RUN)
		stop_timer(t);
	if(t->duration == 0)
		return;		/* A duration value of 0 disables the timer */

	t->expiration = rdclock() + t->duration;
	t->state = TIMER_RUN;

	/* Find right place on list for this guy. Once again, note use
	 * of subtraction and comparison with zero rather than direct
	 * comparison of expiration times.
	 */
	for(tnext = Timers;tnext != NULL;tprev=tnext,tnext = tnext->next){
		if((tnext->expiration - t->expiration) >= 0)
			break;
	}
	/* At this point, tprev points to the entry that should go right
	 * before us, and tnext points to the entry just after us. Either or
	 * both may be null.
	 */
	if(tprev == NULL)
		Timers = t;		/* Put at beginning */
	else
		tprev->next = t;

	t->next = tnext;
}
/* Stop a timer */
void
stop_timer(timer)
struct timer *timer;
{
	register struct timer *t;
	struct timer *tlast = NULL;

	if(timer == NULL || timer->state != TIMER_RUN)
		return;

	/* Verify that timer is really on list */
	for(t = Timers;t != NULL;tlast = t,t = t->next)
		if(t == timer)
			break;

	if(t == NULL)
		return;		/* Should probably panic here */

	/* Delete from active timer list */
	if(tlast != NULL)
		tlast->next = t->next;
	else
		Timers = t->next;	/* Was first on list */

	t->state = TIMER_STOP;
}
/* Return milliseconds remaining on this timer */
int32
read_timer(t)
struct timer *t;
{
	int32 remaining;

	if(t == NULL || t->state != TIMER_RUN)
		return 0;
	remaining = t->expiration - rdclock();
	if(remaining <= 0)
		return 0;	/* Already expired */
	else
		return remaining * MSPTICK;
}
void
set_timer(t,interval)
struct timer *t;
int32 interval;
{
	if(t == NULL)
		return;
	/* Round the interval up to the next full tick, and then
	 * add another tick to guarantee that the timeout will not
	 * occur before the interval is up. This is necessary because
	 * we're asynchronous with the system clock.
	 */	
	if(interval != 0)
		t->duration = 1 + (interval + MSPTICK - 1)/MSPTICK;
	else
		t->duration = 0;
}
/* Delay process for specified number of milliseconds.
 * Normally returns 0; returns -1 if aborted by alarm.
 */
int
ppause(ms)
int32 ms;
{
	int val;

	if(Curproc == NULL || ms == 0)
		return 0;
	kalarm(ms);
	/* The actual event doesn't matter, since we'll be alerted */
	while(Curproc->alarm.state == TIMER_RUN){
		if((val = kwait(Curproc)) != 0)
			break;
	}
	kalarm(0L); /* Make sure it's stopped, in case we were killed */	
	return (val == EALARM) ? 0 : -1;
}
static void
t_alarm(x)
void *x;
{
	alert((struct proc *)x,EALARM);
}
/* Send signal to current process after specified number of milliseconds */
void
kalarm(ms)
int32 ms;
{
	if(Curproc != NULL){
		set_timer(&Curproc->alarm,ms);
		Curproc->alarm.func = t_alarm;
		Curproc->alarm.arg = (char *)Curproc;
		start_timer(&Curproc->alarm);
	}
}
/* Convert time count in seconds to printable days:hr:min:sec format */
char *
tformat(t)
int32 t;
{
	static char buf[17],*cp;
	unsigned int days,hrs,mins,secs;
	int minus;

	if(t < 0){
		t = -t;
		minus = 1;
	} else
		minus = 0;

	secs = t % 60;
	t /= 60;
	mins = t % 60;
	t /= 60;
	hrs = t % 24;
	t /= 24;
	days = t;
	if(minus){
		cp = buf+1;
		buf[0] = '-';
	} else
		cp = buf;
	sprintf(cp,"%u:%02u:%02u:%02u",days,hrs,mins,secs);
	
	return buf;
}
	

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产三级国产aⅴ入口| 亚洲香蕉伊在人在线观| 欧美亚洲综合另类| 极品少妇xxxx精品少妇偷拍| 一区二区三区在线视频播放| 久久综合国产精品| 欧美日韩在线一区二区| 成人深夜在线观看| 美女www一区二区| 亚洲一区二区综合| 中文字幕中文字幕一区| 久久精品一二三| 91精品国模一区二区三区| 色综合夜色一区| 岛国av在线一区| 国产老肥熟一区二区三区| 蜜桃视频在线观看一区二区| 亚洲成人激情综合网| 亚洲精品菠萝久久久久久久| 欧美国产欧美亚州国产日韩mv天天看完整 | 日韩成人精品在线| 伊人性伊人情综合网| 国产欧美一区二区精品秋霞影院| 日韩欧美激情一区| 日韩午夜激情视频| 欧美日韩电影一区| 欧美巨大另类极品videosbest | 亚洲蜜臀av乱码久久精品蜜桃| 久久婷婷国产综合精品青草| 91精品国产品国语在线不卡| 欧美在线短视频| 欧美综合一区二区| 精品视频在线看| 欧美精品亚洲二区| 在线电影欧美成精品| 欧美日韩一区久久| 欧美日韩一级片在线观看| 欧美色手机在线观看| 欧美在线视频全部完| 欧美亚洲一区二区三区四区| 色88888久久久久久影院野外| 91麻豆视频网站| 在线亚洲+欧美+日本专区| 欧美日韩中字一区| 欧美一级搡bbbb搡bbbb| 精品国产污污免费网站入口 | 日韩成人免费看| 免费一级欧美片在线观看| 免费人成在线不卡| 麻豆精品视频在线观看免费| 国产一区激情在线| 成人a免费在线看| 色婷婷久久久久swag精品 | 国产精品―色哟哟| 中文字幕亚洲一区二区av在线| 亚洲欧洲一区二区在线播放| 一色桃子久久精品亚洲| 亚洲一区影音先锋| 免费xxxx性欧美18vr| 国产精品中文字幕日韩精品| 成人av在线看| 欧美性淫爽ww久久久久无| 欧美日韩dvd在线观看| 精品国产1区二区| 国产精品萝li| 亚洲超碰97人人做人人爱| 美女在线视频一区| 成人网男人的天堂| 欧美日韩精品系列| 久久久精品天堂| 亚洲四区在线观看| 秋霞午夜av一区二区三区| 国产福利91精品| 在线观看免费视频综合| 欧美精品一区二区三区四区| 亚洲天堂中文字幕| 蜜臀av性久久久久av蜜臀妖精| 国产伦精一区二区三区| 欧美性三三影院| 久久久国产精品不卡| 亚洲午夜免费视频| 国产福利精品一区| 欧美一区国产二区| 国产精品素人视频| 日本aⅴ免费视频一区二区三区 | 午夜电影一区二区| 成人午夜视频福利| 日韩亚洲欧美在线| 亚洲人成小说网站色在线| 久久国产精品免费| 在线观看91精品国产入口| 久久久99久久| 视频一区二区国产| 91麻豆福利精品推荐| 欧美成人午夜电影| 亚洲va欧美va天堂v国产综合| 丁香激情综合五月| 精品国产一区二区三区不卡| 一区二区三区日韩在线观看| 国产经典欧美精品| 日韩欧美成人激情| 亚洲国产婷婷综合在线精品| 成人一区二区三区视频| 日韩视频永久免费| 亚洲成在人线免费| 91在线观看美女| 亚洲国产成人私人影院tom| 免费欧美日韩国产三级电影| 91久久人澡人人添人人爽欧美| 国产日韩欧美制服另类| 蜜臀av性久久久久蜜臀aⅴ流畅| 在线观看三级视频欧美| 亚洲欧美日韩中文播放 | 日韩一级片在线播放| 亚洲国产精品一区二区久久 | 91玉足脚交白嫩脚丫在线播放| 久久婷婷国产综合国色天香 | 99精品欧美一区| 国产午夜精品久久久久久免费视| 经典三级视频一区| 精品久久久久久久久久久院品网| 日韩精品午夜视频| 欧美精品乱人伦久久久久久| 亚洲综合视频在线| 在线观看日韩电影| 亚洲一区中文在线| 欧美综合天天夜夜久久| 一区二区三区91| 在线免费精品视频| 一区二区三区免费| 欧美男生操女生| 奇米四色…亚洲| 精品国产免费久久| 国内精品在线播放| 国产亚洲视频系列| 国产白丝精品91爽爽久久| 国产欧美日韩亚州综合| 粉嫩av亚洲一区二区图片| 中文字幕亚洲一区二区av在线| 日韩一区二区三区视频| 久久国产夜色精品鲁鲁99| 国产午夜亚洲精品午夜鲁丝片| 国模少妇一区二区三区| 国产日韩欧美不卡| 不卡视频在线观看| 一区二区三区在线看| 欧美精品视频www在线观看| 美女脱光内衣内裤视频久久影院| 日韩精品一区二区三区视频在线观看| 精品制服美女久久| 国产欧美综合在线观看第十页| av资源网一区| 亚洲午夜精品网| 精品久久国产字幕高潮| 国产精品99久久久久久似苏梦涵| 国产精品久久久久久久久久免费看 | 亚洲午夜成aⅴ人片| 日韩一区二区三区av| 国产91精品在线观看| 成人欧美一区二区三区在线播放| 欧美亚州韩日在线看免费版国语版 | 一区二区欧美在线观看| 欧美一区二区三区婷婷月色| 国产精品原创巨作av| 17c精品麻豆一区二区免费| 欧美日韩大陆在线| 粉嫩绯色av一区二区在线观看 | 亚洲同性同志一二三专区| 欧美日韩国产免费一区二区 | 国产日韩欧美精品在线| 91日韩一区二区三区| 麻豆国产欧美日韩综合精品二区| 国产欧美一区二区精品秋霞影院| 欧美亚洲免费在线一区| 黄色小说综合网站| 亚洲另类中文字| 久久精品夜色噜噜亚洲a∨| 欧美性猛交xxxx乱大交退制版| 国产一区二区三区观看| 亚洲一卡二卡三卡四卡无卡久久 | 精品国产电影一区二区| 99国内精品久久| 麻豆专区一区二区三区四区五区| 国产精品伦理在线| 日韩免费一区二区| 91丨porny丨国产| 韩国女主播成人在线观看| 一个色在线综合| 国产午夜精品福利| 欧美一区二区播放| 91片黄在线观看| 国产福利精品一区| 麻豆精品蜜桃视频网站| 依依成人综合视频| 国产精品久久久久一区二区三区共| 欧美精品丝袜中出| 色欧美片视频在线观看在线视频| 国产一区二区三区久久悠悠色av| 亚洲成a人v欧美综合天堂| 国产精品欧美综合在线|