473,508 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory-resident message queue


From: qu******@gmail.com - view profile
Date: Wed, Apr 5 2006 12:56 am
Email: "quigs...@gmail.com" <quigs...@gmail.com>
Groups: comp.unix.programmer
Not yet rated
Rating:
show options

Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse | Find messages by this author

Hey Folks!

Here's the scenario: I'm trying to rapidly develop some C code that
interfaces with some embedded Python. I need custom message queues, to
pass data between the C and Python.

I'm looking for something more high-level than IPC shared memory.
Berkeley DB seems a very viable option, but I'm concerned that it can't
be kept completely memory resident (as I'm expecting millions of tiny
messages being passed back and forth, and I want to avoid high disk i/o
if possible).

The messages are to be strings of some (possibly dynamic) length. Some
metadata will have to be associated with each message, including a
unique integer id, and a few other minor things.

I've considered allocating a big block of memory and making some custom
API to it with an xml-rpc protocol. I'm much more inclined to use
something that is already out there, of course, especially since I'm
racing to get this code out the door. I also heard of Prevaylor
(Java-based prevalence layer), which is an interesting concept I hadn't
previously heard of.

Any thoughts or ideas? I'm open to anything, and I want to thank you
in advance for your time and consideration.

Regards,
John Quigley
https://chicagolug.org/~jquigley/

Apr 5 '06 #1
4 1876
qu******@gmail.com wrote:

<snip header stuff>
Here's the scenario: I'm trying to rapidly develop some C code that
interfaces with some embedded Python. I need custom message queues, to
pass data between the C and Python.
this is really off-topic to comp.lang.c I've added comp.programming to
the groups posted to
I'm looking for something more high-level than IPC shared memory.
Berkeley DB seems a very viable option, but I'm concerned that it can't
be kept completely memory resident (as I'm expecting millions of tiny
messages being passed back and forth, and I want to avoid high disk i/o
if possible).
how big can your queue get? If you are holding millions of entries in
the
queue it may get quite large.
The messages are to be strings of some (possibly dynamic) length. Some
metadata will have to be associated with each message, including a
unique integer id, and a few other minor things.

I've considered allocating a big block of memory and making some custom
API to it with an xml-rpc protocol. I'm much more inclined to use
something that is already out there, of course, especially since I'm
racing to get this code out the door. I also heard of Prevaylor
(Java-based prevalence layer), which is an interesting concept I hadn't
previously heard of.

Any thoughts or ideas? I'm open to anything, and I want to thank you
in advance for your time and consideration.


I'm rather a fan of roll-your own. XML-RPC seems a bit heavy weight to
me
but I don't know your application. I'd be thinking linked list or
cyclic buffer
in IPC. The dynamic strings sound a bit messy (is there an upper limit)
but not totally undoable. I'm sure the XP will be telling you to write
a test.
I'd ignore the shared memory bit for the moment and implment a simple
queing
system. Presumably there are libraries out there to do this sort of
thing.
Google?

In the past I've used linked lists of blocks of memory. Reasonable
compromise
between flexibility and simple memory management.
--
Nick Keighley

Apr 5 '06 #2
"qu******@gmail.com" <qu******@gmail.com> writes:
Berkeley DB seems a very viable option, but I'm concerned that it can't
be kept completely memory resident (as I'm expecting millions of tiny
messages being passed back and forth, and I want to avoid high disk i/o
if possible).


Berkeley DB has a memory-only mode.
--
"doe not call up Any that you can not put downe."
--H. P. Lovecraft
Apr 5 '06 #3
Nick Keighley wrote:
qu******@gmail.com wrote:

<snip header stuff>
Here's the scenario: I'm trying to rapidly develop some C code that
interfaces with some embedded Python. I need custom message queues, to
pass data between the C and Python.
this is really off-topic to comp.lang.c I've added comp.programming to
the groups posted to
I'm looking for something more high-level than IPC shared memory.
Berkeley DB seems a very viable option, but I'm concerned that it can't
be kept completely memory resident (as I'm expecting millions of tiny
messages being passed back and forth, and I want to avoid high disk i/o
if possible).


how big can your queue get? If you are holding millions of entries in
the
queue it may get quite large.
The messages are to be strings of some (possibly dynamic) length. Some
metadata will have to be associated with each message, including a
unique integer id, and a few other minor things.

I've considered allocating a big block of memory and making some custom
API to it with an xml-rpc protocol. I'm much more inclined to use
something that is already out there, of course, especially since I'm
racing to get this code out the door. I also heard of Prevaylor
(Java-based prevalence layer), which is an interesting concept I hadn't
previously heard of.

Any thoughts or ideas? I'm open to anything, and I want to thank you
in advance for your time and consideration.


[snip]

In the past I've used linked lists of blocks of memory. Reasonable
compromise
between flexibility and simple memory management.


I'd recommend a doubly-linked list for the simple fact that traversing
it would be a little less cpu-intensive than starting from the top of
the list and looping through untill you find the right entry. Since the
OP is using an integral type to uniquely identify the message you could
store them in sequential order from smallest to largest which would make
it faster to search through them.

Just my two cents worth.

Joe
Apr 6 '06 #4
Joe Estock wrote:
Nick Keighley wrote:
qu******@gmail.com wrote:
Here's the scenario: I'm trying to rapidly develop some C code that
interfaces with some embedded Python. I need custom message queues, to
pass data between the C and Python.


this is really off-topic to comp.lang.c I've added comp.programming to
the groups posted to
I'm looking for something more high-level than IPC shared memory.
Berkeley DB seems a very viable option, but I'm concerned that it can't
be kept completely memory resident (as I'm expecting millions of tiny
messages being passed back and forth, and I want to avoid high disk i/o
if possible).


how big can your queue get? If you are holding millions of entries in
the queue it may get quite large.
The messages are to be strings of some (possibly dynamic) length. Some
metadata will have to be associated with each message, including a
unique integer id, and a few other minor things.

I've considered allocating a big block of memory and making some custom
API to it with an xml-rpc protocol. I'm much more inclined to use
something that is already out there, of course, especially since I'm
racing to get this code out the door. I also heard of Prevaylor
(Java-based prevalence layer), which is an interesting concept I hadn't
previously heard of.

Any thoughts or ideas? I'm open to anything, and I want to thank you
in advance for your time and consideration.


In the past I've used linked lists of blocks of memory. Reasonable
compromise between flexibility and simple memory management.


I'd recommend a doubly-linked list for the simple fact that traversing
it would be a little less cpu-intensive than starting from the top of
the list and looping through untill you find the right entry. Since the
OP is using an integral type to uniquely identify the message you could
store them in sequential order from smallest to largest which would make
it faster to search through them.

Just my two cents worth.


yes but if its a true FIFO queue he can simply add to the tail and
remove from
the head. Just two pointers and double linking doesn't do much for you.
In m experience it's more usual to process messages in order of arrival
unless there are some special priority messages. Processing in order of
msg type sounds... odd.
--
Nick Keighley

Apr 6 '06 #5

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

Similar topics

32
3791
by: John | last post by:
Hi all: When I run my code, I find that the memory that the code uses keeps increasing. I have a PC with 2G RAM running Debian linux. The code consumes 1.5G memory by the time it finishes...
22
3449
by: xixi | last post by:
hi, we are using db2 udb v8.1 for windows, i have changed the buffer pool size to accommadate better performance, say size 200000, if i have multiple connection to the same database from...
8
2906
by: vikram | last post by:
i have series of questions 1.How a c program is loaded in memory i mean the whats is the structure that the code segment?? data segment?? 2.When you say const int *p; where is p...
14
20747
by: Alessandro Monopoli | last post by:
Hi all, I'm searching a PORTABLE way to get the available and total physical memory. Something like "getTotalMemory" and it returns the memory installed on my PC in bytes, and...
10
2755
by: s.subbarayan | last post by:
Dear all, I happen to come across this exciting inspiring article regarding memory leaks in this website: http://www.embedded.com/story/OEG20020222S0026 In this article the author mentions:...
8
3394
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
13
6124
by: hurry | last post by:
In order to avoid declaring static variables in a function I was asked to write a scratch memory. Reserve a block of memory outside the function and assigning pointers to the memory locations as...
1
3003
by: Nick Craig-Wood | last post by:
I've been dumping a database in a python code format (for use with Python on S60 mobile phone actually) and I've noticed that it uses absolutely tons of memory as compared to how much the data...
1
2021
by: Jean-Paul Calderone | last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote: The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after...
5
505
by: cham | last post by:
Hi, I am working on c++ in a linux system ( Fedora core 4 ), kernel version - 2.6.11-1.1369_FC4 gcc version - 4.0.0 20050519 ( Red Hat 4.0.0-8 ) In my code i am creating a vector to store...
0
7233
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
7342
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
7410
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
7505
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
5650
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
4729
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...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
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 ...
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.