summaryrefslogtreecommitdiff
path: root/sys/kern/kern_time.c
AgeCommit message (Collapse)Author
2019-01-10settime: Don't cancel ongoing adjtime(2) until after full permission checkscheloha
ok jca@ visa@ guenther@ deraadt@
2018-12-31nanosleep: loop tsleep(9) to ensure coverage of the full timeout range.cheloha
tsleep(9)'s maximum timeout shrinks as HZ grows, so this ensures we do not return early from longer timeouts on alpha or on custom kernels. POSIX says you cannot return early unless a signal is delivered, so this makes us more compliant with the standard. While here, remove the 100 million second upper bound. It is an artifact from itimerfix() and it serves no discernible purpose. ok tedu@ visa@
2018-12-29sys_nanosleep: switch to descriptive, idiomatic variable names; ok tedu@cheloha
2018-05-28Constipate a bunch of time functionsPhilip Guenther
ok tb@ kettenis@
2018-05-22nanosleep: ensure tv_nsec input is on [0, 1000000000)cheloha
Instead of converting timespec -> timeval and truncating the input, check with timespecfix and use tstohz(9) for the tsleep. All other contemporary systems check this correctly. Also add a regression test for this case. ok tb@
2018-02-19Remove almost unused `flags' argument of suser().Martin Pieuchot
The account flag `ASU' will no longer be set but that makes suser() mpsafe since it no longer mess with a per-process field. No objection from millert@, ok tedu@, bluhm@
2017-12-18Add the CLOCK_BOOTTIME clockid for use with clock_gettime(2)cheloha
and put it to use in userspace in lieu of the kern.boottime sysctl. Its absolute value is the time that has elapsed since the system booted, i.e., the system uptime. Use in top(1), w(1), and snmpd(8) eliminates a race with settimeofday(2), adjtime(2), etc. inherent to deriving the system uptime via the kern.boottime sysctl. Product of a great deal of discussion/revision with jca@, tb@, and guenther@. ok tb@ jca@ guenther@ dlg@ mlarkin@ tom@
2017-01-24Rename pfind(9) into tfind(9) to reflect that it deals with threads.Martin Pieuchot
While here document prfind(9. with and ok guenther@
2016-09-03Write the system time back to the RTC every 30 minutes.Christian Weisgerber
This fixes the problem that long-running machines which were not shut down properly would reboot with a badly offset system time. hints and ok kettenis@
2016-04-28careful study of the holy scrolls reveals that for pselect (and ppoll)Ted Unangst
oversized timespecs should be clamped, not rejected. ok millert
2015-12-05remove stale lint annotationsTed Unangst
2015-11-01refactor pledge_*_check and pledge_fail functionsSebastien Marie
- rename _check function without suffix: a "pledge" function called from anywhere is a "check" function. - makes pledge_fail call the responsability to the _check function. remove it from caller. - make proper use of (potential) returned error of _check() functions. - adds pledge_kill() and pledge_protexec() with and OK deraadt@
2015-10-09Rename tame() to pledge(). This fairly interface has evolved to be moreTheo de Raadt
strict than anticipated. It allows a programmer to pledge/promise/covenant that their program will operate within an easily defined subset of the Unix environment, or it pays the price.
2015-09-11Only include <sys/tame.h> in the .c files that need itPhilip Guenther
ok deraadt@ miod@
2015-08-22Move to tame(int flags, char *paths[]) API/ABI.Theo de Raadt
The pathlist is a whitelist of dirs and files; anything else returns ENOENT. Recommendation is to use a narrowly defined list. Also add TAME_FATTR, which permits explicit change operations against "struct stat" fields. Some other TAME_ flags are refined slightly. Not cranking libc now, since nothing commited in base uses this and the timing is uncomfortable for others. Discussed with many; thanks for a few bug fixes from semarie, doug, guenther. ok guenther
2015-07-19tame(2) is a subsystem which restricts programs into a "reduced featureTheo de Raadt
operating model". This is the kernel component; various changes should proceed in-tree for a while before userland programs start using it. ok miod, discussions and help from many
2015-04-28Protect the per-process itimerval structs with a mutex. We update theseMark Kettenis
from hardclock() which runs without grabbing the kernel lock. This means that two threads could concurrently update the struct which could lead to corruption of the value which in turn could stop the timer. It could also result in getitimer(2) returning a non-normalized value. With help from guenther@. ok deraadt@, guenther@
2014-12-07typo; fix from Kaspars BankovskisTheo de Raadt
2014-05-15Prefer prsignal() to send process signalsPhilip Guenther
2014-01-30Simplyfy adjtime(2) by keeping track of the adjustment as a number ofMark Kettenis
microsecond in a 64-bit integer. Fixes the issue where ntpd loses sync because the struct timeval currently used to hold the adjustment is not properly normalized after the changes guenther@ made. ok guenther@, millert@
2014-01-22timeval, timespec, and itimerval have padding on many archs. If we'rePhilip Guenther
going to copyout one, memset the structure and then set it member by member. sys_adjtime() does that on copyin instead, as it already has to munge the members as it goes. ok deraadt@
2013-10-25Move the declarations for dogetrusage(), itimerround(), and dowait4()Philip Guenther
to sys/*.h headers so that the compat/linux code can use them. Change dowait4() to not copyout() the status value, but rather leave that for its caller, as compat/linux has to translate it, with the side benefit of simplifying the native code. Originally written months ago as part of the time_t work; long memory, prodding, and ok from pirofti@
2013-10-08Fix delivery of SIGPROF and SIGVTALRM to threaded processes by havingPhilip Guenther
hardclock() set a flag on the running thread and force AST processing, and then have the thread signal itself from userret(). idea and flag names from FreeBSD ok jsing@
2013-10-06Add CLOCK_UPTIME, a clock which measures time-running-not-suspended, soPhilip Guenther
that mlarkin@ can fix programs that report rates-over-uptime. ok kettenis@ manpage corrections jmc@ (which I've probably broken again)
2013-09-14Snapshots for all archs have been built, so remove the T32 codePhilip Guenther
2013-08-13Switch time_t, ino_t, clock_t, and struct kevent's ident and dataPhilip Guenther
members to 64bit types. Assign new syscall numbers for (almost all) the syscalls that involve the affected types, including anything with time_t, timeval, itimerval, timespec, rusage, dirent, stat, or kevent arguments. Add a d_off member to struct dirent and replace getdirentries() with getdents(), thus immensely simplifying and accelerating telldir/seekdir. Build perl with -DBIG_TIME. Bump the major on every single base library: the compat bits included here are only good enough to make the transition; the T32 compat option will be burned as soon as we've reached the new world are are happy with the snapshots for all architectures. DANGER: ABI incompatibility. Updating to this kernel requires extra work or you won't be able to login: install a snapshot instead. Much assistance in fixing userland issues from deraadt@ and tedu@ and build assistance from todd@ and otto@
2013-06-17Add support for the _POSIX_CPUTIME and _POSIX_THREAD_CPUTIME options,Philip Guenther
including CLOCK_{PROCESS,THREAD}_CPUTIME_ID constants and {clock,pthread}_getcpuclockid() functions. Worked out at t2k13 with help from tedu@ and matthew@ and testing by aja@ ok matthew@
2013-06-03Convert some internal APIs to use timespecs instead of timevalsPhilip Guenther
ok matthew@ deraadt@
2013-06-02Use long long and %lld for printing tv_sec valuesPhilip Guenther
ok deraadt@
2013-03-28do not include machine/cpu.h from a .c file; it is the responsibility ofTheo de Raadt
.h files to pull it in, if needed ok tedu
2012-11-05unifdef -D __HAVE_TIMECOUNTERMiod Vallat
2012-05-24On resume, run forward the monotonic and realtimes clocks instead of jumpingPhilip Guenthe
just the realtime clock, triggering and adjusting timeouts to reflect that. ok matthew@ deraadt@
2012-03-23Make rusage totals, itimers, and profile settings per-process insteadPhilip Guenthe
of per-rthread. Handling of per-thread tick and runtime counters inspired by how FreeBSD does it. ok kettenis@
2012-03-19Add tracing and dumping of "pointer to struct" syscall arguments forPhilip Guenthe
structs timespec, timeval, sigaction, and rlimit. ok otto@ jsing@
2012-03-10Add PS_EXITING to better differentiate between the process exiting andPhilip Guenthe
the main thread exiting. c.f. regress/sys/kern/main-thread-exited/
2010-06-30lots of SCARG simplification. ok matthewTed Unangst
2010-06-28clock_gettime(CLOCK_PROF) didn't account for the time between the lastArtur Grabowski
context switch and the call to clock_gettime. oga@ ok
2010-04-04clock_settime() should cancel an in-progress adjtime() just likePhilip Guenthe
settimeofday() does, so move those bits into settime() "I like it" deraadt@
2009-11-27Convert thrsleep() to an absolute timeout with clockid to eliminate aPhilip Guenthe
race condition and prep for later support of pthread_condattr_setclock() "get it in" deraadt@, tedu@, cheers by others
2009-10-16cancel the timeout upon disabling profiling / virtual timer; soMartynas Venckus
that the timeout doesn't happen if setitimer is called between the profiling / virtual timer expires and the timeout is scheduled. firefox triggered this Profiling timer expired problem when in uthread execve signal was being delivered after timer has already been disabled; as reported on ports@ recently. special thanks to kettenis@, kurt@, guenther@. agreed by kettenis@, tedu@. ok guenther@. reminded & ok fgs@. tested by ian@.
2009-06-05abort any time adjustment in progress if the clock is set with settimeofdayChris Kuethe
ok millert
2008-09-19system/5918: fix clearing of ITIMER_VIRTUAL and ITIMER_PROF it_intervalDamien Miller
ok tedu@
2008-04-04ratecheck(9) only seems to be used to limit things to very coarse intervalsDavid Gwynne
like .25 seconds or 5 seconds. the accuracy of microuptime is not really needed then, so switch it to getmicrouptime. ok henning@ art@
2008-01-02Do not lose nanosleep() return value in the last copyout if nonzero; PR#5697Miod Vallat
2007-04-04Implement clock_gettime(CLOCK_PROF) since it's so simple.Artur Grabowski
deraadt@ ok
2007-01-10Fix getitimer to use uptime as setitimer does. Fixes bad output fromArtur Grabowski
getitimer when the clock on the machine has been reset. miod@ ok
2006-10-30Timecounter based implementation of adjfreq(2). Largely from art@Otto Moerbeek
Tested by various using not (yet) committed amd64 timecounter code. ok deraadt@
2006-06-29Normalize the correction passed to adjtime(2) before using it in theMark Kettenis
__HAVE_TIMECOUNTER case. ok otto@
2006-06-27Adapt adjtime() code and put in a better stub for adjfreq() for theOtto Moerbeek
timecounters case. adjfreq() does not work with timecounters, but more is coming. with help from miod; tested by dlg@; ok miod@
2006-06-15Make sys_adjfreq() compile on archs that use timecountersJonathan Gray
(ie sgi). Diff and request to commit from otto@