* 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.
This commit is contained in:
parent
e91ec2e3e6
commit
c0a02a4b42
|
@ -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>
|
2002-11-12 Pierre Humblet <pierre.humblet@ieee.org>
|
||||||
|
|
||||||
* syscalls.cc (chmod): Simplify conditional.
|
* syscalls.cc (chmod): Simplify conditional.
|
||||||
|
|
|
@ -214,7 +214,7 @@ std_dll_init ()
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
InterlockedDecrement (&dll->here);
|
InterlockedDecrement (&dll->here);
|
||||||
Sleep (0);
|
low_priority_sleep (0);
|
||||||
}
|
}
|
||||||
while (InterlockedIncrement (&dll->here));
|
while (InterlockedIncrement (&dll->here));
|
||||||
else if (!dll->handle)
|
else if (!dll->handle)
|
||||||
|
@ -263,7 +263,7 @@ wsock_init ()
|
||||||
while (InterlockedIncrement (&here))
|
while (InterlockedIncrement (&here))
|
||||||
{
|
{
|
||||||
InterlockedDecrement (&here);
|
InterlockedDecrement (&here);
|
||||||
Sleep (0);
|
low_priority_sleep (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wsock_started && (winsock_active || winsock2_active))
|
if (!wsock_started && (winsock_active || winsock2_active))
|
||||||
|
|
|
@ -170,11 +170,11 @@ cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param,
|
||||||
thread_printf ("name %s, id %p", name, id);
|
thread_printf ("name %s, id %p", name, id);
|
||||||
while (!h)
|
while (!h)
|
||||||
#ifndef DEBUGGING
|
#ifndef DEBUGGING
|
||||||
Sleep (0);
|
low_priority_sleep (0);
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
thread_printf ("waiting for %s<%p> to become active", __name, h);
|
thread_printf ("waiting for %s<%p> to become active", __name, h);
|
||||||
Sleep (0);
|
low_priority_sleep (0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
__name = name;
|
__name = name;
|
||||||
|
@ -217,7 +217,7 @@ cygthread::operator
|
||||||
HANDLE ()
|
HANDLE ()
|
||||||
{
|
{
|
||||||
while (!ev)
|
while (!ev)
|
||||||
Sleep (0);
|
low_priority_sleep (0);
|
||||||
return ev;
|
return ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
/* Need to do a busy loop because we can't block or a potential SuspendThread
|
||||||
will hang. */
|
will hang. */
|
||||||
while (InterlockedExchange (&winapi_lock, 1))
|
while (InterlockedExchange (&winapi_lock, 1))
|
||||||
Sleep (1);
|
low_priority_sleep (1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,7 +855,7 @@ setup_handler (int sig, void *handler, struct sigaction& siga)
|
||||||
|
|
||||||
resume_thread:
|
resume_thread:
|
||||||
ResumeThread (hth);
|
ResumeThread (hth);
|
||||||
Sleep (0);
|
low_priority_sleep (0);
|
||||||
continue;
|
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 */
|
pending_signals = 1; /* FIXME: Probably need to be more tricky here */
|
||||||
sig_set_pending (sig);
|
sig_set_pending (sig);
|
||||||
sig_dispatch_pending (1);
|
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);
|
sigproc_printf ("couldn't send signal %d", sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,12 +412,12 @@ fhandler_console::read (void *pv, size_t buflen)
|
||||||
}
|
}
|
||||||
else if ((mouse_event.dwButtonState & 2) != (dev_state->dwLastButtonState & 2))
|
else if ((mouse_event.dwButtonState & 2) != (dev_state->dwLastButtonState & 2))
|
||||||
{
|
{
|
||||||
b = 1;
|
b = 2;
|
||||||
strcpy (sz, "btn2 down");
|
strcpy (sz, "btn2 down");
|
||||||
}
|
}
|
||||||
else if ((mouse_event.dwButtonState & 4) != (dev_state->dwLastButtonState & 4))
|
else if ((mouse_event.dwButtonState & 4) != (dev_state->dwLastButtonState & 4))
|
||||||
{
|
{
|
||||||
b = 2;
|
b = 1;
|
||||||
strcpy (sz, "btn3 down");
|
strcpy (sz, "btn3 down");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,7 @@ fhandler_serial::tcflush (int queue)
|
||||||
COMSTAT st;
|
COMSTAT st;
|
||||||
if (!PurgeComm (get_handle (), PURGE_RXABORT | PURGE_RXCLEAR))
|
if (!PurgeComm (get_handle (), PURGE_RXABORT | PURGE_RXCLEAR))
|
||||||
break;
|
break;
|
||||||
Sleep (100);
|
low_priority_sleep (100);
|
||||||
if (!ClearCommError (get_handle (), &ev, &st) || !st.cbInQue)
|
if (!ClearCommError (get_handle (), &ev, &st) || !st.cbInQue)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ fhandler_pty_master::accept_input ()
|
||||||
debug_printf ("to_slave pipe is full");
|
debug_printf ("to_slave pipe is full");
|
||||||
SetEvent (input_available_event);
|
SetEvent (input_available_event);
|
||||||
ReleaseMutex (input_mutex);
|
ReleaseMutex (input_mutex);
|
||||||
Sleep (10);
|
low_priority_sleep (10);
|
||||||
rc = WaitForSingleObject (input_mutex, INFINITE);
|
rc = WaitForSingleObject (input_mutex, INFINITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sleep (10);
|
low_priority_sleep (10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReadFile (handle, outbuf, rlen, &n, NULL) == FALSE)
|
if (ReadFile (handle, outbuf, rlen, &n, NULL) == FALSE)
|
||||||
|
|
|
@ -291,3 +291,12 @@ sys_mbstowcs (WCHAR *tgt, const char *src, int len)
|
||||||
{
|
{
|
||||||
return MultiByteToWideChar (get_cp (), 0, src, -1, tgt, 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);
|
||||||
|
}
|
||||||
|
|
|
@ -212,7 +212,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h)
|
||||||
this way at some point. */
|
this way at some point. */
|
||||||
if (i < 9 && !created && createit && (procinfo->process_state & PID_EXITED))
|
if (i < 9 && !created && createit && (procinfo->process_state & PID_EXITED))
|
||||||
{
|
{
|
||||||
Sleep (5);
|
low_priority_sleep (5);
|
||||||
release ();
|
release ();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -368,12 +368,7 @@ _pinfo::commune_send (DWORD code)
|
||||||
if (myself->hello_pid <= 0)
|
if (myself->hello_pid <= 0)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
{
|
low_priority_sleep (0);
|
||||||
DWORD prio = GetThreadPriority (GetCurrentThread ());
|
|
||||||
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
|
|
||||||
Sleep (0);
|
|
||||||
SetThreadPriority (GetCurrentThread (), prio);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle (tome);
|
CloseHandle (tome);
|
||||||
tome = NULL;
|
tome = NULL;
|
||||||
|
|
|
@ -438,7 +438,7 @@ sched_setscheduler (pid_t pid, int policy,
|
||||||
int
|
int
|
||||||
sched_yield (void)
|
sched_yield (void)
|
||||||
{
|
{
|
||||||
Sleep (0);
|
low_priority_sleep (0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
sigproc_printf ("pid %d, ppid %d, wait %d, initializing %x", p->pid, p->ppid, wait,
|
||||||
ISSTATE (p, PID_INITIALIZING));
|
ISSTATE (p, PID_INITIALIZING));
|
||||||
for (int i = 0; ISSTATE (p, PID_INITIALIZING) && i < wait; i++)
|
for (int i = 0; ISSTATE (p, PID_INITIALIZING) && i < wait; i++)
|
||||||
Sleep (1);
|
low_priority_sleep (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLastError (0);
|
SetLastError (0);
|
||||||
|
|
|
@ -862,7 +862,7 @@ pthread_cond::Signal ()
|
||||||
{
|
{
|
||||||
InterlockedIncrement (&ExitingWait);
|
InterlockedIncrement (&ExitingWait);
|
||||||
/* give up the cpu to force a context switch. */
|
/* give up the cpu to force a context switch. */
|
||||||
Sleep (0);
|
low_priority_sleep (0);
|
||||||
if (spins == 5)
|
if (spins == 5)
|
||||||
/* we've had 5 timeslices, and the woken thread still hasn't done it's
|
/* we've had 5 timeslices, and the woken thread still hasn't done it's
|
||||||
* thing - maybe we raced it with the event? */
|
* thing - maybe we raced it with the event? */
|
||||||
|
|
|
@ -138,7 +138,7 @@ tty_list::terminate (void)
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sleep (200);
|
low_priority_sleep (200);
|
||||||
}
|
}
|
||||||
|
|
||||||
termios_printf ("tty %d master about to finish", ttynum);
|
termios_printf ("tty %d master about to finish", ttynum);
|
||||||
|
@ -218,12 +218,12 @@ tty_list::allocate_tty (int with_console)
|
||||||
SetConsoleTitle (buf);
|
SetConsoleTitle (buf);
|
||||||
for (int times = 0; times < 25; times++)
|
for (int times = 0; times < 25; times++)
|
||||||
{
|
{
|
||||||
Sleep (10);
|
low_priority_sleep (10);
|
||||||
if ((console = FindWindow (NULL, buf)))
|
if ((console = FindWindow (NULL, buf)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SetConsoleTitle (oldtitle);
|
SetConsoleTitle (oldtitle);
|
||||||
Sleep (40);
|
low_priority_sleep (40);
|
||||||
ReleaseMutex (title_mutex);
|
ReleaseMutex (title_mutex);
|
||||||
if (console == NULL)
|
if (console == NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue