diff options
Diffstat (limited to 'Source/Kernel/VTManager')
-rw-r--r-- | Source/Kernel/VTManager/PipeVT.class.cpp | 9 | ||||
-rw-r--r-- | Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp | 24 | ||||
-rw-r--r-- | Source/Kernel/VTManager/VirtualTerminal.proto.cpp | 4 | ||||
-rw-r--r-- | Source/Kernel/VTManager/VirtualTerminal.proto.h | 7 |
4 files changed, 25 insertions, 19 deletions
diff --git a/Source/Kernel/VTManager/PipeVT.class.cpp b/Source/Kernel/VTManager/PipeVT.class.cpp index 7e67161..f4a5ca9 100644 --- a/Source/Kernel/VTManager/PipeVT.class.cpp +++ b/Source/Kernel/VTManager/PipeVT.class.cpp @@ -1,4 +1,5 @@ #include "PipeVT.class.h" +#include <TaskManager/Task.ns.h> PipeVT::PipeVT() { m_col = 0; @@ -29,7 +30,9 @@ void PipeVT::put(WChar c, bool updatecsr) { kp.character = c; m_col++; } - m_kbdbuffMutex.waitLock(); - m_kbdbuff.push(kp); - m_kbdbuffMutex.unlock(); + while (m_kbdbuffEnd == m_kbdbuffStart - 1 or (m_kbdbuffEnd == KBDBUFFSIZE - 1 and m_kbdbuffStart == 0)) + Task::currThread()->sleep(10); + m_kbdbuff[m_kbdbuffEnd] = kp; + m_kbdbuffEnd++; + if (m_kbdbuffEnd == KBDBUFFSIZE) m_kbdbuffEnd = 0; } diff --git a/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp index 9f3e349..5b551eb 100644 --- a/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp +++ b/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp @@ -4,8 +4,10 @@ using namespace Kbd; void VirtualTerminal::keyPress(keypress_t kp) { - m_kbdbuffMutex.waitLock(); - m_kbdbuff.push(kp); + if (m_kbdbuffEnd == m_kbdbuffStart - 1 or (m_kbdbuffEnd == KBDBUFFSIZE - 1 and m_kbdbuffStart == 0)) return; + m_kbdbuff[m_kbdbuffEnd] = kp; + m_kbdbuffEnd++; + if (m_kbdbuffEnd == KBDBUFFSIZE) m_kbdbuffEnd = 0; if (!m_kbdMutex.locked()) { if (kp.haschar && !kp.hascmd) { put(kp.character); @@ -17,29 +19,26 @@ void VirtualTerminal::keyPress(keypress_t kp) { put("\b"); } } - m_kbdbuffMutex.unlock(); } keypress_t VirtualTerminal::getKeypress(bool show, bool block) { m_kbdMutex.waitLock(); - if (m_kbdbuff.empty() && !block) { + if (m_kbdbuffStart == m_kbdbuffEnd && !block) { m_kbdMutex.unlock(); return keypress_t(); } - while (m_kbdbuff.empty()) { + while (m_kbdbuffStart == m_kbdbuffEnd) { Task::currThread()->sleep(10); } - m_kbdbuffMutex.waitLock(); - keypress_t ret = m_kbdbuff[0]; + keypress_t ret = m_kbdbuff[m_kbdbuffStart]; - for (u32int i = 1; i < m_kbdbuff.size(); i++) { - m_kbdbuff[i - 1] = m_kbdbuff[i]; - } - m_kbdbuff.pop(); - m_kbdbuffMutex.unlock(); + m_kbdbuffStart++; + if (m_kbdbuffStart == KBDBUFFSIZE) m_kbdbuffStart = 0; + + m_kbdMutex.unlock(); if (show) { if (ret.haschar && !ret.hascmd) { @@ -53,7 +52,6 @@ keypress_t VirtualTerminal::getKeypress(bool show, bool block) { } } - m_kbdMutex.unlock(); return ret; } diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp index 0079707..34c10d0 100644 --- a/Source/Kernel/VTManager/VirtualTerminal.proto.cpp +++ b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp @@ -6,7 +6,9 @@ #include <VirtualTerminal.iface.h> VirtualTerminal::VirtualTerminal() : - Ressource(VTIF_OBJTYPE, m_callTable), m_kbdMutex(false), m_kbdbuffMutex(false), m_kbdbuff() { + Ressource(VTIF_OBJTYPE, m_callTable), m_kbdMutex(false), m_kbdbuff() { + m_kbdbuffStart = 0; + m_kbdbuffEnd = 0; } VirtualTerminal::~VirtualTerminal() { diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.h b/Source/Kernel/VTManager/VirtualTerminal.proto.h index 5f874b4..ceb994c 100644 --- a/Source/Kernel/VTManager/VirtualTerminal.proto.h +++ b/Source/Kernel/VTManager/VirtualTerminal.proto.h @@ -14,10 +14,13 @@ struct vtchr { WChar c; }; +#define KBDBUFFSIZE 10 + class VirtualTerminal : public Ressource { protected: - Mutex m_kbdMutex, m_kbdbuffMutex; - Vector<keypress_t> m_kbdbuff; //Key press events buffer + Mutex m_kbdMutex; + keypress_t m_kbdbuff[KBDBUFFSIZE]; //Key press events buffer + int m_kbdbuffStart, m_kbdbuffEnd; //SYSCALLS : static call_t m_callTable[]; |