|
-
Jun 12th, 2002, 03:51 AM
#1
Thread Starter
Hyperactive Member
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.....
-
Jun 12th, 2002, 05:05 AM
#2
Thread Starter
Hyperactive Member
Anything, even banalities.....pleeeeeze...

Best Bar.....
-
Jun 12th, 2002, 06:19 AM
#3
you could somehow reduce the priority of the processes of the Exe's... don't know how though...
-
Jun 12th, 2002, 06:30 AM
#4
Retired VBF Adm1nistrator
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]
-
Jun 12th, 2002, 07:39 AM
#5
ah yes... now I can search the API viewer... ta-da!
VB Code:
Const THREAD_BASE_PRIORITY_IDLE = -15
Const THREAD_BASE_PRIORITY_LOWRT = 15
Const THREAD_BASE_PRIORITY_MIN = -2
Const THREAD_BASE_PRIORITY_MAX = 2
Const THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN
Const THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX
Const THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST + 1)
Const THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST - 1)
Const THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE
Const THREAD_PRIORITY_NORMAL = 0
Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
Const HIGH_PRIORITY_CLASS = &H80
Const IDLE_PRIORITY_CLASS = &H40
Const NORMAL_PRIORITY_CLASS = &H20
Const REALTIME_PRIORITY_CLASS = &H100
Private Declare Function SetThreadPriority Lib "kernel32" (ByVal hThread As Long, ByVal nPriority As Long) As Long
Private Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
Private Declare Function GetThreadPriority Lib "kernel32" (ByVal hThread As Long) As Long
Private Declare Function GetPriorityClass Lib "kernel32" (ByVal hProcess As Long) As Long
Private Declare Function GetCurrentThread Lib "kernel32" () As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Sub Form_Load()
'KPD-Team 2000
'URL: [url]http://www.allapi.net/[/url]
Dim hThread As Long, hProcess As Long
'retrieve the current thread and process
hThread = GetCurrentThread
hProcess = GetCurrentProcess
'set the new thread priority to "lowest"
SetThreadPriority hThread, THREAD_PRIORITY_LOWEST
'set the new priority class to "idle"
SetPriorityClass hProcess, IDLE_PRIORITY_CLASS
'print some results
Me.AutoRedraw = True
Me.Print "Current Thread Priority:" + Str$(GetThreadPriority(hThread))
Me.Print "Current Priority Class:" + Str$(GetPriorityClass(hProcess))
End Sub
-
Jun 12th, 2002, 07:45 AM
#6
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.
-
Jun 12th, 2002, 08:40 AM
#7
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|