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

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

?? timer.c

?? 網(wǎng)友張巍提供的tcpip協(xié)議棧,是一個(gè)成功穩(wěn)定的以太網(wǎng)接口上的TCP/IP協(xié)議程序。里面包括有說明
?? C
字號:
/* 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;
}
	

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品一区二区三区四区| 在线成人小视频| 日韩av电影天堂| 国产精品乱码久久久久久| 在线不卡中文字幕| 99久久精品国产一区二区三区| 日本欧美一区二区| 一区二区成人在线视频| 国产亚洲欧洲997久久综合 | 美女网站视频久久| 伊人一区二区三区| 国产欧美日韩综合| 精品乱人伦小说| 欧美久久一区二区| 91麻豆国产自产在线观看| 国产成人午夜99999| 蜜臀av在线播放一区二区三区| 一区二区在线观看不卡| 亚洲国产精品ⅴa在线观看| 精品国精品国产尤物美女| 欧美日韩1234| 91黄色小视频| 色av综合在线| 91蜜桃网址入口| 成人aaaa免费全部观看| 高清在线观看日韩| 国产.精品.日韩.另类.中文.在线.播放| 麻豆精品久久精品色综合| 亚洲成人av一区二区三区| 亚洲色图20p| 亚洲乱码国产乱码精品精98午夜| 国产精品美女久久久久久久久 | 欧美日韩dvd在线观看| 91福利精品视频| 色综合色综合色综合色综合色综合| 国产精品原创巨作av| 国内精品第一页| 国产乱码精品一区二区三区忘忧草| 国内久久精品视频| 国产另类ts人妖一区二区| 狠狠色丁香婷婷综合| 老色鬼精品视频在线观看播放| 青青草97国产精品免费观看无弹窗版| 亚洲成av人综合在线观看| 香蕉成人伊视频在线观看| 日韩电影在线免费| 老司机精品视频线观看86| 久久er99热精品一区二区| 激情五月婷婷综合| 国产剧情av麻豆香蕉精品| 国产白丝网站精品污在线入口| 国产不卡视频一区| 色综合天天综合网国产成人综合天 | 亚洲国产va精品久久久不卡综合| 一区二区三区日本| 日韩中文字幕1| 精品一区二区av| 国产99久久久国产精品| 成人午夜免费电影| 91福利视频在线| 日韩欧美激情四射| 国产欧美一区二区三区在线老狼| 18欧美亚洲精品| 视频一区二区中文字幕| 精品一区中文字幕| 99久久国产综合精品麻豆| 欧美日韩久久不卡| 久久久久久亚洲综合影院红桃| 国产精品国产三级国产普通话三级 | 麻豆国产精品视频| 成人av资源站| 欧美日韩日日夜夜| 久久婷婷色综合| 一区二区三区在线免费播放| 日韩高清欧美激情| 成人丝袜视频网| 欧美日韩免费不卡视频一区二区三区| 精品福利一区二区三区免费视频| 中文字幕在线一区免费| 午夜在线电影亚洲一区| 国产精品一二三区| 欧美色国产精品| 久久精品视频网| 亚洲福利一区二区| 成人免费看的视频| 欧美一区二区人人喊爽| 中文字幕一区av| 奇米色一区二区| 色哟哟国产精品免费观看| 久久综合久久综合久久综合| 亚洲精品成a人| 国产乱理伦片在线观看夜一区| 在线观看一区二区精品视频| 久久午夜老司机| 日韩和的一区二区| 91女人视频在线观看| 久久久久久久性| 日日欢夜夜爽一区| 91黄视频在线| 国产精品久久久久久妇女6080| 免费不卡在线视频| 欧美最猛黑人xxxxx猛交| 中文字幕免费不卡| 国产中文一区二区三区| 在线成人免费视频| 一区二区三区色| 97精品视频在线观看自产线路二| 久久综合精品国产一区二区三区| 亚洲成人1区2区| 91蝌蚪porny九色| 国产三级一区二区三区| 美腿丝袜亚洲三区| 欧美精品久久一区| 亚洲不卡av一区二区三区| av午夜一区麻豆| 国产精品三级在线观看| 国产一区欧美日韩| 欧美不卡一区二区三区四区| 亚洲大型综合色站| 欧美做爰猛烈大尺度电影无法无天| 国产精品美女久久久久久久久久久| 国产一区二区三区在线观看免费 | 亚洲一线二线三线视频| 不卡视频免费播放| 亚洲国产精华液网站w| 国产一区二区电影| 久久久蜜桃精品| 美女www一区二区| 日韩亚洲欧美在线| 日韩av二区在线播放| 777亚洲妇女| 喷白浆一区二区| 日韩欧美另类在线| 久久99精品国产.久久久久| 日韩一级欧美一级| 美国精品在线观看| 欧美va亚洲va香蕉在线| 紧缚捆绑精品一区二区| 日韩精品一区二区三区视频 | 国产盗摄视频一区二区三区| 精品国产一区二区三区忘忧草| 麻豆精品一区二区三区| 精品国产免费一区二区三区四区 | 在线观看国产91| 亚洲午夜激情网页| 8v天堂国产在线一区二区| 日本va欧美va精品| 欧美成人性战久久| 高清在线不卡av| 亚洲欧美日韩中文播放| 在线日韩国产精品| 日韩在线一区二区| 精品日韩一区二区三区| 国产精品一区二区不卡| 中文字幕中文乱码欧美一区二区| 91视频精品在这里| 亚洲国产成人tv| 日韩午夜在线观看视频| 国内成+人亚洲+欧美+综合在线| 久久精品亚洲精品国产欧美| 91网站最新网址| 婷婷综合五月天| 久久久午夜电影| 一本一本大道香蕉久在线精品| 天天综合网天天综合色| 久久久久久久久99精品| 国产精品1区2区| 亚洲自拍另类综合| 精品精品欲导航| 一本一本久久a久久精品综合麻豆| 同产精品九九九| 国产区在线观看成人精品| 日本高清视频一区二区| 日韩主播视频在线| 欧美经典一区二区三区| 欧美在线不卡视频| 国内精品伊人久久久久影院对白| 亚洲欧美综合另类在线卡通| 欧美日韩免费在线视频| 国产在线精品一区二区| 一区二区高清视频在线观看| 26uuu亚洲综合色欧美| 色吧成人激情小说| 国产毛片精品视频| 亚洲一区二区免费视频| 国产午夜精品一区二区| 欧美色视频在线观看| av福利精品导航| 亚洲日穴在线视频| 91麻豆国产福利在线观看| 久久黄色级2电影| 一区二区免费在线| 亚洲国产精华液网站w| 日韩一区二区在线播放| 成人精品免费看| 美女免费视频一区二区| 亚洲一区二区视频| 国产精品美女一区二区在线观看| 欧美不卡123| 欧美理论片在线|