473,992 Members | 67,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read the memory from both C program and C++ program simultaneously

11 New Member
Hi ,

Can anyone suggest me how to read the contents from an Array from C program while the array is actually populated from another program in C++

More specifically, what i like to do is read some dynamic information from a file, populate into the memory so that both the C program and C++ program can access the runtime contents? Also, i'm working in an UNIX environment!

Thanks in Advance
Jan 25 '07 #1
8 2190
michaelb
534 Recognized Expert Contributor
If this file is more or less static you may consider simply reading this file in each program.

If you really need to support in-memory communication between two (or more) processes, then read on System V IPC (Inter-Process Communication)

I think you can employ some of the IPC facilities, named pipes, or shared memory.
Jan 25 '07 #2
priyachari
11 New Member
Thx michael.

But i need it since, there will be a more than 1 request trying to read and write the file concurrently. Hence, i need the file content, say for eg code,descriptio n and count to be prepopulated into memory and be able to update the count concurrently. Also, the update can be performed either from C++ program or C program also.

Can u suggest me, if fork can be of any use in this case...or should i go for IPC. i tried to populate the content by always loading the array content repeatedly in the memory using an indefinite loop ...but i wasnt able to read the content from another call though...

Thanx in advance
Jan 25 '07 #3
Motoma
3,237 Recognized Expert Specialist
Thx michael.

But i need it since, there will be a more than 1 request trying to read and write the file concurrently. Hence, i need the file content, say for eg code,descriptio n and count to be prepopulated into memory and be able to update the count concurrently. Also, the update can be performed either from C++ program or C program also.

Can u suggest me, if fork can be of any use in this case...or should i go for IPC. i tried to populate the content by always loading the array content repeatedly in the memory using an indefinite loop ...but i wasnt able to read the content from another call though...

Thanx in advance

Are you writing both the C and the C++ program?
Jan 25 '07 #4
priyachari
11 New Member
Motoma,

Yes, both C and C++ program needs to be run and i'm writing both of them...
Jan 25 '07 #5
Motoma
3,237 Recognized Expert Specialist
Motoma,

Yes, both C and C++ program needs to be run and i'm writing both of them...
Here is a decent article on the matter.
Jan 25 '07 #6
horace1
1,510 Recognized Expert Top Contributor
Motoma,

Yes, both C and C++ program needs to be run and i'm writing both of them...
also have a look at
http://www.cs.cf.ac.uk/Dave/C/node27.html

for IPC pipes, semaphores, messages, shared memory, etc
Jan 26 '07 #7
priyachari
11 New Member
also have a look at
http://www.cs.cf.ac.uk/Dave/C/node27.html

for IPC pipes, semaphores, messages, shared memory, etc
Thanks a lot for the article. The sample seems to solve pretty much the problem...
Jan 26 '07 #8
priyachari
11 New Member
Here is a decent article on the matter.
Thanks Motoma...The article is really good...
Jan 26 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6788
by: cnu | last post by:
My program generates a log file for every event that happens in the program. So, I open the file and keep it open till the end. This is how I open the file for writing: <CODE> public CLogHandler() { this.m_fsLog = new FileStream(strTodaysLogFile, System.IO.FileMode.Append, System.IO.FileAccess.Write, System.IO.FileShare.Read); this.m_swLog = new StreamWriter(this.m_fsLog);
50
3040
by: Joerg Schwerdtfeger | last post by:
Hi folks, how can I determine the total main-memory size and the size of free memory available in bytes? I tried to use mallinfo() from malloc.h - resulting some strange values in Windows (cygwin, gcc 3.3.1) and always 0 in Linux (2.4.22, gcc 3.3.2). Thanks in advance,
13
6196
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 per convenience and access them. I was told this would save some memory. I dont understand the logic behind this, as i`ve declared variables as global (assuming i`ve declared the block in main() ) this would always b a residual data for access at...
8
8571
by: Adrian | last post by:
Hi I have a JS program that runs localy (under IE6 only) on a PC but it has a memory leak (probably the known MS one!) What applications are there that I could use to look at the memory usage of each object within my JS app to help locate my problem? Thanks
1
6768
by: rveloso | last post by:
Hi all, i'm having a really nasty problem with popen. I have the following code : --------------------- .... FILE *PD; .... sprintf(fname,"/usr/bin/gzip -dc %s/%s",dirname,dp->d_name); .... if((PD = popen(fname, "r"))==NULL){ fprintf(stderr,"%d: Failed opening pipe to %s\n",errno,fname);
12
5487
by: Sean Davis | last post by:
I am working on a simple script to read from one database (oracle) and write to another (postgresql). I retrieve the data from oracle in chunks and drop the data to postgresql continuously. The author of one of the python database clients mentioned that using one thread to retrieve the data from the oracle database and another to insert the data into postgresql with something like a pipe between the two threads might make sense, keeping...
27
2990
by: George2 | last post by:
Hello everyone, Should I delete memory pointed by pointer a if there is bad_alloc when allocating memory in memory pointed by pointer b? I am not sure whether there will be memory leak if I do not delete a. try { a = new int ;
66
3759
by: karthikbalaguru | last post by:
Hi, Will 'free' return the memory Immediately to the OS ? Thx in advans, Karthik Balaguru
8
2145
by: Horacius ReX | last post by:
Hi, I am developing some code in C which first I compile on my linux machine and afterwards I test on another special hardware which has almost no debug capabilities at all. Usually I get a lot of errors in the latter, because I have memory size limitations. So, I wonder what are the best practices to know for a given program, once it is compiled and before its execution:
0
10228
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,...
1
11729
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
10998
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
8554
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
7710
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
6506
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...
0
6665
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5257
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
3
3842
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.