No announcement yet.

"Critical" API in a DOS window

  • Filter
  • Time
  • Show
Clear All
new posts

  • Mark Hunter

    [This message has been edited by Mark Hunter (edited April 28, 2006).]

    Leave a comment:

  • Tom Hanlin
    CriticalSection is intended for use with small sections of code that perform
    tasks that must not be interrupted in process-- say, updating a jump table
    or interrupt vector. Ideally, a critical section should be employed for very
    small blocks of code. You wouldn't normally employ a critical block for even
    a significant fraction of a second. I would be very hesitant to use it for
    longer periods without having a much better understanding of how it is
    implemented than I do.

    There is not likely to be any point to going in and out of critical sections
    in your application. Any processes that have been starved for time will end
    up taking their due when you exit the critical section.

    It seems that Lance has had some success with using critical sections over
    prolonged periods, so you may find it practical to use one over the course
    of your entire program's execution. Be advised that this is taking the
    intended use of the function way beyond its design, though, so there may be
    unwanted side-effects.

    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:

  • Lance Edmonds
    I use this technique with PBFax for minutes at a time quite successfully. However, it must be noted that it does not "completely disable" Windows - it just switches most of it off. The longest I've let this run is about 5 minutes.

    There are no apparent restrictions on duration and frequency of use, but since the PC may need to do other tasks, I would not want this type of code to run on a Server!

    As for running it for an hour or more?! Please let us know if you have any problems!

    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:

  • Mark Hunter
    started a topic "Critical" API in a DOS window

    "Critical" API in a DOS window

    I've read about the API call CriticalSection, that
    you can use to stop Windows from task switching as

    'code start
    ! MOV AX,&H1681 'CriticalSection API call
    ! INT &H2F

    'code ..........

    'code finish:
    ! MOV AX,&H1682 'release the Critical Task Block
    ! INT &H2F

    I've also read that this call can be used only for
    short periods of time.

    I've written an animation program that displays movies
    smoothly in pure DOS mode. It uses a millisecond timer.
    In a DOS window, I can detect a slight random hesitation
    in the movie. I'd like to use the Critical API call to
    make the movie smooth in a DOS window.


    1. How long is it safe to use this Critical API call?
    That is, the maximum time between &H1681 and &H1682 ?

    2. After using it for that time, how long must you
    wait until you can use it again?

    I'd like to make the call at program start, then release
    it at program finish -- which might be an hour later.

    Failing that, I'd like to call and release it repeatedly
    and very rapidly.