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?
or i should send the items ( x,c ) by value and reconstruct the list ?
my solution: create the list in a shared location in memory, where all the processes can use the same reference to manipulate or read the list, but if i use malloc(); i can't control the physical place where the memory is allocated (that's what i know)
hi elzalem,
there is no such think like a memory location since mem may be swaped out or what ever.
The solution depends on your requierements.
You can use a file in shared mem, the most simple solution.
of if not possible use a 'server task' that handles requests into the data structure
thanks for your reply grumpf , I've wrote a header file that contains several function to handle data structure swapping, i used message passing (message queues) but the thing is that i had to send everything by value (my data structures are complex :each node contains a queue and are filled with pointers).
I was hoping to be able to find a solution similar to the threads where all the processes share all the variables...
i have 2 linked lists that are constantly growing or shrinking, both r visible to all processes, i don't want each process to have a copy, i hope you're understanding what i mean.
without "shared memory" is it possible?
Then why bother with processes? Why not make it one process and use threads, that is effectively the same as multiple processes sharing one process' memory space.
because HE (my teacher) wants processes! No one in my class knows threads , so he didn't let me do it using threads!
I did some threads using C (windows), it'll take me 10 minutes to know how to do them under unix:S
C'est la vie!