Both of these last two responses were very helpful. I'm in the
process of implementing both solutions. Here are responses to
both posts:
-------
Altenbach,
My program is structured somewhat like yours. I've got the UDP
read running in a loop of its own, and it is deciding who sent the
packet (I'm running a set of 8 sensors--each on its own UDP port) by
the IP address and then putting the packet into the corresponding queue
(of an array of 8 queues--one per sensor). Packets are pulled off
of these queues from another loop and processed.
Unfortunately, I have a few other loops running at the same time.
One to handle the UI, one to handle commands and processes, one to
process incoming packets, and one to perform the UDP read. I have
a feeling that this may not be the most elegant solution, but I'm not
too much of a programmer, and it's the best I could come up with.
I've checked for other CPU hogs among these loops, and I can't find any
right now--I've
tried to put generous delays in my other loops to minimize their CPU
usage; that's not to say I haven't missed anything, though.
I'm going to try to implement this loop with the LV2 style globals
rather than queues, and then I'm going to move ALL of the processing
(including deciding which sensor the packet is from) out of the UDP
read loop and into the packet processing loop. I think this will
be a large step towards solving my problem. Thanks a lot.
In response to the rest of your post, my hardware is an PCI NIC in a
rackmount computer. The computer's pretty fast, but there are two
NICs--one to communicate with sensors and another to communicate with
the outside world. Having two NICs may be another source of my
problem--I don't know for sure.
-------
help,
Thanks very much for the useful links about TCP/UDP in Windows.
I'm going to attempt to increase the buffer size to see if this helps
as well. I've been looking for articles just like these to help
me understand what's going on. This will help me greatly as I
continue to improve my software.
-----
Thanks,
Tom