J
James Kimble
I'm trying to write a method to poll a quasi-real time system for
various data via UDP. What I need to do is send 10 different messages
over a period of 10 seconds with each message send operation separated
by 1 second. The system then responds on another UDP port.
The orignal programmer had a method that simply had a counter for
each message. The method was called from an infinte loop. Each message
had a count to wait for and would then be sent. A sleep of 10 seconds
was then called after all messages had been sent. This created some
issues with some messages being sent vertually on top of each other
and others being sent at too long an interval. I wanted to do something
much more predictable and maintainable.
I created a method that sends a message, does a "this.sleep(1000)",
then sends the next message and so on. Because there are 9 different
messages this gives me just the messaging rate I want. Unfortunately it
also seems to take my system load (according to top) to a level of 3.8
to 4.5 where the previous method was down around 1.9 to 2.5. System
load is critical to this system (quasi-real time).
Can anyone suggest the best method for doing what I'm attempting while
keeping system load as low as possible? Can anyone explain why a number
of sleeps would drive sytem load so high?
Any help greatly appreciated.
James Kimble
various data via UDP. What I need to do is send 10 different messages
over a period of 10 seconds with each message send operation separated
by 1 second. The system then responds on another UDP port.
The orignal programmer had a method that simply had a counter for
each message. The method was called from an infinte loop. Each message
had a count to wait for and would then be sent. A sleep of 10 seconds
was then called after all messages had been sent. This created some
issues with some messages being sent vertually on top of each other
and others being sent at too long an interval. I wanted to do something
much more predictable and maintainable.
I created a method that sends a message, does a "this.sleep(1000)",
then sends the next message and so on. Because there are 9 different
messages this gives me just the messaging rate I want. Unfortunately it
also seems to take my system load (according to top) to a level of 3.8
to 4.5 where the previous method was down around 1.9 to 2.5. System
load is critical to this system (quasi-real time).
Can anyone suggest the best method for doing what I'm attempting while
keeping system load as low as possible? Can anyone explain why a number
of sleeps would drive sytem load so high?
Any help greatly appreciated.
James Kimble