Max OS 0.3
Loading...
Searching...
No Matches
ipc.h
Go to the documentation of this file.
1
9#ifndef MAXOS_PROCESSES_IPC_H
10#define MAXOS_PROCESSES_IPC_H
11
12#include <cstdint>
13#include <cstddef>
14#include <common/vector.h>
15#include <common/string.h>
16#include <common/buffer.h>
17#include <common/spinlock.h>
18#include <memory/physical.h>
19#include <memory/memoryIO.h>
20#include <processes/resource.h>
21
22
23namespace MaxOS::processes {
24
29 class SharedMemory final : public Resource {
30
31 private:
32 uintptr_t m_physical_address;
33 size_t m_size;
34
36
37 public:
38 SharedMemory(const string& name, size_t size, resource_type_t type);
39 ~SharedMemory() final;
40
41 void open(size_t flags) final;
42 void close(size_t flags) final;
43
44 int read(void* buffer, size_t size, size_t flags) final;
45
46 [[nodiscard]] uintptr_t physical_address() const;
47 [[nodiscard]] size_t size() const;
48 };
49
54 class SharedMessageEndpoint final : public Resource {
55
56 private:
58 common::Spinlock m_message_lock;
59
60 public:
61 SharedMessageEndpoint(const string& name, size_t size, resource_type_t type);
63
64 int read(void* buffer, size_t size, size_t flags) final;
65 int write(const void* buffer, size_t size, size_t flags) final;
66 };
67}
68
69
70#endif // MAXOS_PROCESSES_IPC_H
Defines a Buffer class for safe memory operations.
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
Enables a resource to be used by only one instance at a time through locking and unlocking.
Definition spinlock.h:21
Represents a generic resource that can be opened, closed, read from and written to.
Definition resource.h:29
string name()
Gets the name of this resource.
Definition resource.cpp:79
resource_type_t type()
Gets the type of this resource.
Definition resource.cpp:88
A block memory that is mapped into multiple processes.
Definition ipc.h:29
size_t size() const
Gets the size of the shared memory block.
Definition ipc.cpp:72
int read(void *buffer, size_t size, size_t flags) final
Get the address that the current process has this shared memory mapped to.
Definition ipc.cpp:47
void close(size_t flags) final
Frees the page containing the shared memory.
Definition ipc.cpp:99
uintptr_t physical_address() const
Gets the physical address of the shared memory block.
Definition ipc.cpp:62
void open(size_t flags) final
Map the shared memory into the address space of the owning process.
Definition ipc.cpp:82
A endpoint that allows processes to queue messages on.
Definition ipc.h:54
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.
Definition ipc.cpp:158
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.
Definition ipc.cpp:136
~SharedMessageEndpoint() final
Destroys the shared message endpoint and frees all messages.
Definition ipc.cpp:121
Defines classes for memory input and output operations of various bit widths (8, 16,...
Defines a PhysicalMemoryManager class for managing physical memory allocation and deallocation of pag...
Defines classes for managing process resources such as files and devices.
::syscore::ResourceType resource_type_t
Alias to make the libsyscore ResourceType accessible here.
Definition resource.h:22
Defines Spinlock and BlockingLock classes for thread synchronization.
Defines a String class for dynamically sized strings with various operations.
Defines a Vector class for dynamically storing an array of elements.