TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Mike Bilow
from: Mario Semo
date: 1996-03-11 13:06:32
subject: mutex semaphores

Hello Mike,

On Mar 08 15:48 96, Mike Bilow of 1:323/107 wrote:

 MS>> PS: DosSleep of course will never return in <= 31ms. even
 MS>> not in TimeCrtitcalThreads. 

 MB> This is not quite right.  DosSleep(1) will return more quickly than 
 MB> scheduler granularity if and only if no other threads are ready, or all 
 MB> other ready threads make explicit yields.  My guess is that this is how 
 MB> you are seeing 7.3 ms as your 95% threshold.  I think you would see your 
 MB> response time decline to a normally distributed curve centered on 16 ms 
 MB> if the processor is loaded.

==== x.cpp ===========
#include 
#include 
#define INCL_DOS
#include 

void func1()
{
 printf("A\n");

 DosSetPriority(PRTYS_THREAD,PRTYC_TIMECRITICAL,0,0);
 for (int i=0;i<100;i++)
    DosSleep(1);
}

void func2()
{
 HEV hev=0;
 ULONG Handle;
 ULONG ulPostCount;

 printf("B\n");

 DosSetPriority(PRTYS_THREAD,PRTYC_TIMECRITICAL,0,0);
 DosCreateEventSem(0, &hev,DC_SEM_SHARED,FALSE);

 for (int i=0;i<100;i++)
   {
    DosResetEventSem(hev,&ulPostCount);
    DosStartTimer(0, (HSEM)hev,&Handle);  // 0 = 1ms
    DosWaitEventSem(hev,1000);
   }

 DosCloseEventSem(hev);
}


main(int argc, char *argv[], char *envp[])
{
 ULONG ul=clock();

 if (argc==1)
    func1();  // const. 3125 : means 31.25ms
 else
    func2();    // about 800 : means 8ms

 ul=clock()-ul;
 printf("%d\n",ul);
 return 0;
}

 WARPED!, Mario

--- Msgedsq/2 2.2e
* Origin: LC/32 Development Team-Vienna-Austria (2:310/14.11)
SEEN-BY: 50/99 78/0 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 310/14 1 24/999 2/777 396/1 270/101 712/515 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™.