1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:37:34 +00:00

Kernel+LibC: Make all SharedBuffers purgeable (default: non-volatile)

This patch makes SharedBuffer use a PurgeableVMObject as its underlying
memory object.

A new syscall is added to control the volatile flag of a SharedBuffer.
This commit is contained in:
Andreas Kling 2019-12-09 20:06:47 +01:00
parent 65229a4082
commit 0317ca5ccc
6 changed files with 50 additions and 5 deletions

View file

@ -1,4 +1,5 @@
#include <AK/kmalloc.h>
#include <Kernel/Syscall.h>
#include <SharedBuffer.h>
#include <stdio.h>
#include <unistd.h>
@ -64,3 +65,19 @@ void SharedBuffer::seal()
ASSERT_NOT_REACHED();
}
}
void SharedBuffer::set_volatile()
{
u32 rc = syscall(SC_set_shared_buffer_volatile, m_shared_buffer_id, true);
ASSERT(rc == 0);
}
bool SharedBuffer::set_nonvolatile()
{
u32 rc = syscall(SC_set_shared_buffer_volatile, m_shared_buffer_id, false);
if (rc == 0)
return true;
if (rc == 1)
return false;
ASSERT_NOT_REACHED();
}

View file

@ -1,7 +1,7 @@
#pragma once
#include <AK/RefPtr.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
class SharedBuffer : public RefCounted<SharedBuffer> {
public:
@ -15,6 +15,8 @@ public:
int size() const { return m_size; }
void* data() { return m_data; }
const void* data() const { return m_data; }
void set_volatile();
[[nodiscard]] bool set_nonvolatile();
private:
SharedBuffer(int shared_buffer_id, int size, void*);