mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 09:27:35 +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:
parent
65229a4082
commit
0317ca5ccc
6 changed files with 50 additions and 5 deletions
|
@ -2909,6 +2909,28 @@ int Process::sys$get_shared_buffer_size(int shared_buffer_id)
|
|||
return shared_buffer.size();
|
||||
}
|
||||
|
||||
int Process::sys$set_shared_buffer_volatile(int shared_buffer_id, bool state)
|
||||
{
|
||||
LOCKER(shared_buffers().lock());
|
||||
auto it = shared_buffers().resource().find(shared_buffer_id);
|
||||
if (it == shared_buffers().resource().end())
|
||||
return -EINVAL;
|
||||
auto& shared_buffer = *(*it).value;
|
||||
if (!shared_buffer.is_shared_with(m_pid))
|
||||
return -EPERM;
|
||||
#ifdef SHARED_BUFFER_DEBUG
|
||||
kprintf("%s(%u): Set shared buffer %d volatile: %u\n", name().characters(), pid(), shared_buffer_id, state);
|
||||
#endif
|
||||
if (!state) {
|
||||
bool was_purged = shared_buffer.vmobject().was_purged();
|
||||
shared_buffer.vmobject().set_volatile(state);
|
||||
shared_buffer.vmobject().set_was_purged(false);
|
||||
return was_purged ? 1 : 0;
|
||||
}
|
||||
shared_buffer.vmobject().set_volatile(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Process::terminate_due_to_signal(u8 signal)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue