some fixes for ipc

This commit is contained in:
2026-02-24 22:42:41 +01:00
parent e3452cf051
commit a35cc22990
2 changed files with 20 additions and 13 deletions

View File

@@ -303,7 +303,7 @@ bool copy_from_phys(Vault& vault, uintptr_t phys_ptr, void* virt_ptr, size_t siz
} }
memcpy(virt_ptr, (void*)((uintptr_t)(virt_addr)+ (uintptr_t)offset), size); memcpy(virt_ptr, (void*)((uintptr_t)(virt_addr)+ (uintptr_t)offset), size);
PageFrameAllocator::free((uintptr_t)(virt_addr)); setMapping((uintptr_t)(virt_addr), 0, search_table);
return true; return true;
} }
@@ -357,8 +357,9 @@ int receive(Vault& v, void* buffer, size_t size) {
IpcStruct* ipc = thread->ipc_queue.first(); IpcStruct* ipc = thread->ipc_queue.first();
if (ipc == nullptr) return -1; if (ipc == nullptr) return -1;
size_t copy_len = (size < ipc->size) ? size:ipc->size;
// Buffer holen // Buffer holen
if (!copy_from_phys(v, ipc->ptr, buffer, size)) { if (!copy_from_phys(v, ipc->ptr, buffer, copy_len)) {
return -3; return -3;
} }
@@ -370,6 +371,10 @@ bool reply(Vault& v, const void* buffer, size_t size) {
Thread* current_thread = v.scheduler.active(); Thread* current_thread = v.scheduler.active();
IpcStruct* ipc = current_thread->ipc_queue.dequeue(); IpcStruct* ipc = current_thread->ipc_queue.dequeue();
//noting to reply to
if(!ipc)
return false;
// if (!ipc || ipc->pid < 0 || static_cast<size_t>(ipc->pid) >= v.thread_count) return false; // if (!ipc || ipc->pid < 0 || static_cast<size_t>(ipc->pid) >= v.thread_count) return false;
Thread* other_thread = v.thread_list[ipc->pid]; Thread* other_thread = v.thread_list[ipc->pid];

View File

@@ -53,6 +53,7 @@ extern "C" void main() {
uint8_t cnt = 0; uint8_t cnt = 0;
for (unsigned i = 1;; ++i) { for (unsigned i = 1;; ++i) {
if(i%10 == 0){
if(id == 2){ if(id == 2){
send(4, text, strlen(text), text, 5); send(4, text, strlen(text), text, 5);
write(1, text, strlen(text), 25, (int)id); write(1, text, strlen(text), 25, (int)id);
@@ -63,6 +64,7 @@ extern "C" void main() {
write(1, blubb, strlen(blubb), 25, (int)id); write(1, blubb, strlen(blubb), 25, (int)id);
reply("toast", 5); reply("toast", 5);
} }
}
//counter to see app running //counter to see app running
cnt=(cnt+1)%100; cnt=(cnt+1)%100;