summaryrefslogtreecommitdiff
path: root/Kernel/Process.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-10 13:44:01 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-10 19:21:16 +0200
commitfdfc66db618a59242db34fd6b59e5ada095190ab (patch)
treeab62f4ad151860157bdcc1547e5f0fb441cdacb6 /Kernel/Process.h
parentf02d73db4dd331f463694b77bb2838f92f2aa572 (diff)
downloadserenity-fdfc66db618a59242db34fd6b59e5ada095190ab.zip
Kernel+LibC: Allow clock_gettime() to run without syscalls
This patch adds a vDSO-like mechanism for exposing the current time as an array of per-clock-source timestamps. LibC's clock_gettime() calls sys$map_time_page() to map the kernel's "time page" into the process address space (at a random address, ofc.) This is only done on first call, and from then on the timestamps are fetched from the time page. This first patch only adds support for CLOCK_REALTIME, but eventually we should be able to support all clock sources this way and get rid of sys$clock_gettime() in the kernel entirely. :^) Accesses are synchronized using two atomic integers that are incremented at the start and finish of the kernel's time page update cycle.
Diffstat (limited to 'Kernel/Process.h')
-rw-r--r--Kernel/Process.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 9ae0d27e0b..b0e56a3ad7 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -412,6 +412,7 @@ public:
KResultOr<FlatPtr> sys$anon_create(size_t, int options);
KResultOr<FlatPtr> sys$statvfs(Userspace<const Syscall::SC_statvfs_params*> user_params);
KResultOr<FlatPtr> sys$fstatvfs(int fd, statvfs* buf);
+ KResultOr<FlatPtr> sys$map_time_page();
template<bool sockname, typename Params>
int get_sock_or_peer_name(const Params&);