Hi,
I want to make 2 simple programs communicate each other with shared memory.
The programs will share an 2D array. In the first program (intarr.c) i create an x[3][4] array which is:
1 2 3 4
5 6 7 8
9 10 11 12
and i call the second program (intarr2.c) with execvp(); giving it the segment id as an argument. The intarr2.c just print the array to the terminal.
With this code i dont get any warning or error with gcc.
But the ./a.out gives me Segmentation fault.
Any ideas?
Probably operator precedence, among other problems.
If with that you're trying to define "x" as a pointer to a 3x4 array, I think offhand what you're actually getting is a 3x4 array of integer pointers. I'd guess that's probably not what you want.
And this:
That assigns the address of the shared memory segment to the [3][4] element of your array. That's almost certainly NOT what you want to do.
This definition might work, but I'm not going to dig through all the C operator precedence rules to find out:
You can always use typedef's to make it easier, because then you can build your complex declaration step-by-step:
Hello.
I am new to this forum and I would like to ask for advice about low level POSIX programming.
I have to implement a POSIX compliant C shared library.
A file will have some variables and the shared library will have some functions which need those variables.
There is one special... (5 Replies)
Hi Everyone,
#!/usr/bin/perl
use strict;
use warnings;
my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d");
would like to split the @test array into two array:
@test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d");
means search for 3rd filed.
Thanks
find the... (0 Replies)
Hi All,
How do I write into shared memory blocks using multiple threads? For example, I have created 50 threads to write into shared memory and 50 threads to read from shared memory.
I have already created a shared memory and I want to write into shared memory as follows:
... (0 Replies)
I am writing a shared library in Linux (but compatible with other UNIXes) and I want to allow multiple instances to share a piece of memory -- 1 byte is enough. What's the "best" way to do this? I want to optimize for speed and portability.
Obviously, I'll have to worry about mutual exclusion. (0 Replies)
I need to create a shared library to access an in memory DB. The DB is not huge, but big enough to make it cumbersome to carry around in every single process using the shared library. Luckily, it is pretty static information, so I don't need to worry much about synchronizing the data between... (12 Replies)
hi,
this is the problem: i want to swap a linked list between 4 processes (unrelated), is there any way i can do that just by sending a pointer to a structure?
//example
typedef struct node
{
int x;
char c;
struct node *next;
} node;
or i should send the items ( x,c ) by... (9 Replies)
I am running HP-UX B.11.11.
I'm increasing a parameter for a database engine so that it uses more memory to buffer the disk drive (to speed up performance). I have over 5GB of memory not being used.
But when I try to start the DB with the increased buffer parameter I get told.
"Not... (1 Reply)
Dear Reader,
Is is necessary to attach / dettach the shared memory segments for write operations , if more than one program is accessing same shared memory segments..
I have used semaphore mutex and still I'm getting segmentation fault when I write to the segment when other program is already... (1 Reply)