Home All Groups Group Topic Archive Search About

Threading make computer slow

Author
7 Mar 2006 2:58 PM
PH
Hi guys;



I got a single processor computer, running an application that launches
2 threads.

Each of these threads listens for incoming connections in a specific
port, so there is a Loop . Until inside each of them.

When a packet is received the thread calls a method that process the
packet, and so on, this happens for every packet in any of those 2
ports.



THIS SI NOT THE ACTUAL CODE, BUT IS SOMETHING ALIKE



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



Dim Thread1 as new Thread (addressOff ProcessPacket)

Thread1.Start



Dim Thread2 as new Thread (addressOff ProcessPacket)

Thread2.Start





Private Sub ProcessPacket

  Do

   BeginAccept( WhateverProc)

Until bStop

End Sub





Private Sub WhateverProc

  Process the packet

End Sub



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



Now, my problem is that in a period of time, lets say 30 seconds, I only
receive 4 packets (this is only when I test, in production will be a LOT
more, believe me ;-)  )

What happens is that the processor's resources are almost gone, and the
computer reacts responsive less.

If this is happening with 4 packets, I don't what to even imagine what
will happen with 100.

Is there any way to easy the life of the processor even with more
traffic coming in?



Thanks

Author
7 Mar 2006 3:33 PM
Tom
Have you tried putting an Application.DoEvents in your Do loop? It
would seem that would allow other messages/threads to be processed and
should reduce your CPU usage. Otherwise, you may have to redesign the
thread so that it processes on a timer - i.e. only runs once every 15
seconds or something.

Tom


--

PH wrote:

Show quoteHide quote
> Hi guys;
>

>
> I got a single processor computer, running an application that
> launches 2 threads.
>
> Each of these threads listens for incoming connections in a specific
> port, so there is a Loop . Until inside each of them.
>
> When a packet is received the thread calls a method that process the
> packet, and so on, this happens for every packet in any of those 2
> ports.
>

>
> THIS SI NOT THE ACTUAL CODE, BUT IS SOMETHING ALIKE
>

>
> --------------------------
>

>
> Dim Thread1 as new Thread (addressOff ProcessPacket)
>
> Thread1.Start
>

>
> Dim Thread2 as new Thread (addressOff ProcessPacket)
>
> Thread2.Start
>

>

>
> Private Sub ProcessPacket
>
>   Do
>
>    BeginAccept( WhateverProc)
>
>  Until bStop
>
> End Sub
>

>

>
> Private Sub WhateverProc
>
>   Process the packet
>
> End Sub
>

>
> --------------------------
>

>
> Now, my problem is that in a period of time, lets say 30 seconds, I
> only receive 4 packets (this is only when I test, in production will
> be a LOT more, believe me ;-)  )
>
> What happens is that the processor's resources are almost gone, and
> the computer reacts responsive less.
>
> If this is happening with 4 packets, I don't what to even imagine what
> will happen with 100.
>
> Is there any way to easy the life of the processor even with more
> traffic coming in?
>

>
> Thanks
>

>

>
>
Author
7 Mar 2006 3:35 PM
Patrice
What if you don't use threading at all ? Once done, if it works fine it's
likey a problem with the multithreading part, else if it still perform badly
this is likely a problem with how the connection is managed...
--
Patrice

"PH" <nospam@nospam.com> a écrit dans le message de
news:003801c641f7$94929600$0e01a8c0@m1...
Show quoteHide quote
> Hi guys;
>
>
>
> I got a single processor computer, running an application that launches
> 2 threads.
>
> Each of these threads listens for incoming connections in a specific
> port, so there is a Loop . Until inside each of them.
>
> When a packet is received the thread calls a method that process the
> packet, and so on, this happens for every packet in any of those 2
> ports.
>
>
>
> THIS SI NOT THE ACTUAL CODE, BUT IS SOMETHING ALIKE
>
>
>
> --------------------------
>
>
>
> Dim Thread1 as new Thread (addressOff ProcessPacket)
>
> Thread1.Start
>
>
>
> Dim Thread2 as new Thread (addressOff ProcessPacket)
>
> Thread2.Start
>
>
>
>
>
> Private Sub ProcessPacket
>
>   Do
>
>    BeginAccept( WhateverProc)
>
>  Until bStop
>
> End Sub
>
>
>
>
>
> Private Sub WhateverProc
>
>   Process the packet
>
> End Sub
>
>
>
> --------------------------
>
>
>
> Now, my problem is that in a period of time, lets say 30 seconds, I only
> receive 4 packets (this is only when I test, in production will be a LOT
> more, believe me ;-)  )
>
> What happens is that the processor's resources are almost gone, and the
> computer reacts responsive less.
>
> If this is happening with 4 packets, I don't what to even imagine what
> will happen with 100.
>
> Is there any way to easy the life of the processor even with more
> traffic coming in?
>
>
>
> Thanks
>
>
>
>
>
>
>
>