473,654 Members | 2,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1869
"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_Keit h) 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 "technicall y correct" English; but since when was rock & roll "technicall y correct"?
Nov 14 '05 #3

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

Similar topics

8
3958
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer http://alexvn.freeservers.com/s1/perfometer.html
3
4748
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 around chunks of data in DataTables/DataSets, simply because that was the format that they were in when the data was taken from the database. Now, I know this maybe a pretty silly question with a standard "it depends" answer, but I'm going to...
22
25575
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 compile. <WebMethod()> _ Public Function VerifySku(ByVal skus As XmlDataDocument) As DataSet Test program : Dim cartSet As DataSet cartSet = ws.VerifySku(cartSet)
1
2212
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 this, the MFC application is asctual a keyboard hook which translate keyboard combinations into special codes. The keyboard in this case is actual a USB remote control which generates keyboard combinations in the range of F13 to F24, and VK keys of...
3
1981
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 the WEB site to mail to passing a variable from the WEB site to the ASPX web site to E-Mail to? Hope I explained this correctly. This is a response from another group. There was no way for you to know it, but this is a classic asp newsgroup....
9
3784
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 techniques are not feasible) The question is; Given that I have a Person object with a private set for id. What is the recommended approac in passing that object to the web service
10
3920
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication eventname string source string ID string
4
2808
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 objects should be passed by reference using the ref keyword generally speaking because as the writer of code you are conveying your intentions that an Object should/can be modified by your function.
7
1729
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 the descriptor or pointer to the array to the function
0
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.