- Jan 27, 2014
-
-
Nadav Har'El authored
Replace the old function condvar::wait(mutex*, uint64_t) with one taking a timepoint. This timepoint can use any clock which the timer supports, namely osv::clock::uptime or osv::clock::wall (as usual, wall-clock timers are not recommended, and are converted to an uptime timer at the point of instantiation). Leave a C-only function condvar_wait(convar*, mutex*, s64) but comment on what it takes. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
Fix tst-wait-for.cc to use the new <osv/clock.hh> APIs. This test uses std::abs on a time duration, and unfortunately C++11 fails to implement std::abs on an std::chrono::duration. This patch also adds support for this (in the form of a trivial template function) to <osv/clock.hh>. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
Delete the sched::thread::sleep_until() function. All users of this function actually wanted a relative time, not absolute time, and can use the simpler new sched::thread::sleep() instead. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
C++11's std::chrono allows clearly differentiating between absolute times (std::chrono::time_point) and relative times (std::chrono::duration), and we are no longer at risk of confusing absolute and relative time. This patch allows various functions to also take relative times (duration) instead of absolute times (time_point), making them easier to use. All of them use the monotonic clock's current time (osv::clock::uptime::now) to convert relative to absolute times: 1. Shortcut tmr.set(10_ms) for tmr.set(osv::clock::uptime::now() + 10_ms) 2. Similarly, we add a duration version of condvar::wait(), which can now be used as condvar::wait(mutex, 10_ms). 3. Add a new function sched::thread::sleep(10_ms). These new variants are not only shorter, they also make it unnecessary for the caller to understand what clock it should use for relative waits, or mistakenly use the wrong clock. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
Switch the thread scheduler from using the s64 type for durations and the wall time, to the osv::clock::uptime::duration type (which is std::chrono::nanoseconds) and monotonic clock. Also, now that the per-thread CPU-time clock (thread::thread_clock()) returns an std::chrono::duration instead of s64, we no longer need the fill_ts(s64) variant in libc/time.cc (if we leave it unused, we'll get a compilation warning). Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
Durations cannot be compared with unit-less integers: one cannot just check d < 7: One needs to do something like d < 7_ms. Unfortunately, this rule also applies to zero: d < 0 won't work, and users need to add a unit to the zero. Of course, any unit would work: d < 0_ms, or d < 0_ns, or any other time unit. For physicists, this requirement makes perfect sense (even zero has units), but for most programmers, the extra units would seem surprising and redundant. This patch makes it possible to compare a std::chrono::duration to 0 without needing to add a unit, while still leaving comparison with a non-zero integer an error. This is convenient for us because existing code which compared s64 durations to unit-less 0, will continue to work unmodified after we switch from s64 to std::chrono::duration. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
sched::timer_base, used to implement all forms of timeouts in OSv, is currently based on the wall-clock time in s64 form. This is problematic for two reasons: 1. The type s64 doesn't say which units should be used, whether the time is absolute or relative or what is its epoch. 2. wall-clock time is a bad choice for short-term timers: If a thread intends to sleep for a millisecond, and the wall-clock goes back a minute, the thread will end up sleeping a whole minute. So this patch changes the basis of sched::timer_base to strongly-typed time points from a monotonic clock, osv::clock::uptime::time_point. We also allow setting timers using the wall-clock time, but with a big caveat: The expiration time is converted from wall to uptime clocks at the moment of timer_base::set(), so if the wall-clock is adjusted later, the wall time at expiration may not be exactly the one intended. So that we don't have to change all timer users in this one patch, we also temporarily implement the old weakly-typed timer_base::set(s64) using the new mechanism. This variant will be removed in a later patch in this series, when it is no longer used. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
Unfortunately, sched.cc uses "using namespace osv" causing a big mixup between ::clock (from <drivers/clock.hh>) and osv::clock (from <osv/clock.hh>). In the next patch, we want to start using <osv/clock.hh> in sched.cc, so we need to first clear this mixup by temporarily adding an alias osv::clock::get(), to resolve the clock::get() used throughout sched.cc. In later patches in this series, we'll remove all the calls to clock::get(), from sched.cc, so at the end of the series we revert this patch. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
Currently, OSv's sched::timer mechanism supports only the wall clock clock::get()->time(). In the following patches, we intend to support both wall-clock and monotonic clock in timers, but only keep a single list of timers (using the monotonic clock). For this, we need a way to convert wall-clock time to monotonic uptime. This patch adds to the clock driver a function clock::boot_time() which returns the current offset between the wall time and the uptime, i.e., the current estimate of the wall time at boot. Note that this estimate can change if the wall time is adjusted (in the host, since OSv currently has no mechanism for adjusting the clock from within). Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 24, 2014
-
-
Glauber Costa authored
To avoid using hard code values for the original anonymous vma that mapped the region before we ballooned, let's store the original flags in the JVM vma. This patch does not yet use it, but only lays down the infrastructure. User will come in the next patch. Signed-off-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 22, 2014
-
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Move definitions from <debug.h> to <osv/debug.h> and update includes to use the latter. Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 21, 2014
-
-
Avi Kivity authored
Signed-off-by:
Avi Kivity <avi@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Avi Kivity authored
Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 20, 2014
-
-
Avi Kivity authored
Allow arbitrary predicates to be waited on. Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
Avi Kivity authored
A waitqueue is an object on which multiple threads can wait; other threads can wake up either one or all waiting threads. A waitqueue is associated with an external mutex which the user must supply for both wait and wake operations. Waitqueues differ from condition variables in three respects: - waitqueues do not contain an internal mutex. This makes them smaller, and reduces lock acquisitions. On the other hand the waker must hold the associated mutex, whereas this is not required with condition variables. - waitqueues support sched::thread::wait_for() waitqueues support wait morphing and do not cause excess lock contention, even with wake_all(). Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
Avi Kivity authored
This adds a facility to wake a thread, but with the intention that it will acquire a certain lock after waking, and while the waker holds the lock. This is implemented using the regular wait morphing code (send_lock() and receive_lock()), but with additional mutual exclusion to allow regular wake()s in parallel. Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
Avi Kivity authored
Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
Avi Kivity authored
Add a signal catching class (signal_catcher). Use signal_catcher::wait() to wait for a signal. Use sched::thread::wait_for(..., signal_catcher&, ...) to wait for a signal in addition to other events. Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
Avi Kivity authored
Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
Avi Kivity authored
Waiting is complicated; you can wait for a condition variable, a timer, wait queues and signals (when we have them), semaphores, and more. When you need to wait for multiple events, things become even more complicated as some sort of abstraction is needed. poll() for example supports waiting for multiple objects that conform to the fd interface, or for a timeout. To allow more flexible waiting, this patch adds a poll-like interface to the scheduler, except that the interfaces are all compile time. We add a new function wait_for() that accepts a variable number of waitable objects. A waitable object is an object that supports the three methods: - poll(): check if waiting is complete - arm(): prepare for waiting - disarm(): finish waiting to make a waitable object usable with wait_for, these functions have to be supplied. Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
- Jan 19, 2014
-
-
Nadav Har'El authored
sysinfo() until now was a stub. This patches fills some of the information we can already provide, namely the uptime in seconds (through the recently added osv::clock::uptime()), the total and free memory (through the recently added memory::stats::free()/total() functions), and number of processes (always 1 on OSv). This patch also changes a couple of types from unsized names (like "unsigned") to fixed-sized ones (like "u32"), to match the definition of this structure on Linux. It won't make any difference on x86_64, but perhaps in some future architecture it will. Tested-by:
Amnon Heiman <amnon@cloudius-systems.com> Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-