1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

Kernel+LibC: Publish a "kernel info page" and use it for gettimeofday()

This patch adds a single "kernel info page" that is mappable read-only
by any process and contains the current time of day.

This is then used to implement a version of gettimeofday() that doesn't
have to make a syscall.

To protect against race condition issues, the info page also has a
serial number which is incremented whenever the kernel updates the
contents of the page. Make sure to verify that the serial number is the
same before and after reading the information you want from the page.
This commit is contained in:
Andreas Kling 2019-12-15 21:29:26 +01:00
parent 931e4b7f5e
commit 77cf607cda
6 changed files with 62 additions and 9 deletions

View file

@ -67,6 +67,8 @@ public:
static Process* from_pid(pid_t);
static void update_info_page_timestamp(const timeval&);
const String& name() const { return m_name; }
pid_t pid() const { return m_pid; }
pid_t sid() const { return m_sid; }
@ -233,6 +235,7 @@ public:
int sys$module_unload(const char* name, size_t name_length);
int sys$profiling_enable(pid_t);
int sys$profiling_disable(pid_t);
void* sys$get_kernel_info_page();
static void initialize();