]> sourceware.org Git - newlib-cygwin.git/commitdiff
* miscfuncs.cc (low_priority_sleep): New function. Use throughout where code
authorChristopher Faylor <me@cgf.cx>
Wed, 13 Nov 2002 19:36:12 +0000 (19:36 +0000)
committerChristopher Faylor <me@cgf.cx>
Wed, 13 Nov 2002 19:36:12 +0000 (19:36 +0000)
is supposed to be giving up time slice.
* fhandler_console.cc (fhandler_console::read): Switch button 2/3 output escape
sequences to be consistent with xterm.

13 files changed:
winsup/cygwin/ChangeLog
winsup/cygwin/autoload.cc
winsup/cygwin/cygthread.cc
winsup/cygwin/exceptions.cc
winsup/cygwin/fhandler_console.cc
winsup/cygwin/fhandler_serial.cc
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/miscfuncs.cc
winsup/cygwin/pinfo.cc
winsup/cygwin/sched.cc
winsup/cygwin/sigproc.cc
winsup/cygwin/thread.cc
winsup/cygwin/tty.cc

index b35da5cbaf439d41e6a7596bdf226ac7e0215039..b36bd80737e8dfdfc7261ba39c8b942f0007ad0b 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-13  Christopher Faylor  <cgf@redhat.com>
+
+       * miscfuncs.cc (low_priority_sleep): New function.  Use throughout
+       where code is supposed to be giving up time slice.
+
+       * fhandler_console.cc (fhandler_console::read): Switch button 2/3
+       output escape sequences to be consistent with xterm.
+
 2002-11-12  Pierre Humblet <pierre.humblet@ieee.org>
 
        * syscalls.cc (chmod): Simplify conditional.
index 0b66278f68e978cb042936cb8615332989116fd0..5210623a0b077266ab136a98b0482685625295b4 100644 (file)
@@ -214,7 +214,7 @@ std_dll_init ()
     do
       {
        InterlockedDecrement (&dll->here);
-       Sleep (0);
+       low_priority_sleep (0);
       }
     while (InterlockedIncrement (&dll->here));
   else if (!dll->handle)
@@ -263,7 +263,7 @@ wsock_init ()
   while (InterlockedIncrement (&here))
     {
       InterlockedDecrement (&here);
-      Sleep (0);
+      low_priority_sleep (0);
     }
 
   if (!wsock_started && (winsock_active || winsock2_active))
index 70225f0cf02cf43209bec7fb1656920c5bdea8b7..27e7f944260750b3c14e07211a578b1f8cd8da95 100644 (file)
@@ -170,11 +170,11 @@ cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param,
   thread_printf ("name %s, id %p", name, id);
   while (!h)
 #ifndef DEBUGGING
-    Sleep (0);
+    low_priority_sleep (0);
 #else
     {
       thread_printf ("waiting for %s<%p> to become active", __name, h);
-      Sleep (0);
+      low_priority_sleep (0);
     }
 #endif
   __name = name;
@@ -217,7 +217,7 @@ cygthread::operator
 HANDLE ()
 {
   while (!ev)
-    Sleep (0);
+    low_priority_sleep (0);
   return ev;
 }
 
index 4e18e2791bdb04856d9fe980d7bfd7379bb32180..05f285b2e739f85c08e32648aad1a8ab3e85a68d 100644 (file)
@@ -666,7 +666,7 @@ sigthread::get_winapi_lock (int test)
   /* Need to do a busy loop because we can't block or a potential SuspendThread
      will hang. */
   while (InterlockedExchange (&winapi_lock, 1))
-    Sleep (1);
+    low_priority_sleep (1);
   return 1;
 }
 
@@ -855,7 +855,7 @@ setup_handler (int sig, void *handler, struct sigaction& siga)
 
        resume_thread:
          ResumeThread (hth);
-         Sleep (0);
+         low_priority_sleep (0);
          continue;
        }
 
@@ -879,7 +879,7 @@ setup_handler (int sig, void *handler, struct sigaction& siga)
       pending_signals = 1;     /* FIXME: Probably need to be more tricky here */
       sig_set_pending (sig);
       sig_dispatch_pending (1);
-      Sleep (0);               /* Hopefully, other process will be waking up soon. */
+      low_priority_sleep (0);  /* Hopefully, other process will be waking up soon. */
       sigproc_printf ("couldn't send signal %d", sig);
     }
 
index 5be009eb926a1281eef3ef242ba0e2e735382a8a..80ea71a43c5350aa5274ea9287f12701373d37fa 100644 (file)
@@ -412,12 +412,12 @@ fhandler_console::read (void *pv, size_t buflen)
                }
              else if ((mouse_event.dwButtonState & 2) != (dev_state->dwLastButtonState & 2))
                {
-                 b = 1;
+                 b = 2;
                  strcpy (sz, "btn2 down");
                }
              else if ((mouse_event.dwButtonState & 4) != (dev_state->dwLastButtonState & 4))
                {
-                 b = 2;
+                 b = 1;
                  strcpy (sz, "btn3 down");
                }
 
index fd7abb808e0c29322c9bd1e9ee0faec974a5a359..3c951801bc699bceca4f125809787da1468bfeaf 100644 (file)
@@ -508,7 +508,7 @@ fhandler_serial::tcflush (int queue)
        COMSTAT st;
        if (!PurgeComm (get_handle (), PURGE_RXABORT | PURGE_RXCLEAR))
          break;
-       Sleep (100);
+       low_priority_sleep (100);
        if (!ClearCommError (get_handle (), &ev, &st) || !st.cbInQue)
          break;
       }
index ed109277694bc1ce799d88bc0c901adc7f1be50e..82dae85eda2fc19f0b68ffe1974c98c5c9b925e9 100644 (file)
@@ -175,7 +175,7 @@ fhandler_pty_master::accept_input ()
              debug_printf ("to_slave pipe is full");
              SetEvent (input_available_event);
              ReleaseMutex (input_mutex);
-             Sleep (10);
+             low_priority_sleep (10);
              rc = WaitForSingleObject (input_mutex, INFINITE);
            }
        }
@@ -279,7 +279,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
                  break;
                }
 
-             Sleep (10);
+             low_priority_sleep (10);
            }
 
          if (ReadFile (handle, outbuf, rlen, &n, NULL) == FALSE)
index fd7ae8edf78b2a169957392f797f1db129406f71..36a3d9332c68d8723080444b115f857bfebad9f8 100644 (file)
@@ -291,3 +291,12 @@ sys_mbstowcs (WCHAR *tgt, const char *src, int len)
 {
   return MultiByteToWideChar (get_cp (), 0, src, -1, tgt, len);
 }
+
+void __stdcall
+low_priority_sleep (DWORD secs)
+{
+  DWORD prio = GetThreadPriority (GetCurrentThread ());
+  SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
+  Sleep (secs);
+  SetThreadPriority (GetCurrentThread (), prio);
+}
index d4764bceda77ea9237421ac26527edf5a5b921cd..6feea6444200f39c4e0670187a2e90a73e1fa9bb 100644 (file)
@@ -212,7 +212,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h)
           this way at some point.  */
       if (i < 9 && !created && createit && (procinfo->process_state & PID_EXITED))
        {
-         Sleep (5);
+         low_priority_sleep (5);
          release ();
          continue;
        }
@@ -368,12 +368,7 @@ _pinfo::commune_send (DWORD code)
     if (myself->hello_pid <= 0)
       break;
     else
-      {
-       DWORD prio = GetThreadPriority (GetCurrentThread ());
-       SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
-       Sleep (0);
-       SetThreadPriority (GetCurrentThread (), prio);
-      }
+      low_priority_sleep (0);
 
   CloseHandle (tome);
   tome = NULL;
index 185530210f8f7e89be0849ca546f722ae2dfdbf2..99c73914db2aee002f4d5a2dd1a1a5c69a98e80f 100644 (file)
@@ -438,7 +438,7 @@ sched_setscheduler (pid_t pid, int policy,
 int
 sched_yield (void)
 {
-  Sleep (0);
+  low_priority_sleep (0);
   return 0;
 }
 }
index 8af76e1383b884e7ad2aefcef4f07565bf20f8e7..af59a67ff6f0b22e423ccbf2b60561cb91c479d0 100644 (file)
@@ -886,7 +886,7 @@ getsem (_pinfo *p, const char *str, int init, int max)
       sigproc_printf ("pid %d, ppid %d, wait %d, initializing %x", p->pid, p->ppid, wait,
                  ISSTATE (p, PID_INITIALIZING));
       for (int i = 0; ISSTATE (p, PID_INITIALIZING) && i < wait; i++)
-       Sleep (1);
+       low_priority_sleep (1);
     }
 
   SetLastError (0);
index 115df453eeed0fa6c9ef5840260a3e5f8124e5e9..e2fc0affde3a43e7b4d413c939b1b16d548d8604 100644 (file)
@@ -862,7 +862,7 @@ pthread_cond::Signal ()
     {
       InterlockedIncrement (&ExitingWait);
       /* give up the cpu to force a context switch. */
-      Sleep (0);
+      low_priority_sleep (0);
       if (spins == 5)
        /* we've had 5 timeslices, and the woken thread still hasn't done it's
         * thing - maybe we raced it with the event? */
index 9a295244f3f700f9686f80a1dd5e453e7b343294..0e3e14a529ba016005cab55ba0a3b5d47b1866a7 100644 (file)
@@ -138,7 +138,7 @@ tty_list::terminate (void)
              i = 0;
            }
 
-         Sleep (200);
+         low_priority_sleep (200);
        }
 
       termios_printf ("tty %d master about to finish", ttynum);
@@ -218,12 +218,12 @@ tty_list::allocate_tty (int with_console)
       SetConsoleTitle (buf);
       for (int times = 0; times < 25; times++)
        {
-         Sleep (10);
+         low_priority_sleep (10);
          if ((console = FindWindow (NULL, buf)))
            break;
        }
       SetConsoleTitle (oldtitle);
-      Sleep (40);
+      low_priority_sleep (40);
       ReleaseMutex (title_mutex);
       if (console == NULL)
        {
This page took 0.04914 seconds and 5 git commands to generate.