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-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.
do
{
InterlockedDecrement (&dll->here);
- Sleep (0);
+ low_priority_sleep (0);
}
while (InterlockedIncrement (&dll->here));
else if (!dll->handle)
while (InterlockedIncrement (&here))
{
InterlockedDecrement (&here);
- Sleep (0);
+ low_priority_sleep (0);
}
if (!wsock_started && (winsock_active || winsock2_active))
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;
HANDLE ()
{
while (!ev)
- Sleep (0);
+ low_priority_sleep (0);
return ev;
}
/* 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;
}
resume_thread:
ResumeThread (hth);
- Sleep (0);
+ low_priority_sleep (0);
continue;
}
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);
}
}
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");
}
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;
}
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);
}
}
break;
}
- Sleep (10);
+ low_priority_sleep (10);
}
if (ReadFile (handle, outbuf, rlen, &n, NULL) == FALSE)
{
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);
+}
this way at some point. */
if (i < 9 && !created && createit && (procinfo->process_state & PID_EXITED))
{
- Sleep (5);
+ low_priority_sleep (5);
release ();
continue;
}
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;
int
sched_yield (void)
{
- Sleep (0);
+ low_priority_sleep (0);
return 0;
}
}
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);
{
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? */
i = 0;
}
- Sleep (200);
+ low_priority_sleep (200);
}
termios_printf ("tty %d master about to finish", ttynum);
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)
{