?? ll-timers.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 + -