Ignore:
Timestamp:
Dec 30, 2011, 11:41:30 AM (14 years ago)
Author:
dmik
Message:

winmm: Restore normal priority when calling timer funciton.

This should prevent the callback code from working at the high
priority used for waiting on timer signals.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/winmm/os2timer.cpp

    r21930 r21933  
    423423  ULONG   Count = 0;
    424424  APIRET  rc = 0;       /* Return code  */
    425   USHORT  selTIB;
    426425
    427426  dprintf(("WINMM: TimerHandler thread created (%08xh)\n",
    428427           this));
    429428
    430   rc = DosSetPriority (PRTYS_THREAD,        /* Change a single thread */
    431                        PRTYC_TIMECRITICAL,  /* Time critical class    */
    432                        0L,                  /* Increase by 15         */
    433                        0L);                 /* Assume current thread  */
     429  // save the current thread priority
     430  PTIB ptib = NULL;
     431  DosGetInfoBlocks(&ptib, NULL);
     432  ULONG prio = ptib->tib_ptib2->tib2_ulpri;
     433
     434  // increase the thread priority to improve timer resolution
     435  DosSetPriority (PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
    434436
    435437  while(!fFatal)
     
    438440             dwFlags,
    439441            clientCallback));
    440    
     442
    441443    rc = DosWaitEventSem(TimerSem, SEM_INDEFINITE_WAIT);
    442444    if(rc) {
     
    451453    if(!fFatal)
    452454    {
    453         // @@@PH: we're calling the client with PRTYC_TIMECRITICAL !!!
    454         //        It'd be much nicer to call with original priority!
    455      
    456455        // check timer running condition
    457456        if (TimerStatus == Running)
     
    467466              if (clientCallback != NULL)
    468467              {
     468                  // restore the original priority (we never know what the callback
     469                  // code does)
     470                  DosSetPriority (PRTYS_THREAD, (prio >> 8) & 0xFF, 0, 0);
     471
    469472                  clientCallback((UINT)timerID, 0, userData, 0, 0);
     473
     474                  DosSetPriority (PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
    470475              }
    471476              break;
Note: See TracChangeset for help on using the changeset viewer.