473,406 Members | 2,698 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,406 software developers and data experts.

Expert Query on timing, threads, networking plz.... :S



Two quick queries:

1. I have programmed a little network performance monitor. It monitors
a set of remote hosts over a network. It gets the CPU statistics and
all gets collected at one of the remote hosts (say primary remote host,
holding procValues[n][4], 4 CPU floating numbers per n remote hosts).

Now, I want to transfer this data set (double procValues[n][4]) over a
TCP or UDP network connection to a local host for graphing and storing
in a database tool.

I've read Beej's Networking Guide
http://www.ecst.csuchico.edu/~beej/guide/net/ and going to follow his
code.

However I don't know how am going to send a double[n][4] over the
network efficiently without hogging the network. Is the most efficient
way just converting double[n][4] into a string?

Am using a sleep(1) function to set the frequency of 1 second to read
the cpu statistics.

If a sending function takes more than the frequency of "cpu statistic
collecting" then am going to get lots of missed out data... no wait it
wouldn't be perfectly synchronized to the exact second, it will be
lagged behind. Maybe thread the network transfer so that the frequency
of "cpu collecting" remains precisely every second?

What are your views?

2. How does one create/use threads in C, AND C++? Do threads differ in
usage in C and C++?

Jul 23 '05 #1
5 1456
>>However I don't know how am going to send a double[n][4] over the
network efficiently without hogging the network. Is the most efficient
way just converting double[n][4] into a string? First send the value of n, then send each double value in a
loop.Receiving side, n will determine the no of double values to
recieve.Maybe thread the network transfer so that the frequency
of "cpu collecting" remains precisely every second? You may consider a list of data sharing between both thread and access
should be syncronized between them.
data collecting thread will collect data and add this to rear of list
and other thread will take the as much as data availabel in list and
will copy it and send it to network.2. How does one create/use threads in C, AND C++? Do threads differ in

usage in C and C++?
If you are on windows , use beginthreadex(). Search "multithreading
C++" on google. Also consider the synchronization issues, you may use
mutex , critical section etc depending upon situations.

Jul 23 '05 #2
>>then send each double value in a loop
Sorry, why need loop? just send it as one buffer, they are arrays, i
forgot that.

Jul 23 '05 #3
What? Just pass the 2-dimensional array? How?

Jul 23 '05 #4

KevinGPO wrote:
Two quick queries:
(...)
Now, I want to transfer this data set (double procValues[n][4]) over a
TCP or UDP network connection to a local host for graphing and storing
in a database tool.

I've read Beej's Networking Guide
http://www.ecst.csuchico.edu/~beej/guide/net/ and going to follow his
code.

However I don't know how am going to send a double[n][4] over the
network efficiently without hogging the network. Is the most efficient
way just converting double[n][4] into a string?

If you plan on using send and recv (as is suggested by the link), you
have no option besides converting the 2D array into a string (for send)
and reading the character stream (from recv) to retrieve the double
values. NB: Neither send nor recv belong to the standard libraries of
C and C++.

(...)

2. How does one create/use threads in C, AND C++? Do threads differ in
usage in C and C++?


The core languages (and their libraries) do not offer any support for
threads (yet?!). You need to use POSIX extensions to C for this
purpose. Try comp.unix.programmer.

- Anand

Jul 26 '05 #5
How about using message queuing model. I always find it good when there
is the case of data loss because of different speeds of producer and
consumer.
You can create a queue and then dump the data into it. Another
task/thread can read data from it and process it at its own will.
So you will not lose data but the graph which you will be displaying
will be a bit older than the actual stats.

Jul 26 '05 #6

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

Similar topics

1
by: Dan Williams | last post by:
Hi people Part of the reason I have started using Python (experience: 3 days) is that I recognise the potential benefits in using it compared to writing C/C++ code. In particular, there are a...
6
by: S. David Rose | last post by:
Hello All! I am new to Python, and wanted to know if I might ask you a question regarding timing. I want a main loop which takes photos from 8 different web-cams, each can be addressed by...
2
by: Ryan Budge | last post by:
Hi All. I have some rather large SQL Server 2000 databases (around 60GB). I have set up jobs to re-index the tables and update statistics every sunday. This worked will for a few months. Now...
2
by: Norm | last post by:
I have run into problems from time to time (and this is one of those times) using visual basic to access an external database and perform a basic select from statement. When the table is extremely...
7
by: jamie | last post by:
hey all, I am attempting to do motion control for a final project, but I have a concern.... For motion control, timing is everyting, the better it is, the better it works. Currently I am...
3
by: gregory_may | last post by:
I have an application where I am using a System Thread to capture the screen & Broadcast it to clients. Its "working", but the timing on the background thread gets wildly erratic at times. Some...
4
by: frizzle | last post by:
Hi there, Still building my forum. I have a certain mysql-query i just can't figure out. These are my tables (simplified): categories -> id, description forums -> id, cat_id,...
2
by: Oeyvind Brandtsegg | last post by:
hello I'm writing a Python application for live music performance/improivsation, using csound as the synthesis engine, and Python for compositional algorithms, GUI and control. I creating...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.