diff --git a/src/internal.cpp b/src/internal.cpp index 82b515a..a6c5937 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -37,8 +37,11 @@ namespace vkvm { auto callEvent(EventType type) -> bool { auto ivt = getInterrupTable(); - if (ivt[type].pid != 0) { - sendSignal(ivt[type].pid, ivt[type].signum); + for(int i = 0; i < impl.interruptEntrysPerEventType;i++){ + auto &entry= ivt[type * impl.interruptEntrysPerEventType + i]; + if (entry.pid != 0) { + sendSignal(entry.pid, entry.signum); + } } return true; } diff --git a/src/internal.hpp b/src/internal.hpp index d237f92..a2fe49f 100644 --- a/src/internal.hpp +++ b/src/internal.hpp @@ -54,7 +54,8 @@ constexpr int keyboardBufferSize = 16; int sharedMemoryPid; key_t sharedMemoryKey; int sharedMemorySize; - int interruptEntyCount = 64; //NOLINT + int interruptEntyCount = 256; //NOLINT + int interruptEntrysPerEventType = 8; int reservedSize = 1024; //NOLINT std::vector> eventTable; }; diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 3493667..57cf76e 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -37,21 +37,27 @@ namespace vkvm { lockSharedMemory(); - ivt[type].pid = getpid(); - ivt[type].signum = signum; - impl.eventTable.push_back(handler); + for(int i = 0; i < impl.interruptEntrysPerEventType;i++){ + auto &entry= ivt[type * impl.interruptEntrysPerEventType + i]; + if (entry.pid == 0) { - onSignal(signum, [](int sig){ - if(sig >= SIGUSR1){ - if((sig - SIGUSR1) < impl.eventTable.size()){ - impl.eventTable[sig - SIGUSR1](); - } + entry.pid = getpid(); + entry.signum = signum; + impl.eventTable.push_back(handler); + + onSignal(signum, [](int sig){ + if(sig >= SIGUSR1){ + if((sig - SIGUSR1) < impl.eventTable.size()){ + impl.eventTable[sig - SIGUSR1](); + } + } + }); + unlockSharedMemory(); + return true; } - }); - + } unlockSharedMemory(); - - return true; + return false; } auto setPixel(int x, int y, Color color) -> bool {