Forráskód Böngészése

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.
Andreas Kling 6 éve
szülő
commit
a2ec09bc20

+ 1 - 1
Kernel/.bochsrc

@@ -26,7 +26,7 @@ optramimage2: file=none
 optramimage3: file=none
 optramimage3: file=none
 optramimage4: file=none
 optramimage4: file=none
 pci: enabled=1, chipset=i440fx
 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
 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: 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
 cpuid: mmx=true, apic=xapic, simd=sse2, sse4a=false, misaligned_sse=false, sep=true

+ 2 - 1
Kernel/Process.cpp

@@ -1551,7 +1551,8 @@ pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
 void Process::unblock()
 void Process::unblock()
 {
 {
     if (current == this) {
     if (current == this) {
-        kprintf("ignoring unblock() on current, %s(%u) {%s}\n", name().characters(), pid(), toString(state()));
+        system.nblocked--;
+        m_state = Process::Running;
         return;
         return;
     }
     }
     ASSERT(m_state != Process::Runnable && m_state != Process::Running);
     ASSERT(m_state != Process::Runnable && m_state != Process::Running);

+ 12 - 2
WindowServer/WSWindowManager.cpp

@@ -10,6 +10,7 @@
 #include <AK/StdLibExtras.h>
 #include <AK/StdLibExtras.h>
 
 
 //#define DEBUG_FLUSH_YELLOW
 //#define DEBUG_FLUSH_YELLOW
+//#define DEBUG_COUNTERS
 
 
 static const int windowTitleBarHeight = 16;
 static const int windowTitleBarHeight = 16;
 
 
@@ -109,6 +110,10 @@ WSWindowManager::WSWindowManager()
     : m_framebuffer(WSFrameBuffer::the())
     : m_framebuffer(WSFrameBuffer::the())
     , m_screen_rect(m_framebuffer.rect())
     , m_screen_rect(m_framebuffer.rect())
 {
 {
+#ifndef DEBUG_COUNTERS
+    (void)m_recompose_count;
+    (void)m_flush_count;
+#endif
     auto size = m_screen_rect.size();
     auto size = m_screen_rect.size();
     m_front_bitmap = GraphicsBitmap::create_wrapper(size, m_framebuffer.scanline(0));
     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);
     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()
 void WSWindowManager::compose()
 {
 {
     auto invalidated_rects = move(m_invalidated_rects);
     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);
     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) {
     auto any_window_contains_rect = [this] (const Rect& r) {
         for (auto* window = m_windows_in_order.head(); window; window = window->next()) {
         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);
     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();
     RGBA32* front_ptr = m_front_bitmap->scanline(rect.y()) + rect.x();
     const RGBA32* back_ptr = m_back_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();
     size_t pitch = m_back_bitmap->pitch();

+ 1 - 0
WindowServer/WSWindowManager.h

@@ -77,6 +77,7 @@ private:
     Rect m_last_cursor_rect;
     Rect m_last_cursor_rect;
 
 
     unsigned m_recompose_count { 0 };
     unsigned m_recompose_count { 0 };
+    unsigned m_flush_count { 0 };
 
 
     RetainPtr<GraphicsBitmap> m_front_bitmap;
     RetainPtr<GraphicsBitmap> m_front_bitmap;
     RetainPtr<GraphicsBitmap> m_back_bitmap;
     RetainPtr<GraphicsBitmap> m_back_bitmap;