⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ll-timers.cc

📁 一个很好的LINUX底下的GPRS协议栈
💻 CC
字号:
/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- *//* By Sandeep Kumar, Kopparapu Suman and Richa Jain, * Indian Institute of Technology, Bombay. * June, 2001.*/ /* Copyright (c) 2001 Indian Insitute of Technology, Bombay.   * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *  * 1. Redistributions of source code and binary code must contain * the above copyright notice, this list of conditions and the following  * disclaimer. *  * 2. All advertising materials mentioning features or use of this software * must display the following acknowledgement:  * This product includes software developed at Indian Insitute of * Technology, Bombay.  * * 3. The name of the Institute may not be used to endorse or promote  * products derived from this software without specific prior written  * permission. * INDIAN INSTITUTE OF TECHNOLOGY, BOMBAY, MAKES NO REPRESENTATIONS  * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE  * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software  * is provided "as is" without express or implied warranty of any kind.*/#include <delay.h>#include <connector.h>#include <packet.h>#include <random.h> // #define DEBUG//#include <debug.h>#include <arp.h>#include <ll.h>#include <mac.h>#include <ll-timers.h>/* * Force timers to expire on slottime boundries. */// #define USE_SLOT_TIME#define ROUND_TIME()	\	{								\		assert(slottime);					\		double rmd = remainder(s.clock() + rtime, slottime);	\		if(rmd > 0.0)						\			rtime += (slottime - rmd);			\		else							\			rtime += (-rmd);				\	}/* ======================================================================   Timers   ====================================================================== */voidLLTimer::start(double time){	Scheduler &s = Scheduler::instance();	assert(busy_ == 0);		busy_ = 1;	paused_ = 0;	stime = s.clock();	rtime = time;	assert(rtime >= 0.0);//	fprintf(stderr,"ll timer started\n");	s.schedule(this, &intr, rtime);}voidLLTimer::stop(void){	Scheduler &s = Scheduler::instance();	//	fprintf(stderr,"ll timer stopped\n");	assert(busy_);	if(paused_ == 0)		s.cancel(&intr);	busy_ = 0;	paused_ = 0;	stime = 0.0;	rtime = 0.0;}/* ======================================================================   Send Timer   ====================================================================== */void llTxTimer::handle(Event *){       	busy_ = 0;	paused_ = 0;	stime = 0.0;	rtime = 0.0;	ll->sendHandler();}void llackTimer::handle(Event *){       	busy_ = 0;	paused_ = 0;	stime = 0.0;	rtime = 0.0;	ll->sendackHandler();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -