/*1* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 20092* The President and Fellows of Harvard College.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of the University nor the names of its contributors13* may be used to endorse or promote products derived from this software14* without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _CLOCK_H_30#define _CLOCK_H_3132#include "opt-synchprobs.h"3334/*35* Time-related definitions.36*37* hardclock() is called on every CPU HZ times a second, possibly only38* when the CPU is not idle, for scheduling.39*40* timerclock() is called on one CPU once a second to allow simple41* timed operations. (This is a fairly simpleminded interface.)42*43* gettime() may be used to fetch the current time of day.44* getinterval() computes the time from time1 to time2.45*46* XXX we have struct timespec now, let's use it.47*/4849/* hardclocks per second */50#if OPT_SYNCHPROBS51/* Make synchronization more exciting :) */52#define HZ 1000053#else54/* More realistic value */55#define HZ 10056#endif5758void hardclock_bootstrap(void);5960void hardclock(void);61void timerclock(void);6263void gettime(time_t *seconds, uint32_t *nanoseconds);6465void getinterval(time_t secs1, uint32_t nsecs,66time_t secs2, uint32_t nsecs2,67time_t *rsecs, uint32_t *rnsecs);6869/*70* clocksleep() suspends execution for the requested number of seconds,71* like userlevel sleep(3). (Don't confuse it with wchan_sleep.)72*/73void clocksleep(int seconds);747576#endif /* _CLOCK_H_ */777879