Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the use of an anonymous pipe introduce a memory barrier for interthread communication?

For example, say I allocate a struct with new and write the pointer into the write end of an anonymous pipe.

If I read the pointer from the corresponding read end, am I guaranteed to see the 'correct' contents on the struct?

Also of of interest is whether the results of socketpair() on unix & self connecting over tcp loopback on windows have the same guarantees.

The context is a server design which centralizes event dispatch with select/epoll

like image 800
Bwmat Avatar asked Mar 07 '16 06:03

Bwmat


People also ask

How to communicate using anonymous pipes within the process?

To communicate using anonymous pipes within the process or between the process we need a mechanism to pass pipe handle to client so that it can connect to the pipe created by server.Below are the steps. Parent creates Pipe hence its called pipe server. Get the handle for the pipe. Parent creates child and pass pipe handle to child

What is the use of anonymous pipes in Windows 10?

Pipes are a mechanism for inter process communication in windows.Pipes come in two varieties viz. Anonymous pipes and Named pipes.Anonymous pipes as name suggest do not have a name and can be used to communicate between threads or two related processes i.e. when one process initiates another process.

What is the difference between named and anonymous pipes?

Anonymous pipes provide interprocess communication on a local computer. They offer less functionality than named pipes, but also require less overhead. You can use anonymous pipes to make interprocess communication on a local computer easier. You cannot use anonymous pipes for communication over a network.

How to communicate between two threads in the same process?

You can use anonymous pipes to communicate between two threads in the same process.Below is the code for the same. using (AnonymousPipeServerStream pipedServer = new AnonymousPipeServerStream (PipeDirection.Out)) Console.Write (" [CLIENT] Press Enter to continue...");


1 Answers

For example, say I allocate a struct with new and write the pointer into the write end of an anonymous pipe.

If I read the pointer from the corresponding read end, am I guaranteed to see the 'correct' contents on the struct?

No. There is no guarantee that the writing CPU will have flushed the write out of its cache and made it visible to the other CPU that might do the read.

Also of of interest is whether the results of socketpair() on unix & self connecting over tcp loopback on windows have the same guarantees.

No.

like image 76
Cornstalks Avatar answered Sep 24 '22 22:09

Cornstalks