Results 1 to 7 of 7

Thread: CPU Maxing Problem

  1. #1

    Thread Starter
    Hyperactive Member FATBOYPEE's Avatar
    Join Date
    May 2001
    Location
    Charleville (Ireland) Still. ANYONE GOT A JOB I CAN HAVE ? GIZA JOB. I CAN DO THAT....
    Posts
    463

    CPU Maxing Problem

    Guys,

    First off, THIS IS NOT MY DESIGN....second off, I need your expertise, suggestions (constructive please ) about anything I can do to sort my problem out....

    Now, niceties out the way, heres' the problem:

    One Server. On that server there is an EXE that instantiates another EXE using CreateprocessA API to listen to ports 1 thru to 80 (each port has a separate EXE instantiated).

    The spawned EXE listens for activity on the port, interrogates a database & sends VT Character data back thru the port.

    Each port is connected to a wireless scanning gun via a base station.

    The problem is that once 30 spawned exe's have been created, the processor on the server simply maxes out.

    Is there any way, given the current design to cap the CPU usage of the spawned EXE ?

    Reason being, once CPU maxes out, the SQL Server that resides on the same machine cannot find enough process space to field information back to each of the EXEs & then the whole server jams up ?

    Your comments & enlightenment most appreciated !!!

    FATBOY....

    Best Bar.....

  2. #2

    Thread Starter
    Hyperactive Member FATBOYPEE's Avatar
    Join Date
    May 2001
    Location
    Charleville (Ireland) Still. ANYONE GOT A JOB I CAN HAVE ? GIZA JOB. I CAN DO THAT....
    Posts
    463
    Anything, even banalities.....pleeeeeze...

    Best Bar.....

  3. #3
    Si_the_geek
    Guest
    you could somehow reduce the priority of the processes of the Exe's... don't know how though...

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Hit CTRL+ALT+DEL, go into task manager, and reduce the thread priority of the process tree
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5
    Si_the_geek
    Guest
    ah yes... now I can search the API viewer... ta-da!
    VB Code:
    1. Const THREAD_BASE_PRIORITY_IDLE = -15
    2. Const THREAD_BASE_PRIORITY_LOWRT = 15
    3. Const THREAD_BASE_PRIORITY_MIN = -2
    4. Const THREAD_BASE_PRIORITY_MAX = 2
    5. Const THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN
    6. Const THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX
    7. Const THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST + 1)
    8. Const THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST - 1)
    9. Const THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE
    10. Const THREAD_PRIORITY_NORMAL = 0
    11. Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
    12. Const HIGH_PRIORITY_CLASS = &H80
    13. Const IDLE_PRIORITY_CLASS = &H40
    14. Const NORMAL_PRIORITY_CLASS = &H20
    15. Const REALTIME_PRIORITY_CLASS = &H100
    16. Private Declare Function SetThreadPriority Lib "kernel32" (ByVal hThread As Long, ByVal nPriority As Long) As Long
    17. Private Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
    18. Private Declare Function GetThreadPriority Lib "kernel32" (ByVal hThread As Long) As Long
    19. Private Declare Function GetPriorityClass Lib "kernel32" (ByVal hProcess As Long) As Long
    20. Private Declare Function GetCurrentThread Lib "kernel32" () As Long
    21. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
    22. Private Sub Form_Load()
    23.     'KPD-Team 2000
    24.     'URL: [url]http://www.allapi.net/[/url]
    25.     'E-Mail: [email][email protected][/email]
    26.     Dim hThread As Long, hProcess As Long
    27.     'retrieve the current thread and process
    28.     hThread = GetCurrentThread
    29.     hProcess = GetCurrentProcess
    30.     'set the new thread priority to "lowest"
    31.     SetThreadPriority hThread, THREAD_PRIORITY_LOWEST
    32.     'set the new priority class to "idle"
    33.     SetPriorityClass hProcess, IDLE_PRIORITY_CLASS
    34.     'print some results
    35.     Me.AutoRedraw = True
    36.     Me.Print "Current Thread Priority:" + Str$(GetThreadPriority(hThread))
    37.     Me.Print "Current Priority Class:" + Str$(GetPriorityClass(hProcess))
    38. End Sub

  6. #6
    jim mcnamara
    Guest
    Taking a different tack: memory and context switching

    It sounds like the system is thrashing big time. You can add a LOT of memory to the server, which will help. Figure about 5MB per process. Those processes need about 400MB to remain resident.

    Or try setting the swap file size to triple memory - which is about the max NT can deal with. Which is not going to really fix the problem.

    The reason the CPU goes crazy is that the OS is spending most of it's time in kernel mode handling all of the context switches and swapping stuff in/out of memory. Monitor CPU usage, then look for time in kernel mode and interrupt. If both of these total more than about 20%-25% on average it's an OS problem.
    Look for page file activity as well. It will be high. If this pans out you need a load more memory

    PS: start monitoring BEFORE the problem occurs.

  7. #7

    Thread Starter
    Hyperactive Member FATBOYPEE's Avatar
    Join Date
    May 2001
    Location
    Charleville (Ireland) Still. ANYONE GOT A JOB I CAN HAVE ? GIZA JOB. I CAN DO THAT....
    Posts
    463

    Bedankt

    Thanks for the replies guys. Much appreciated !

    Seems the CPU spikes are erratic and may not after all be load-based. But I'm not convinced !! Ergo I'm gonna try all suggestions in turn.

    Thanks

    Pee.

    Best Bar.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width