TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Jonathan de Boyne Pollard
from: Patrick Haller
date: 1994-06-16 20:56:30
subject: Dos-Think died two years ago !

Hi Jonathan!

[..]
 JdBP> Yielding time with DosSleep is a Windows-ism, and not the most
 JdBP> efficient way of multitasking, since it incurs the penalty of two
 JdBP> ring   transitions per call, especially if there are no other
 JdBP> threads in the   ready state that can be yielded to.  
Jep. But this was intended here. I tried to find a halfway reliable way to
determine how much time OS/2 needs for the thread switching. I know my
results are anything but exact - but I'm rather sure OS/2 needs less than
60 microsecs for a complete thread switch on a 486/66. I'm still wondering
about this because someone wrote here in this area about QNX doing this in
about 6 microsecs.
Perhaps you could tell me better way to measure this or even exact timings ... ?

void _stdcall CountThd (PVOID var)
{
  ULONG *v;

  v = var;
  for (;;)
  { (*v)++; /* count me ... */
    DosSleep (0L); 
  }
}

void main (void)
{
  /* reset counters */
  for (i = 0;i < NUMTHREADS; i++) b[i] = 0;

  /* start measuring threads */
  for (i = 0;i < NUMTHREADS; i++)
    _beginthread (CountThd,THDSTACK,(PVOID)&b[i]);

  /* Wait for one minute */  
  DosSleep (RUNTIME);

  memmove (a,b,sizeof(b));
  for (i = 0;i < NUMTHREADS; i++)
    if (a[i]) printf ("\nThread %4u: a=%u, %u per second",i,a[i],
(a[i] / RUNTIME10));
    else      printf ("."); // Thread was not started

  total = 0;
  for (i = 0;i < NUMTHREADS; i++)
    total += a[i];
  printf ("\nTotal: a=%u, %u per second",total, (total / RUNTIME10));
  printf ("\nThis means %u mcs per Thread (including computing
time)", (1000000 * RUNTIME10 / total));
}

This is my quick hack. It is absolutely unsuitable for precise measuring,
but now I know about the scale of OS/2's thread switching.
       __
       |_)      Internet: Haller{at}ti-nov1.fbe.fh-weingarten.de
cu/2.1 |atrick  Fidonet:  2:246/2320.18 ZebraNet: 7:7000/7998

--- FleetStreet 0.88wb


* Origin: Zebra / Uplink / Bodensee Bitbeisser Crew ! (2:246/2320.18)
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: 246/2320 2300 2200 2426/2000 24/24 396/1 3615/50 229/2
@PATH: 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™.