Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Managing linked list through child processes

Status
Not open for further replies.

Geeco

Technical User
Jun 30, 2003
8
FI
Hi,

I have a few questions about unix tcp/ip programming (C -language).
1) In client/server application I need to implement a dynamically linked list which could be edited through child processes. So if I create this linked list before calling the fork (), the child should be able to write into the linked list elements or add an element to the list. How can this be done because when forking, the child process gets a copy of data and if this child changes that data, the parent process doesn't see it.

2) this problem is similar to the previous: before fork() there is an item_counter which increases every time a child is created. Also every child should be able to increase this item_counter value if necessary. How can the item_counter hold its total value also outside of the child process?

Thanks.

 
>> I have a few questions about unix tcp/ip programming (C -language).

It seems your tcp/ip questions got lost in the transfer of your post across the tcp/ip connection [lol]


-pete
 
Your problem seems to be more well-suited for multiple threads instead of multiple processes. Each thread you create in your program will then be able to access the same data and all other threads will see any changes another thread makes. If you do this, you'll need to implement access protection (mutexes) to make sure that reads and writes to the shared data are atomic.

If you must use multiple processes, take a look at IPC. IPC allows processes to share data by maintaining the data outside all processes in the kernel. Your linked list could be implemented as a message queue and your counter could be implemented as a shared memory segment.
 
Like palbano had said the ?'s u've asked here are OS based ?'s ..and nothing dat involve TCP/IP or networking.

When u mean dat the parent/child shud share sumthing common between them. u may make use of message queues/pipes/shared memory. But note that the system imposes a size on them. i.e their max size. If iam right the size of message queues cant exceed more than 5K...
it varied from system to system.

for the counter u may make use of shared memory and for the linked list also u may make use of shared memory.
Pipes/message queues are generally used when there is a 2 way communication like sender-receiver... the tcp/ip way ;)

There are a lot of sites that actually give u code as in how to use these so coding it shudnt be a problem
hope this is of some help to you.
-vs

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top