473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Threading make computer slow

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


Mar 7 '06 #1
2 1654
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:
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


Mar 7 '06 #2
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" <no****@nospam.com> a écrit dans le message de
news:003801c641f7$94929600$0e01a8c0@m1...
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



Mar 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
2
by: AtherMurtuzapurwala | last post by:
Hi All, Client/Server Program using Sockets... Server sends request in form of CSV format in NetworkStream... So I want to read this using threading because it is in very large volume so...
13
by: John | last post by:
I've got some reasonably complex business logic in my C# code, in a class called by a ASP.NET page. This takes around 3-4 seconds to execute. It's not dependent on SQL calls or anything like that....
7
by: Bruce W. Darby | last post by:
I've been doing some reading on threading, using the BackgroundWorker, but I'm getting in over my head a bit. I've run through the tutorial at MSDN and, while it has some good information, it is a...
14
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I just started learning Threading in C#. I read lot of articles and what I am trying to accomplish here is that I have an array of string and I want to pass the member of that...
0
by: SyGC | last post by:
Hi Guys, I have used Threading for Network.Ping to continuously ping an IP address if ping is successful Image A is displayed if not Image B. The code is as follows: Imports System Imports...
5
by: George Maicovschi | last post by:
As multi-threading is not built in PHP I've been using a hack letting the Apache server handle the multi-threading issues, but I'm really curious of other approaches to this issue. If anyone has...
9
by: Salad | last post by:
I have access, for testing at my client's site, a Win2000 computer running A2003 retail. He recently upgraded all of his other machines to DualCore Pentiums with 2 gig ram and run A2003 runtime. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.