summaryrefslogtreecommitdiff
path: root/sys/kern/kern_clock.c
AgeCommit message (Collapse)Author
2006-01-03Make #undef match its temporary #define.Miod Vallat
2005-11-28ansi/deregister.Jonathan Gray
'go for it' deraadt@
2005-10-25dont' -> don't in comments;Jason McIntyre
from ray lai;
2005-10-03In hardclock(), do not setup process virtual and profile timers if the processAaron Campbell
is in the midst of exiting. This solves a race condition that causes freed memory to be left referenced in the master kernel timeout worklist, leading to a uvm_fault (observed on an i386 MP system). tedu@, deraadt@, miod@ ok
2004-11-10Diff from art@:Alexander Yurchenko
Update ticks in timeout_hardclock_update to avoid errors in hardclock (this is the third time we mess up here). ticks is only used for timeouts anyway. At the same protect updating ticks with timeout_mutex and be slightly more paranoid in timeout_hardclock_update. ok tdeval@ miod@
2004-09-15Typo in #endif comment.Alexander Yurchenko
2004-08-05Fix typos. Found by Dries SchellekensArtur Grabowski
2004-08-04hardclock detects if ITIMER_VIRTUAL and ITIMER_PROF have expired andArtur Grabowski
sends SIGVTALRM and SIGPROF to the process if they had. There is a big problem with calling psignal from hardclock on MULTIPROCESSOR machines though. It means we need to protect all signal state in the process with a lock because hardclock doesn't obtain KERNEL_LOCK. Trying to track down all the tentacles of this quickly becomes very messy. What saves us at the moment is that SCHED_LOCK (which is used to protect parts of the signal state, but not all) happens to be recursive and forgives small and big errors. That's about to change. So instead of trying to hunt down all the locking problems here, just make hardclock not send signals. Instead hardclock schedules a timeout that will send the signal later. There are many reasons why this works just as good as the previous code, all explained in a comment written in big, friendly letters in kern_clock. miod@ ok noone else dared to ok this, but noone screamed in agony either.
2004-08-04Even when we have timecounters we still have to do the check for secondaryArtur Grabowski
cpus calling hardclock and the statclock emulation. Move some ifdef __HAVE_TIMECOUNTER code.
2004-07-28This touches only MI code, and adds new time keeping code. TheThorsten Lockert
code is all conditionalized on __HAVE_TIMECOUNTER, and not enabled on any platforms. adjtime(2) support exists, courtesy of nordin@, sysctl(2) support and a concept of quality for each time source attached exists. High quality time sources exists for PIIX4 ACPI timer as well as some AMD power management chips. This will have to be redone once we actually add ACPI support (at that time we need to use the ACPI interfaces to get at these clocks). ok art@ ken@ miod@ jmc@ and many more
2004-06-24This moves access to wall and uptime variables in MI code,Thorsten Lockert
encapsulating all such access into wall-defined functions that makes sure locking is done as needed. It also cleans up some uses of wall time vs. uptime some places, but there is sure to be more of these needed as well, particularily in MD code. Also, many current calls to microtime() should probably be changed to getmicrotime(), or to the {,get}microuptime() versions. ok art@ deraadt@ aaron@ matthieu@ beck@ sturm@ millert@ others "Oh, that is not your problem!" from miod@
2004-06-21First step towards more sane time handling in the kernel -- this changesThorsten Lockert
things such that code that only need a second-resolution uptime or wall time, and used to get that from time.tv_secs or mono_time.tv_secs now get this from separate time_t globals time_second and time_uptime. ok art@ niklas@ nordin@
2004-06-13debranch SMP, have funNiklas Hallqvist
2004-06-09Merge in a piece of the SMP branch into HEAD.Artur Grabowski
Introduce the cpu_info structure, p_cpu field in struct proc and global scheduling context and various changed code to deal with this. At the moment no architecture uses this stuff yet, but it will allow us slow and controlled migration to the new APIs. All new code is ifdef:ed out. ok deraadt@ niklas@
2003-06-02Remove the advertising clause in the UCB license which BerkeleyTodd C. Miller
rescinded 22 July 1999. Proofed by myself and Theo.
2003-05-13Force "struct timeval time" variable to be aligned to an 8-bit boundary.Miod Vallat
This is at least necessary for the sparc microtime() function, and was only working before by goat luck. The recent commons removal triggered it. __atribute__ syntax borrowed from NetBSD.
2002-09-24Restore pentium_microtime, testing by henning@, millert@. ok deraadt@Thomas Nordin
2002-07-06Remove kernel support for NTP. ok deraadt@ and tholo@Thomas Nordin
2002-07-03Change all variables definitions (int foo) in sys/sys/*.h to variableMiod Vallat
declarations (extern int foo), and compensate in the appropriate locations.
2002-06-07Change addupc_intr to not use fuswintr and suswintr to update the profilingArtur Grabowski
info. Since we only use it to profile processes in user mode and there is no way to get back user mode without going past the AST that will write out the profiling info in a context where copyout works. Sitting in my tree for ages. Reviewed and with some suggestions from nordin@
2002-06-07Simplify so that we can remove CLKF_BASEPRI() and spllowersoftclock()Thomas Nordin
infrastructure. ok art@ and miod@
2002-04-24Introduce a new file, machine/internal_types.h, to hold that specific archMarc Espie
type characteristics. internal_types.h will contain only settings invisible from standard C, e.g., in the __* or _[A-Z]* namespace, and be reused by files like limits.h. This allows us to shorten machine/limits.h greatly, as all the common defines are now in sys/limits.h, plus a small stub in internal_types.h. Tested on all arches as far as I know. Approved after discussion with art, millert, deraadt, and others.
2002-02-18Don't do unnecessary normalization. ok art@Thomas Nordin
2002-02-15Improve comment. ok art@Thomas Nordin
2002-02-15Add a tvtohz function. Like hzto, but doesn't subtract the current time.Artur Grabowski
2002-01-02Remove reference to timeout table. deraadt@ okThomas Nordin
2001-12-14New hz value needed by AlphaServer 1200 and a couple other machinesNathan Binkert
2001-11-06Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.Miod Vallat
(Look ma, I might have broken the tree)
2001-08-19generic soft interrupts for softclock.Artur Grabowski
From NetBSD.
2000-08-23Move the updating of timeout queues to after ticks is incremented.Artur Grabowski
The older code actually ensured that no timeout would be too early, but it violated the principle of least surprise by making it seem (when you looked at the time variable) that every timeout was one tick late. Also periodic timeouts (that readd themselves in the timeout function), will now happen with the frequency you expect.
2000-07-07Make hzto return 0 for timeouts that should happen now or in the past.Artur Grabowski
2000-07-06Change splsoftclock() to spllowersoftclock(). (art@ ok)Hakan Olsson
2000-07-05Stop sleeps from returning early (by up to a clock tick).Paul Janzen
From FreeBSD: eventually, we should replace hzto() with something like tvtohz() as well.
2000-03-23Update a comment to reflect reality.Artur Grabowski
2000-03-23New API for timeouts. Replaces the old timeout()/untimeout() API andArtur Grabowski
makes it the callers responsibility to allocate resources for the timeouts. This is a KISS implementation and does _not_ solve the problems of slow handling of a large number of pending timeouts (this will be solved in future work) (although hardclock is now guarateed to take constant time for handling of timeouts). Old timeout() and untimeout() are implemented as wrappers around the new API and kept for compatibility. They will be removed as soon as all subsystems are converted to use the new API.
1999-08-15Adopt NetBSD fix for scheduler problems (nice was broken). From the NetBSDPaul Janzen
commit messages: Scheduler bug fixes and reorganization * fix the ancient nice(1) bug, where nice +20 processes incorrectly steal 10 - 20% of the CPU, (or even more depending on load average) * provide a new schedclock() mechanism at a new clock at schedhz, so high platform hz values don't cause nice +0 processes to look like they are niced * change the algorithm slightly, and reorganize the code a lot * fix percent-CPU calculation bugs, and eliminate some no-op code === nice bug === Correctly divide the scheduler queues between niced and compute-bound processes. The current nice weight of two (sort of, see `algorithm change' below) neatly divides the USRPRI queues in half; this should have been used to clip p_estcpu, instead of UCHAR_MAX. Besides being the wrong amount, clipping an unsigned char to UCHAR_MAX is a no-op, and it was done after decay_cpu() which can only _reduce_ the value. It has to be kept <= NICE_WEIGHT * PRIO_MAX - PPQ or processes can scheduler-penalize themselves onto the same queue as nice +20 processes. (Or even a higher one.) === New schedclock() mechanism === Some platforms should be cutting down stathz before hitting the scheduler, since the scheduler algorithm only works right in the vicinity of 64 Hz. Rather than prescale hz, then scale back and forth by 4 every time p_estcpu is touched (each occurance an abstraction violation), use p_estcpu without scaling and require schedhz to be generated directly at the right frequency. Use a default stathz (well, actually, profhz) / 4, so nothing changes unless a platform defines schedhz and a new clock. [ To do: Define these for alpha, where hz==1024, and nice was totally broke.] === Algorithm change === The nice value used to be added to the exponentially-decayed scheduler history value p_estcpu, in _addition_ to be incorporated directly (with greater weight) into the priority calculation. At first glance, it appears to be a pointless increase of 1/8 the nice effect (pri = p_estcpu/4 + nice*2), but it's actually at least 3x that because it will ramp up linearly but be decayed only exponentially, thus converging to an additional .75 nice for a loadaverage of one. I killed this: it makes the behavior hard to control, almost impossible to analyze, and the effect (~~nothing at for the first second, then somewhat increased niceness after three seconds or more, depending on load average) pointless. === Other bugs === hz -> profhz in the p_pctcpu = f(p_cpticks) calcuation. Collect scheduler functionality. Try to put each abstraction in just one place.
1998-08-27Undo changes which were not discussed.Theo de Raadt
1998-08-27defopt NTPMichael Shalayeff
1998-02-08Updates to match type changes in syscall tablesThorsten Lockert
1997-12-30make it compile w/ GPROFMichael Shalayeff
1997-11-23nuke prehistoric disk statisticsMichael Shalayeff
1997-01-25Don't do disruptive time corrections if tick size is not integral; fromThorsten Lockert
Dennis Ferguson (NetBSD PR #2788)
1997-01-25Improve adjtime() for odd hz values; from Dennis Ferguson (NetBSD PR# 2787)Thorsten Lockert
1996-09-09Don't claim a better precision than (1,000,000 / hz) us...Thorsten Lockert
1996-06-09Declare tickfixcnt only ifndef NTP.briggs
1996-05-03Make pretty + update $NetBSD$ tag. No functional change.Niklas Hallqvist
1996-05-02sync syscalls, no sys/cpu.hTheo de Raadt
1996-04-21partial sync with netbsd 960418, more to comeTheo de Raadt
1996-04-19NetBSD 960317 mergeNiklas Hallqvist
1996-03-03From NetBSD: 960217 mergeNiklas Hallqvist