Commit Graph

189 Commits

Author SHA1 Message Date
njoly
a9422942bd Adjust clock_nanosleep(2) to not copyout remaining time struct if
TIMER_ABSTIME flag is set.

Ok Christos.
2016-11-11 15:29:36 +00:00
msaitoh
8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
christos
ea2913a0a2 GSoC 2016: Charles Cui: Add timer related macros
_POSIX_CPUTIME
    _POSIX_THREAD_CPUTIME
    _POSIX_DELAYTIMER_MAX
2016-06-10 23:29:20 +00:00
christos
8114776c49 Add clock_getcpuclockid2(2) as well as CLOCK_{PROCESS,THREAD}_CPUTIME_ID. 2016-04-23 23:08:26 +00:00
christos
53a91c7008 - GC pts_fired, and fix the comment about MAX_TIMERS
- Bump MAX_TIMERS to 36 so that we have 32 POSIX user timers which is the
  minimum required.
2016-03-08 05:02:55 +00:00
uwe
705ce573e4 Don't leak garabage from the kernel stack on sleep(0) and equivalents.
Hat tip to perl's ext/POSIX/t/wrappers.t
2016-03-03 01:39:17 +00:00
christos
3053e9e889 Make comments and code match reality; there are 4 reserved timers. 2016-02-26 17:08:58 +00:00
christos
a3c9e9c899 CID/1325753: remove extra return. 2015-10-06 15:03:34 +00:00
christos
3415810083 PR/50295: clock_nanotime() should not set errno, but return the error. 2015-10-02 19:47:08 +00:00
maxv
6647020bbc Unused inits (harmless).
Found by Brainy.
2015-07-24 13:02:52 +00:00
christos
39d23ee140 Make ts2timo(9) always return the absolute start time if the start argument
is present, and handle the TIMER_ABSTIME case in nanosleep1(9).
2013-05-22 16:00:52 +00:00
christos
463c93b4e7 always return immediately on error, and if we passed negative seconds,
return with 0.
2013-03-31 16:45:06 +00:00
martin
573f2396f8 Move clock_gettime1() to subr_time.c (which is included in rump kernels) 2013-03-29 10:34:12 +00:00
christos
4cec95f0ea Centralize the computation of struct timespec to the int timo.
Make lwp_park take the regular arguments for specifying what kind
of timeout we supply like clock_nanosleep(), namely clockid_t and flags.
2013-03-29 01:08:17 +00:00
christos
1ec743232e kernel portion of clock_nanosleep() 2012-10-02 01:44:27 +00:00
dholland
98573cd6ad Misplaced parenthesis; fixes PR 44927 2012-03-22 17:46:07 +00:00
rmind
25c2f01c4f itimerfire: fix a regression, check if timer is already queued. 2012-02-20 01:12:42 +00:00
rmind
ad12c77015 Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
2012-02-19 21:05:51 +00:00
christos
2e4fce7c78 Fix monotonic interval timers. 2011-12-18 22:30:25 +00:00
christos
10ae252532 There is no reason not to support CLOCK_MONOTONIC in {g,s}etitimer() since
the underlying implementation already supports it, so add it.
2011-10-27 16:12:52 +00:00
uebayasi
2de1fdfe8b These don't need uvm/uvm_extern.h. 2011-07-27 14:35:33 +00:00
yamt
22f6580cf6 implement timer_create of CLOCK_MONOTONIC 2011-04-08 10:35:37 +00:00
yamt
ba01a8d426 fix assertion failure in timer_intr. CLOCK_REALTIME timers can be on
timer_queue.
2011-04-05 00:27:35 +00:00
yamt
56704cd648 realtimerexpire: rename a confusing variable. no functional change.
(now_ms -> now_ns as it hold a nano second value)
2010-12-17 22:08:18 +00:00
njoly
4f2ea8f3c9 Add a new clock_gettime1() function that holds most of the
clock_gettime syscall code (except for the copyout). Adjust all
corresponding syscalls to make use of it.
2010-04-08 11:51:13 +00:00
njoly
0876f873dd Move most clock_getres syscall code, except for coypout call, to a new
clock_getres1() function which can be used by emulations. Adjust all
clock_getres syscalls to now make of use it.
2010-04-03 17:20:05 +00:00
drochner
a1a04dd1be If a struct sigevent with SIGEV_SIGNAL is passed to timer_create(2),
check the signal number to be in the allowed range. An invalid
signal number could crash the kernel by overflowing the sigset_t
array.
More checks would be good, and SIGEV_THREAD shouldn't be dropped
silently, but this fixes at least the local DOS vulnerability.
2009-12-10 12:39:12 +00:00
elad
a39251ecc2 Introduce time_wraps() to check if setting the time will wrap it (or
close to it). Useful for secmodels.

Replace open-coded form with it in secmodel code (securelevel, keylock).

Note: I need to find a way to make secmodel_keylock.c ~<100 lines.
2009-10-03 20:48:42 +00:00
pooka
fbd53556dc Wipe out the last vestiges of POOL_INIT with one swift stroke. In
most cases, use a proper constructor.  For proplib, give a local
equivalent of POOL_INIT for the kernel object implementation.  This
way the code structure can be preserved, and a local link set is
not hazardous anyway (unless proplib is split to several modules,
but that'll be the day).

tested by booting a kernel in qemu and compile-testing i386/ALL
2009-09-13 18:45:10 +00:00
christos
2b1b4bc6ef Move the internal poll/select related API's to use timespec instead
of timeval (rides the uvm bump).
2009-03-29 19:21:19 +00:00
yamt
fc774e4e61 settime1: fix a bug i introduced when i made l_stime use monotonic time.
from Matthias Drochner on tech-kern@.  PR/40511 from Martin Husemann.
2009-01-31 15:53:36 +00:00
ad
697e4adf70 timer_intr: hold proc_lock across the loop, otherwise the process we are
about to signal could disappear.
2009-01-30 23:11:27 +00:00
christos
e625b403dd - fix leaked lock, thanks ad@ for noticing.
- remove unneeded cast.
2009-01-11 15:57:29 +00:00
christos
461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
wrstuden
27724c38ae Adjust locking on the sadata::sa_vps list. The main time we
walk the list, we're looking for a vp to do something with. We do
this in the signal code and in the timer code. The signal code already
runs with proc::p_lock held, so it's a very natural lock to use. The
timer code, however, calls into the sa timer code with a spinlock held.
Since proc::p_lock is an adaptable mutex, we can sleep to get it. Sleeping
with a spinlock is BAD. So proc::p_lock is _not_ the right lock there,
and something like sadata::sa_mutex would be best.

Address this difficulty by noting that both uses actually just read
the list. Changing the list of VPs is rare - once one's added, it stays
until the process ends. So make the locking protocol that to write the
list you have to hold both proc::p_lock and sadata::sa_mutex (taken
in that order). Thus holding either one individually grants read access.

This removes a case where we could sleep with timer_lock, a spinlock at
IPL_SCHED (!!), while trying to get p_lock. If that ever happened, we'd
pretty much be dead. So don't do that!

This fixes a merge botch from how I handled our gaining p_lock - p_lock
should not have simply replaced p_smutex.

While here, tweak the sa_unblock_userret() code for the case
when the blessed vp is actually running (on another CPU). Make its
resched RESCHED_IMMED so we whack the CPU. Addresses a hang I've
observed in starting firefox on occasion when I see one thread running
in userland and another thread sitting in lwpublk, which means it's on
the list of threads for which we need an unblocked upcall. This list is
one on which things should NOT linger.
2008-10-16 18:21:45 +00:00
wrstuden
fc7511b00e Merge wrstuden-revivesa into HEAD. 2008-10-15 06:51:17 +00:00
pooka
44367b7199 Split rate-checking routines into their own module for easier reuse. 2008-09-25 17:17:10 +00:00
christos
93aed8f8e3 fix half-assed change usec -> nsec that broke non-real timers. 2008-09-23 16:44:49 +00:00
christos
f6e1114503 Fix broken setitimer(). (Sverre Froyen) 2008-08-08 16:44:52 +00:00
christos
aa389c698d Use more timespecs internally. From Alexander Shishkin and me.
Welcome to 4.99.70, 30 more to go for 100.
2008-07-15 16:18:08 +00:00
christos
7f6e74c46e Fix to bug reported and tested by Alexander Shishkin. struct ptimer has
a union that contains either a callout [for CLOCK_REALTIME] or a flag
and a list [for other clock types]. Make sure we perform the right actions
on the right union member depending on the clock type. Otherwise this would
result in crashes.
2008-07-08 20:53:02 +00:00
joerg
157262cae8 Explicitly compute the next interval using 64bit arithmetic, if the time
was either stepped backwards or the timer has overflown. This fixes
PR 26470.
2008-05-29 15:27:51 +00:00
ad
541e4662f9 - Add tc_gonebad(): allows timecounter to be flagged as bad and removed at
the next clock tick.
- Remove time_lock, which is no longer required.
2008-05-08 18:56:58 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad
6d70f903e6 Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
  be sent from a hardware interrupt handler. Signal activity must be
  deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
  and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
2008-04-24 15:35:27 +00:00
ad
43d8bae932 Give callout_halt() an additional 'kmutex_t *interlock' argument. If there
is a need to block and wait for the callout to complete, and there is an
interlock, it will be dropped while waiting and reacquired before return.
2008-04-22 12:04:22 +00:00
ad
a2249ef75c Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE. 2008-04-21 12:56:30 +00:00
ad
08b44dd8b9 timer fixes for PR 37093:
- Fix serious concurrency problems, making the code MT and MP safe in
  the process.
- Don't allocate memory or inspect process state from hardclock().
2008-04-21 00:13:46 +00:00
yamt
8b793ad476 nanosleep1: handle kpause spontaneous wakeups. 2008-02-25 12:25:03 +00:00
yamt
63e70ec982 wrap long lines. no functional change. 2008-02-19 14:21:56 +00:00