From a2ec09bc205ecbf746f9cc245054c24c50b6832a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 16 Jan 2019 17:47:18 +0100 Subject: [PATCH] Allow the scheduler to unblock the current process. It's a bit confusing that the "current" process is not actually running while we're inside the scheduler. Perhaps the scheduler should redirect "current" to its own dummy Process. I'm not sure. Regardless, this patch improves responsiveness by allowing the scheduler to unblock a process right after it calls select() in case it already has a pending wakeup request. --- Kernel/.bochsrc | 2 +- Kernel/Process.cpp | 3 ++- WindowServer/WSWindowManager.cpp | 14 ++++++++++++-- WindowServer/WSWindowManager.h | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Kernel/.bochsrc b/Kernel/.bochsrc index a061866f39..a06fedbe30 100644 --- a/Kernel/.bochsrc +++ b/Kernel/.bochsrc @@ -26,7 +26,7 @@ optramimage2: file=none optramimage3: file=none optramimage4: file=none pci: enabled=1, chipset=i440fx -vga: extension=vbe, update_freq=25, realtime=1 +vga: extension=vbe, update_freq=60, realtime=0 cpu: count=1, ips=4000000, model=bx_generic, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0 cpuid: level=6, stepping=3, model=3, family=6, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU " cpuid: mmx=true, apic=xapic, simd=sse2, sse4a=false, misaligned_sse=false, sep=true diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 8939fa6b35..0a24ebebfa 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1551,7 +1551,8 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options) void Process::unblock() { if (current == this) { - kprintf("ignoring unblock() on current, %s(%u) {%s}\n", name().characters(), pid(), toString(state())); + system.nblocked--; + m_state = Process::Running; return; } ASSERT(m_state != Process::Runnable && m_state != Process::Running); diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp index 710eefea55..1f0162e20b 100644 --- a/WindowServer/WSWindowManager.cpp +++ b/WindowServer/WSWindowManager.cpp @@ -10,6 +10,7 @@ #include //#define DEBUG_FLUSH_YELLOW +//#define DEBUG_COUNTERS static const int windowTitleBarHeight = 16; @@ -109,6 +110,10 @@ WSWindowManager::WSWindowManager() : m_framebuffer(WSFrameBuffer::the()) , m_screen_rect(m_framebuffer.rect()) { +#ifndef DEBUG_COUNTERS + (void)m_recompose_count; + (void)m_flush_count; +#endif auto size = m_screen_rect.size(); m_front_bitmap = GraphicsBitmap::create_wrapper(size, m_framebuffer.scanline(0)); auto* region = current->allocate_region(LinearAddress(), size.width() * size.height() * sizeof(RGBA32), "BackBitmap", true, true, true); @@ -266,9 +271,10 @@ void WSWindowManager::processMouseEvent(MouseEvent& event) void WSWindowManager::compose() { auto invalidated_rects = move(m_invalidated_rects); - printf("[WM] compose #%u (%u rects)\n", ++m_recompose_count, invalidated_rects.size()); - +#ifdef DEBUG_COUNTERS + dbgprintf("[WM] compose #%u (%u rects)\n", ++m_recompose_count, invalidated_rects.size()); dbgprintf("kmalloc stats: alloc:%u free:%u eternal:%u\n", sum_alloc, sum_free, kmalloc_sum_eternal); +#endif auto any_window_contains_rect = [this] (const Rect& r) { for (auto* window = m_windows_in_order.head(); window; window = window->next()) { @@ -387,6 +393,10 @@ void WSWindowManager::flush(const Rect& a_rect) { auto rect = Rect::intersection(a_rect, m_screen_rect); +#ifdef DEBUG_COUNTERS + dbgprintf("[WM] flush #%u (%d,%d %dx%d)\n", ++m_flush_count, rect.x(), rect.y(), rect.width(), rect.height()); +#endif + RGBA32* front_ptr = m_front_bitmap->scanline(rect.y()) + rect.x(); const RGBA32* back_ptr = m_back_bitmap->scanline(rect.y()) + rect.x(); size_t pitch = m_back_bitmap->pitch(); diff --git a/WindowServer/WSWindowManager.h b/WindowServer/WSWindowManager.h index b6bf211ac2..58be90b8d6 100644 --- a/WindowServer/WSWindowManager.h +++ b/WindowServer/WSWindowManager.h @@ -77,6 +77,7 @@ private: Rect m_last_cursor_rect; unsigned m_recompose_count { 0 }; + unsigned m_flush_count { 0 }; RetainPtr m_front_bitmap; RetainPtr m_back_bitmap;