Announcement

Collapse
No announcement yet.

Inkey$ - hogging CPU in win XP

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

  • Inkey$ - hogging CPU in win XP

    Hi All !

    I was looking at this old thread and wondered if a better solution existed which did not hog the CPU when the inkey$/timer etc was used. I somehow cant seem to be able to post directly to the thread.

    Also another observation :- If a p4 CPU is used it will hog up 50% only while a Celeron CPU would be hogge'd to 100%. Why may this be?

    One other question :- The solutions provided assumes that Windows XP(NT) is used, has anyone noticed CPU hogging with Win98.

    Has PowerBasic released a fix etc ?

    JustBASit www.compubyte.co.za


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

  • #2
    Hello,

    this is not a PB problem, it is a Windows problem.
    win98 doesn't have the issue, but Win2k and later does.

    this is the best solution that I've found, and explains what
    is happening:
    http://www.tamedos.com

    ------------------
    If you go flying back through time and you see somebody else flying forward into the future, it's probably best to avoid eye contact.

    Comment


    • #3
      teratech had code to release a timeslice, but never used
      with pb. the routine was called idle and worked with qb.
      here is an example in pb/cc (which doesn't need it.)
      not sure if pb has a routine to release a timeslice.
      Code:
      #compile exe
      #dim all
      declare function ink as string
      declare sub idle
      
      function pbmain  as long
        local keypress as string
        keypress = ink$
      end function
      
      function ink as string
        call idle
        ink = inkey$
      end function
      
      sub idle
        'release time slice code
      end sub
      this might be useful. see lance's code. http://www.powerbasic.com/support/pb...read.php?t=604
      ------------------


      [this message has been edited by mike doty (edited august 25, 2005).]

      Comment


      • #4
        This is a SUB whis is part of one of my old input-output-libraries.
        It was called during the keyboard-/mouse-polling-loop and contains some INTs
        which are recommend then. But I never did intensive testing to proof those
        calls to be helpfull in minimizing CPU load...

        Code:
        SUB wRelease() LOCAL PUBLIC
           CALL INTERRUPT &H28 ' INT 28 destroys registers, so use CALL
           ! MOV AX,&h1680
           ! INT &h2F
           IF BIT(PBVHOST,8) = 0 THEN ' only without Win 3.1+
              ! MOV AX,&h8400
              ! INT &h2A
           END IF
        END SUB
        I think there are some more INTs to release time slice and/or support multi-
        tasking environments, take a look at Ralph Brown's Interrupt List.

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

        Comment


        • #5
          Originally posted by A.Basit A.Bulbulia:
          Also another observation :- If a p4 CPU is used it will hog up 50% only while a Celeron CPU would be hogge'd to 100%.
          Probably with that P4 CPU you see the effect of HyperThreading (2 logical cores presented to the OS).

          Bye!

          ------------------
          Try Online TrID file identifier! Recognize over 1.700 filetypes and counting...
          Give a powerfull scriptable Lua interface to your application with PowerBLua
          PBTracer - Tracer / Profiler for PowerBASIC (soon!)
          -- The universe tends toward maximum irony. Don't push it.

          File Extension Seeker - Metasearch engine for file extensions / file types
          Online TrID file identifier | TrIDLib - Identify thousands of file formats

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎