TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Patrick Haller
from: Jonathan de Boyne Pollard
date: 1994-06-14 20:32:20
subject: Dos-Think Lives !

PH>
  > AFAIK there is/was a little bug (?). DosSleep (0L) won't
  > release a complete timeslice, but DosSleep (1L) will. I'm
  > not very sure about this, but after a few tests, I got very
  > different results from those two calls. You'll have to try,
  > which one fits better for the input loop.
PH>

  DosSleep(0), since it invokes the dispatcher upon return from the
  kernel, yields to any thread with equal or high priority.  It doesn't
  necesarily release a timeslice if no such threads exist.

  DosSleep(1), since it always releases at least one timeslice, will
  yield to lower priority (e.g. idle class) threads as well.

  Yielding time with DosSleep is a Windows-ism, and not the most
  efficient way of multitasking, since it incurs the penalty of two ring
  transitions per call, especially if there are no other threads in the
  ready state that can be yielded to.  Far better to use blocking I/O,
  and let the normal scheduling mechanisms control thread dispatching.

PH>
  > When measuring 64 Threads usind DosSleep(1L), the CPU load
  > raises to 17%. When doing the same with DosSleep(0L) to
  > "pre-empt" the current thread voluntarily, the CPU load
  > raises to 100%.
PH>

  A good example.  DosSleep(0) was doing all that work with ring
  transitions and stuff, but not actually yielding any time (Pulse uses
  idle class threads to measure CPU load, which wouldn't be yielded to
  by regular class threads with DosSleep(0)).

  So your threads were spending time calling DosSleep(0) in a tight
  loop, and effectively being CPU-bound in a busy wait loop (which is
  bad), most of which loop was *in the kernel* (which is worse).

  > JdeBP <
___
 X MegaMail 2.10 #0:

--- Maximus/2 2.01wb

* Origin: DoNoR/2,Woking UK (0483-725167) (2:440/4)
SEEN-BY: 54/54 620/243 632/348 640/820 690/660 711/409 413 430 807 808 809
SEEN-BY: 711/934 712/353 623 713/888 800/1 2442/0
@PATH: 440/4 141/209 865 3615/50 229/2 2442/0 711/409 54/54 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.