Operating Systems
COMP 3430 Guderian
Copyright By PowCoder代写 加微信 powcoder
Message-passing
Signals are good, but limited
We want to be able to send more than a stock messages + 2 customizable message
Message-passing how-to
A few ways to pass messages:
Message-passing how-to
A few ways to pass messages: Within OS – Pipes (aka FIFOs)
Message-passing how-to
A few ways to pass messages:
Within OS – Pipes (aka FIFOs) Sockets on loopback interface
Message-passing how-to
A few ways to pass messages:
Within OS – Pipes (aka FIFOs) Sockets on loopback interface
Both work about the same way, see 3010 for sockets
Anonymous and named
There are 2 types of pipes
Anonymous and named pipes
There are 2 types of pipes
Anonymous – where the two processes are related somehow
Anonymous and named pipes
There are 2 types of pipes
Anonymous – where the two processes are related somehow
Named – a file (because unix)
Pipes are managed by the kernel
Buffers information between readers and writers
Writes are atomic – never interfered with by a context switch.
man 7 pipe
Named Pipes
Named pipes are also called FIFOs Hello COMP 2140.
FIFOs can have many clients writing to it, and (should only have) one client reading from it.
Named Pipes
Work very similar to anonymous pipes – file descriptor we use read and write on.
Named Pipes (FIFOs)
Globally asscessible – a file!
man 2 mkfifo
man 7 fifo
But seriously…
A FIFO is a file on the file system that can be written to, and read from.
Code example…
We make a FIFO, and provide a path.
FIFO quirks
FIFOS block on open if mode is read, until there is a writer connected.
FIFOs do not block on open if mode is write.
Cleaning up FIFOs
Best to unlink them, rather than rm them. unlink is kinder to any fd that is open.
Client/Server example
client server
Then what?
This is message-passing, but we need to talk the same language.
We need to define a protocol. In the example, it just looks for \0 to delimit messages
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com