473,386 Members | 1,799 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,386 software developers and data experts.

message passing question

Gvs
Hi,

I'm currently trying to pass messages into a queue. This all works fine,
however, i'm trying to my program to stop sending messages to the queue when
it reaches an upper threshold. At present this threshold is the number of
chairs in a waiting room. This is an int represented by nChairs.

So i want to compare this to the number of messages in my queue. I'm using
the following lines of code to do this, however the queue is always saying
it has 0 messages, i check with ipcs and it has multiple (+30) some times.
What am i doing wrong ?

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

while (ds.msg_qnum < nChairs)
{
printf("number of chairs : %d\n", nChairs);
printf("number of messages : %d\n", ds.msg_qnum);
}

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

I have more code that adds the messages inside this while loop .. but i
ommitted it for simplicity.

Matt
Nov 14 '05 #1
2 1858
"Gvs" <tr****@westnet.com.au> writes:
I'm currently trying to pass messages into a queue. This all works fine,
however, i'm trying to my program to stop sending messages to the queue when
it reaches an upper threshold. At present this threshold is the number of
chairs in a waiting room. This is an int represented by nChairs.

So i want to compare this to the number of messages in my queue. I'm using
the following lines of code to do this, however the queue is always saying
it has 0 messages, i check with ipcs and it has multiple (+30) some times.
What am i doing wrong ?

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

while (ds.msg_qnum < nChairs)
{
printf("number of chairs : %d\n", nChairs);
printf("number of messages : %d\n", ds.msg_qnum);
}

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


We have no way of knowing from what you've posted. Apparently ds is a
structure with a member called msg_qnum, but you haven't told us
anything more about it, and we don't know what "ipcs" is.

When you say that "the queue is always saying it has 0 messages", do
you mean that ds.msg_qnum==0?

In the code fragment you provided, there's nothing that could change
the value of ds.msg_qnum, so if it executes at all it's an infinite
loop.

If this is part of something system-specific, you'll need to ask in a
system-specific newsgroup. If it's part of your own software, you'll
need to provide more details.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #2
Groovy hepcat Gvs was jivin' on Thu, 19 May 2005 13:13:48 +0800 in
comp.lang.c.
message passing question's a cool scene! Dig it!
I'm currently trying to pass messages into a queue. This all works fine,
however, i'm trying to my program to stop sending messages to the queue when
it reaches an upper threshold. At present this threshold is the number of
chairs in a waiting room. This is an int represented by nChairs.

So i want to compare this to the number of messages in my queue. I'm using
the following lines of code to do this, however the queue is always saying
it has 0 messages, i check with ipcs and it has multiple (+30) some times.
What am i doing wrong ?

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

while (ds.msg_qnum < nChairs)
{
printf("number of chairs : %d\n", nChairs);
printf("number of messages : %d\n", ds.msg_qnum);
}

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

I have more code that adds the messages inside this while loop .. but i
ommitted it for simplicity.


Umph! A guy goes to his local mechanic and says, "My car has
something wrong with its gearbox. I can't change gear. I've brought
along the locking bolts from a couple of the cogs inside the gearbox
to show you. What could be the trouble?"
What do you think the mechanic said to the guy? Now you know what we
want to say to you.
Please post the smallest *complete* program that demonstrates the
problem. By "complete" I mean something you expect to compile and run.
If your program is long, cut out everything extraneous, leaving just
enough to show the problem - but *complete*. And make sure what you
post actually does show the problem. You'll also need to tell us
exactly how the code is supposed to work, as well as a concise but
reasonably detailed description of the behaviour you observe and how
this differs from the behaviour you expect.
We can't tell anything from what you have posted. We're not mind
readers. You have to give us something to go on.

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
Nov 14 '05 #3

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

Similar topics

8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
3
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
1
by: Lonewolf | last post by:
Hi all, please pardon me if this sounds too simple. Basically I need to have inter process communication, between a native MFC applicationa nd my C# program. Basically it works something like...
3
by: James Robertson | last post by:
I am new to the ASP and VB thing so be kind. Question I have is that I have created an ASPX web site to use as an E-Mail page. But I want to use this for a lot of users. Can I create the link on...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
10
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication...
4
by: Deckarep | last post by:
Hello fellow C# programmers, This question is more about general practice and convention so here goes: I got into a discussion with a co-worker who insisted that as a general practice all...
7
by: =?Utf-8?B?YmVyaWNr?= | last post by:
New to this, I used to pass an array like this function BytesToString(byref myarray() as byte, somethingelse as long) as long and m = BytesToString(fooBar(), bluenose) This would send...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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
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...

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.