15using namespace MaxOS::processes;
16using namespace MaxOS::processes::resources;
17using namespace MaxOS::common;
18using namespace MaxOS::memory;
31:
Resource(name, size, MaxOS::KPI::ResourceType::SHARED_MEMORY),
37SharedMemory::~SharedMemory() =
default;
51 if(it == m_mappings.end())
64 return m_physical_address;
86 if(it != m_mappings.end())
124 for(
auto& message : m_queue)
137 m_message_lock.
lock();
141 for (
size_t i = 0; i < count; ++i)
142 size += vec[i].length;
145 auto* new_message =
new buffer_t(size);
146 for (
size_t i = 0; i < count; ++i)
147 new_message->copy_from(vec[i].address, vec[i].length);
150 m_queue.push_back(new_message);
168 while(m_queue.empty()) {
177 buffer_t* message = m_queue.pop_front();
178 size_t readable = size > message->capacity() ? message->capacity() : size;
179 memcpy(buffer, message -> raw(), readable);
VirtualMemoryManager * vmm()
static PhysicalMemoryManager * s_current_manager
The current physical memory manager in use.
void free_area(uint64_t start_address, size_t size)
Frees an area of physical memory.
void * load_shared_memory(const string &name)
Load shared memory into the VMM's address space.
void lock()
Lock the spinlock once it is available, sleeping until other processes are done with it.
void unlock()
Unlock the spinlock.
static Process * current_process()
Gets the process on the currently executing core.
static Thread * current_thread()
Gets the thread on the currently executing core.
uint64_t pid() const
Gets the pid of the process.
memory::MemoryManager * memory_manager
The manager for memory used by this process.
size_t size() const
Gets the size of the shared memory block.
SharedMemory(const string &name, size_t size, resources::resource_type_t type)
Creates a new shared memory block.
int read(void *buffer, size_t size, size_t flags) final
Get the address that the current process has this shared memory mapped to.
void close(size_t flags) final
Frees the page containing the shared memory.
uintptr_t physical_address() const
Gets the physical address of the shared memory block.
void open(size_t flags) final
Map the shared memory into the address space of the owning process.
int write(const void *buffer, size_t size, size_t flags) final
Handles writing to the message endpoint resource by writing the buffer as a message.
int read(void *buffer, size_t size, size_t flags) final
Reads the first message from the endpoint or will yield until a message has been written.
SharedMessageEndpoint(const string &name, size_t size, resources::resource_type_t type)
Creates a new shared message endpoint.
void send(const ipc_iovec_t *vec, size_t count)
Combines a multipart message and sends it to the endpoint.
~SharedMessageEndpoint() final
Destroys the shared message endpoint and frees all messages.
void yield()
Pass execution to the next ready thread.
Defines inter-process communication (IPC) methods such as shared memory and message endpoints.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
KPI::Resource Resource
Alias to make the libsyscore Resource accessible here.
KPI::ResourceType resource_type_t
Alias to make the libsyscore ResourceType accessible here.
Defines a GlobalScheduler and Scheduler for managing processes and threads.
Read/Write call entry for a list of I/O requests in a RPC call.