What is the best way to send a linked list structure between processes over a pipe in Linux programming

I am trying to send a linked list between child processes that come from one parent. Child1 needs to find the first prime number in the list and delete it and its multiplicity, and then send Child2. Child2 does the same and it sends Child3, and ChildN does the same and sends Child1. However, I am trying to send the address data between all numbers, but this is the right way, because maybe I am forcing my child process to enter a different address space. So, what is the best way you think or in some other way instead of sending the address?

+3
source share
4 answers

System V ( , shmat) mmap, . Boost.Interprocess ++ , .

+2

, Eratothenes . , , . , , - , , .

Generator -> [Prime2] -> Prime3 -> Prime5 -> Prime7 -> ... PrimeP

. , 8 , Prime2 . 9, Prime2, Prime3, . 10 2, 11 , Prime7 , 11 . Prime2 , . Prime 2 20, Prime3 19 . (: Prime2 ).

PrimeN PrimeP, 2 , , . node 4 : / node, - / node. node , .

, , . :

read(parent, &value, sizeof(value))

write(stdout, &value, sizeof(value))

.

, :

  • PoisonPill (, 0 - ). .
  • SIGTERM .
  • SIGTERM PoisonPill (, , 2).

, PoisonPill; PoisonPill .

:

  • .
  • .
  • , . - Haskell, , C.
  • . shmem, fifo ..
  • ... . - , . PrimeProcessor. () . PrimeProcessor ( , , ) .

, , . , , .

+1

, .

(, Eratothenes, ).

0

If you use channels, you “delete” the recordings without recording the recording in the channel. So don’t worry about deleting data from the list, just think about whether to write the record you are reading from the input channel to the output channel.

0
source

All Articles