- Jan 27, 2014
-
-
Nadav Har'El authored
Fix pthread_cond_timedwait to set the absolute timer using a timepoint, instead of the old s64. Moreover, now that we have both a wall-clock and monotonic clock, we can support pthread_condattr_setclock, so this patch also adds this support. OpenJDK 8, for example, cannot run without this support (it assumes that if the OS supports CLOCK_MONOTONIC, it can also configure condition variables to use it). Unfortunately supporting pthread_condattr_setclock - the only condition- variable attribute that really exists - grows the pthread condition variable structure :( Fixes #168. 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
Drop the s64 literals _ms, _ns, etc., from <drivers/clock.hh>. Fix a few places which still use the old literals. The std:chrono::duration version from <osv/clock.hh> remains - but remember you need to "using namespace osv::clock::literals" to use them. 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
Change alarm() implementation to use the new <osv/clock.hh> APIs and the monotonic 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
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
Switch the timerfd to use std::chrono types, and add support also for the monotonic clock. Fixes #142. 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>
-
- 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>
-
- Jan 20, 2014
-
-
Vlad Zolotarov authored
Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Vlad Zolotarov <vladz@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Vlad Zolotarov authored
Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Vlad Zolotarov <vladz@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Vlad Zolotarov authored
Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Vlad Zolotarov <vladz@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@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>
-
- Jan 17, 2014
-
-
Pekka Enberg authored
Currently, RLIMIT_STACK is 64 KB. This is too small for the JVM which limits stack size to RLIMIT_STACK if a VMA range that covers address found in '__libc_stack_end' in /proc/self/maps. In preparation for procfs support, switch to pthread_attr_getstacksize() for RLIMIT_STACK. Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Pekka Enberg authored
Add pthread_attr_getstacksize() in preparation for fixing RLIMIT_STACK. Reviewed-by:
Glauber Costa <glommer@cloudius-systems.com> Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 16, 2014
-
-
Nadav Har'El authored
Output to stdout normally goes to file descriptor 1. However, during early boot, before the console is opened on file descriptor 1, we also want printf() to work. So this case is specially treated in libc/stdio/__stdout_write.cc, where in this early case, we used debug_write directly, instead of write to the file descriptor. However, recent patches changed debug_write to write to a memory buffer, instead of to screen (unless "--verbose" option is given to the loader). This made early printf() break too. This patch changes __stdout_write to use console::write(), not debug_write(). To use console::write(), I had to convert that source file to C++. Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 15, 2014
-
-
Nadav Har'El authored
Add a type-safe std::chrono interface to the wall-clock time. E.g., use use osv::clock::wall::now() to get an std::chrono::time_point instead of clock::get()->time() which returns an s64. This patch also changes clock_gettime(CLOCK_REALTIME) and gettimeofday() to use the new osv::clock::wall::now() interface. Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 13, 2014
-
-
Dmitry Fleytman authored
Signed-off-by:
Dmitry Fleytman <dmitry@daynix.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Dmitry Fleytman authored
Move alarm cancellation logic to a separate function cancel_alarm_ll(). This fucntion will be called on thread destruction to avoid post-mortem alarms. Also move alarm scheduling logic to a separate function set_alarm_ll() to make code symmetric. Signed-off-by:
Dmitry Fleytman <dmitry@daynix.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
The code "file_ts" converting a std::chrono::duration into a struct timespec, was unnecessarily constrained to take as input a std::chrono::nanoseconds, whereas it can actually work with durations of any resolution (the duration_cast will convert it to the correct units), so this patch makes this generalization which, I think, makes the code clearer. At first I decided to move this general function into <osv/clock.hh> and make it a bit more friendly (returning a timespec, instead of writing into one), but at the end, I decided not to move it. typespec is a dangerous type because though it does specify the clock's resolution (always nanoseconds) it doesn't specify the clock's epoch, so one can make mistakes like calling clock_gettime(CLOCK_MONOTONIC), and pass the returned timespec to pthread_cond_timedwait, which expects CLOCK_REALTIME not CLOCK_MONOTONIC. So we should avoid timespec whenever we can, and I don't think we'll need the fill_ts() function anywhere outside time.cc. Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 10, 2014
-
-
Glauber Costa authored
We are currently only answering requests for CLOCK_REALTIME, but we could easily handle: * CLOCK_REALTIME_COARSE, which is effective the same as CLOCK_REALTIME but faster. In our case, all time sources are equally fast * CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, since we can easily get runtimes for our threads and publish that. Signed-off-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
This patch starts to solve both issue #142 ("Support MONOTONIC_CLOCK") and issue #81 (use <chrono> for time). First, it adds an uptime() function to the "clock" interface, and implements it for kvm/xen/hpet by returning the system time from which we subtract the system time at boot (but not adding any correction for wallclock). Second, it adds a new std::chrono-based interface to this clock, in a new header file <osv/clock.hh>. Instead of the old-style clock::get()->uptime(), one should prefer osv::clock::uptime::now(). This returns a std::chrono::time_point which is type-safe, in the sense that: 1. It knows what its epoch is (i.e., that it belongs to osv::clock::uptime), and 2. It knows what its units are (nanoseconds). This allows the compiler to prevent a user from confusing measurements from this clock with those from other clocks, or making mistakes in its units. Third, this patch implements clock_gettime(MONOTONIC_CLOCK), using the new osv::clock::uptime::now(). Note that though the new osv::clock::uptime is almost identical to std::chrono::steady_clock, they should not be confused. The former is actually OSv's implementation of the latter: steady_clock is implemented by the C++11 standard library using the Posix clock_gettime, and that is implemented (in this patch) using osv::clock::uptime. With this patch, we're *not* done with either issues #142 or #81. For issue #142, i.e., for supporting MONOTONIC_CLOCK in timerfd, we need OSv's timers to work on uptime(), not on clock::get()->time(). For issue #81, we should add a osv::clock::wall type too (similar to what clock::get()->time() does today, but more correctly), and use either osv::clock::wall or osv::clock::uptime everywhere that clock::get()->time() is currently used in the code. clock::get()->time() should be removed. 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 08, 2014
-
-
Glauber Costa authored
The current implementation of memmove is a PITA (I mean the bread, of course) to decode if a fault happens. We have very little control of where exactly in the code the fault happens, therefore it is difficult to reason about it. This patch implements memmove in terms of memcpy + memcpy_backwards. For those, we can have specific fixups in the possible fault sites, that will allow us to decode the faults with ease. Note that originally, the only reason why the first branch was not a memcpy is that we would like to handle alignment. Since our implementation of memcpy is fast enough, we can just ignore that and we will end up being even faster. Signed-off-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Nadav Har'El authored
In his review of timerfd.cc, Avi asked that I simplify the implementation by having a single "timerfd" object (instead of two I had - timerfd_file and timerfd_object), and by using a single mutex instead of the complex combination of mutexes and atomic variable. This new version indeed does this. It should be easier to understand this code, and it is 30 lines shorter. The performance of this code is slightly inferior to the previous one - in particular poll() now locks and unlocks a mutex - but this should be negligible in practice. Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 07, 2014
-
-
Glauber Costa authored
This patch implements a simplified version of pthread_getcpuclockid that should be enough for our needs. Reviewed-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Glauber Costa <glommer@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 03, 2014
-
-
Tomasz Grabiec authored
This is not a documented behavior but glibc's dlopen behaves this way. Spotted when debugging assertion failure when java is started with a debugger, we try to read elf header from "/" on dlopen("", ...): Assertion failed: data.uio_resid == 0 (osv/fs/fs.cc: read: 27) Signed-off-by:
Tomasz Grabiec <tgrabiec@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Jan 01, 2014
-
-
Nadav Har'El authored
Each implementation of "struct file" needs to implement 8 different file operations. Most special file implementations, such as pipe, socketpair, epoll and timerfd, don't support many of these operations. We had in unsupported.h functions that can be reused for the unsupported operation, but this resulted in a lot of ugly boiler-plate code. Instead, this patch switches to a cleaner, more C++-like, method: It defines a new "file" subclass, called "special_file", which implements all file operations except close(), with a default implementation identical to the old unsupported.h implementations. The files of pipe(), socketpair(), timerfd() and epoll_create() now inherit from special_file, and only override the file operations they really want to implement. Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
- Dec 31, 2013
-
-
Gleb Natapov authored
Right now most of mmap related functions have the same bug related to vma locking: they validate mapping under vma lock then release the lock and do actual vma operation, but since between validation and operation the mapping can go away it is incorrect. This patch fixes this by doing validation and operation under the same lock. Signed-off-by:
Gleb Natapov <gleb@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
- Dec 30, 2013
-
-
Gleb Natapov authored
mprotect(PROT_WRITE) on a file opened as read only should fail, but current mprotect() implementation is missing the check. The patch implements it. Signed-off-by:
Gleb Natapov <gleb@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
Or Cohen authored
getgrgid_r(3) is needed when querying file attributes from Java (see java.nio.file.Files.readAttributes()). This is needed for long format (-l) flag of ls. getgrgid_r also requires sysconf(_SC_GETGR_R_SIZE_MAX) Signed-off-by:
Or Cohen <orc@fewbytes.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Dec 24, 2013
-
-
Nadav Har'El authored
We use sched::thread::attr to pass parameters to sched::thread creation, i.e., create a thread with non-default stack parameters, pinned to a particular CPU, or a detached thread. Previously we had constructors taking many combinations of stack size (integer), pinned cpu (cpu*) and detached (boolean), and doing "the right thing". However, this makes the code hard to read (what does attr(4096) specify?) and the constructors hard to expand with new parameters. Replace the attr() constructors with the so-called "named parameter" idiom: attr now only has a null constructor attr(), and one modifies it with calls to pin(cpu*), detach(), or stack(size). For example, attr() // default attributes attr().pin(sched::cpus[0]) // pin to cpu 0 attr().stack(4096).pin(sched::cpus[0]) // pin and non-default stack and so on. Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-
- Dec 20, 2013
-
-
Nadav Har'El authored
This patch implements the Linux's timerfd_*() system calls, declared in <sys/timerfd.h>. These define a file descriptor, usable for read() or poll() and friends, which becomes readable when a timer expires. This aspires to be a full implementation of timerfd, with all the intricate details explained in timerfd_create(2). timerfd was added to Linux five years ago (Linux 2.6.25). Boost's asio, in particular, uses this feature if it thinks it is available. Fixes #129. Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Dec 19, 2013
-
-
Gleb Natapov authored
mprotect() should fails with ENOMEM if it is called on non mapped virtual address, but this check is done by mmu::ismapped(). Signed-off-by:
Gleb Natapov <gleb@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Dec 18, 2013
-
-
Nadav Har'El authored
af_local.h declares a couple of functions implemented in af_local.cc. There is no reason for pipe.cc to include it. Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
-
- Dec 15, 2013
-
-
Nadav Har'El authored
This patch changes backtrace() to use the _Unwind_* facilities provided by the GCC runtime (libgcc_eh.a), instead of the separate libunwind.a. After this patch, we don't use libunwind.a in OSv any more, and it can be removed (see issue #83). Signed-off-by:
Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
-