feat(ipc): implement synchronous Rendezvous IPC and multi-thread cooperative scheduler

This commit is contained in:
RarDog
2026-09-02 16:52:03 +03:00
parent 6cbd13b4aa
commit 448b0e710e
11 changed files with 712 additions and 97 deletions
+38 -1
View File
@@ -24,6 +24,13 @@ struct FastResponse {
uint64_t out1;
};
struct IncomingRequest {
uint64_t sender_tid;
uint64_t opcode;
uint64_t arg0;
uint64_t arg1;
};
// RAII Capability Handle
class Capability {
private:
@@ -56,7 +63,7 @@ public:
[[nodiscard]] constexpr bool is_valid() const noexcept { return handle_ != CAP_NULL; }
};
// RAII IPC Endpoint Wrapper
// RAII IPC Client Endpoint Wrapper
class Endpoint {
private:
Capability cap_;
@@ -82,6 +89,36 @@ public:
[[nodiscard]] cap_t raw_handle() const noexcept { return cap_.get(); }
};
// RAII IPC Server Endpoint Wrapper
class ServerEndpoint {
private:
Capability cap_;
public:
explicit ServerEndpoint(Capability&& cap) noexcept : cap_(static_cast<Capability&&>(cap)) {}
explicit ServerEndpoint(cap_t cap) noexcept : cap_(cap) {}
// Server main loop: Reply to previous sender and wait for next request
[[nodiscard]] Result<IncomingRequest> reply_and_recv(
uint64_t reply_to_tid = 0,
uint64_t reply_val0 = 0,
uint64_t reply_val1 = 0
) const noexcept {
uint64_t sender_tid = 0;
uint64_t opcode = 0;
uint64_t arg0 = 0;
uint64_t arg1 = 0;
sysret_t ret = sys_ipc_reply_recv_raw(cap_.get(), reply_to_tid, reply_val0, reply_val1,
&sender_tid, &opcode, &arg0, &arg1);
return Result<IncomingRequest>{
.status = ret,
.value = { sender_tid, opcode, arg0, arg1 }
};
}
[[nodiscard]] cap_t raw_handle() const noexcept { return cap_.get(); }
};
// RAII Shared Memory Buffer
class SharedBuffer {
private: