Announcement

Collapse
No announcement yet.

Time slicing without windows

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Time slicing without windows

    I was having a problem with a networked dos program that produces a lot of printing (a sales program that writes invoices etc.). The sales program runs on the server as well as other workstations, and the INKEY$ code sequences really fouls up the network spooler performance when printing from a workstation when the server is in an inkey loop.
    After reading Lance's remarks about time slicing, I tried his code snippet (without the PbvHost test):

    while not instat
    if IsWindows% then
    ! push DS
    ! mov AX, &H1680
    ! int &H2F
    ! pop DS
    end if
    wend
    a$ = inkey$

    and it works very well, allowing the workstations to print normally. Perhaps I should mention that the printer is attached to the server, and workstations direct their printouts to the server printer.
    My question is, allowing that I am strictly a high-level language programmer and know next to nothing about assemblers: should this code work reliably in a non-windows system, or am I just lucky? I wonder, because the original code tested for a windows environment, whether the routine is legit for dos.
    -

    ------------------

  • #2
    Aaargh...
    the code snippet should be:
    while not instat
    ! push DS
    ! mov AX, &H1680
    ! int &H2F
    ! pop DS
    wend
    a$ = inkey$
    That is, all code testing for windows is removed.

    ------------------

    Comment


    • #3
      The function should be harmless, at worst, on most DOS systems.
      However, keeping the test would be fully prudent. I see no advantage
      in taking it out.

      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        Tom,
        The reason for taking the test out was because the test fails - and therefore the routine doesn't run - if the system is running under dos, whereas I wanted the routine to run under dos.

        ------------------

        Comment


        • #5
          'k. Are we talking plain DOS, here? Shouldn't be a reason to run a free-time-slice interrupt there, as far as I can figure: plain DOS only handles one session, without multi-tasking. Of course, there are potential considerations such as DESQview, OS/2, or who knows what...

          If you're running under plain DOS, no need to worry: no need for the routine, let it turn itself off. Otherwise, tell us why you want it and, probably, we can offer a suitable work-around.

          I'd guess this routine is safe as used under all circumstances except older DOS-only machines, some of which didn't even initialize unused interrupt vectors. But, there are are a number of techniques that can be used to drive the potential for problems way down.

          My concern here is because the INT is only "mostly" safe without precautions, and "almost always" safe even with precautions. I prefer my software to be fully bomb-proof. It is best to run this routine only under Windows, where you know it will be ok, unless you have reason to address other environments.

          ------------------
          Tom Hanlin
          PowerBASIC Staff

          Comment


          • #6
            Tom,
            thanks for the replies.
            Yes, the system is running under plain dos, MSDOS 6.22, and a Lantastic network.
            Specific problem: when a program running on the server is in an inkey$ loop, the Lantastic spooler slows right down and almost stops - symptoms are that when a workstation sends an invoice to the printer attached to the server, the printer prints a line, then waits for well over a minute, prints the next line, waits again, and so on.
            When the program on the server is not in an inkey$ loop, the printer runs normally. It appears that the inkey$ loop is utilizing nearly all the processor time, leaving little for the spooler.
            Incorporating Lance's routine into the dos program allows the spooler to run as normal.
            Since the computer is running plain vanilla dos, the PbvHost test for a windows environment has to be disabled.
            To repeat my original question for the sake of clarity: allowing that I am strictly a high-level language programmer and know next to nothing about assemblers: should this code work reliably in a non-windows system, or am I just lucky? I wonder, because the original code tested for a windows environment, whether the routine is legit for plain ms-dos.
            regards,
            Colin.


            ------------------

            Comment


            • #7
              I think that the key point is that it is not running in plain DOS, but actually [u]DOS with Lantastic[/i].

              Ralf Browns interrupt list does not specifically state that Lantastic supports this particular service on the multiplex interrupt &H2F, unless it is classified as a multi-tasking O/S. See http://www.ctyme.com/intr/rb-4530.htm

              Also, this service is not noted in the Lantastic functions listed on http://www.ctyme.com/intr/cat-027.htm

              So, I would say that based on your experience, the code works so use it. However, on a plain DOS (ie, no Lantastic, Windows, OS/2 or DesqView, etc), it may or may not have any side-effects.



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

              Comment


              • #8
                Above all said, how would we improve the following for PB 3.5 for
                DOS?

                Code:
                           IF ISTRUE BIT(pbvHost, 8%) THEN '   In WIN environment
                              ! push DS
                              ! mov AX, &H1680
                              ! int &H2F
                              ! pop DS
                           ELSE '                      Not in a WIN environment
                              ! push DS                ; Save DS for PowerBASIC
                              ! mov AX, &H8600         ; Place function $AH68in AX
                              ! mov CX, &H00           ; Use less than 1000 MS delay
                              ! mov DX, &H0A00         ; Try &H0A00 for a delay in DX
                              ! int &H15               ; Call timer interrupt
                              ! pop DS
                           END IF
                Above seems to work well under OS/2 DOS VDM's, as well as under NOVELL
                and .. so far .. under what few WIN-95, WIN-98 boxes on which stuff
                I have is running.

                Point well noted that in pure DOS, why bother? As well, that it might
                prang this or that .. thus back to to the crocidille fable again:

                "How doth the shining crocidille improve his shining tail, by sprinkling
                waters of the Nile o'r every golden scale .."




                ------------------
                Mike Luther
                [email protected]
                Mike Luther
                [email protected]

                Comment


                • #9
                  PBVHOST does not recognise Windows NT and Windows 2000, but the time-slice release code itself is supported by those platforms.

                  I don't have XP to test it with, but I would guess that it will follow the NT tradition.

                  A simple and fairly reliable technique to test for NT/2000 is this:
                  Code:
                  IF UCASE$(ENVIRON$("OS")) = "WINDOWS_NT" THEN ' Windows NT/2000 is running.

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

                  Comment


                  • #10
                    The code should be reasonably safe on standard later PCs. I'd turn it off
                    for DOS versions below 3.1 and CPUs below 80286. INT 2Fh is not guaranteed
                    to be properly initialized on earlier systems, although you could try
                    loading the vector and doing a few tests on it if you expect to need to
                    run on earlier PCs. INT 15h was originally used for the PC cassette interface
                    and didn't include timer functions until at least the PC AT (80286).


                    ------------------
                    Tom Hanlin
                    PowerBASIC Staff

                    Comment


                    • #11
                      Thanks Lance and Tom ..

                      You are both very kind and thoughtful people.



                      ------------------
                      Mike Luther
                      [email protected]
                      Mike Luther
                      [email protected]

                      Comment


                      • #12
                        Thanks to everyone for the interest. The computers are all reasonably recent, with pentium 120s or the like, so int 2Fh will be supported, I think.
                        regards, Colin

                        ------------------

                        Comment


                        • #13
                          Glad to be of service!

                          ------------------
                          Tom Hanlin
                          PowerBASIC Staff

                          Comment


                          • #14
                            Originally posted by Colin J Donoghue:
                            Aaargh...
                            the code snippet should be:
                            while not instat
                            ! push DS
                            ! mov AX, &H1680
                            ! int &H2F
                            ! pop DS
                            wend
                            a$ = inkey$
                            That is, all code testing for windows is removed.

                            Colin, Could you please tell me exactly what the above piece of
                            code does/means. I need to know in case it causes other problems
                            in our system. It fixed our 100% CPU usage problem, so thanks.


                            ------------------

                            Comment


                            • #15
                              According to Ralf Brown's Interrupt List:

                              MS Windows, DPMI, various - RELEASE CURRENT VIRTUAL MACHINE TIME-SLICE

                              Programs can use this function in idle loops to enhance performance under multitaskers; this call is supported by MS Windows 3+, DOS 5+, DPMI 1.0+, and in OS/2 2.0+ for multitasking DOS applications. Does not block the program; it just gives up the remainder of the time slice. When called very often without intermediate screen output under MS Windows 3.x, the VM will go into an idle-state and will not receive the next slice before 8 seconds have elapsed. This time can be changed in SYSTEM.INI through "IdleVMWakeUpTime=<seconds>". Setting it to zero results in a long wait. This function has no effect under OS/2 2.10-4.0 if the DOS box has an "Idle Sensitivity" setting of 100.

                              For more details, please see the Interrupt List. INTER61.ZIP can be downloaded here:

                              http://www.powerbasic.com/files/pub/docs/

                              ------------------
                              Tom Hanlin
                              PowerBASIC Staff

                              Comment


                              • #16
                                Comment from Methusalem

                                I run all my DOS / Btrieve programs on Workstations and use the
                                Server for storing the Data Files all the Workstations share and
                                access only.

                                This not only reduces network traffic, it also allows me to set
                                up one Workstation as a "Stand-Alone" should there be a problem
                                with the LAN. Giving it a copy of the most recent Data saved from
                                the Server to another media, allows business to continue until
                                the Server / LAN problem can be fixed !

                                Printer output is "Captured" directly to Queues on the Server
                                and directed to Print Servers and their printers as desired.
                                NOVELL Netware that is, the only Networking systen worth using
                                in my book !

                                Instant Printing this way, depending on queueing and time-outs !


                                ------------------


                                [This message has been edited by OTTO WIPFEL (edited February 24, 2002).]

                                Comment

                                Working...
                                X