1) The document discusses named pipes (also called FIFOs) which allow communication between unrelated processes. Named pipes have a name and persist in the file system.
2) It provides an example of a client/server program that uses a named pipe for communication. The server creates and opens the pipe for reading while the client opens it for writing.
3) select() can be used to multiplex I/O on multiple file descriptors, including named pipes. An example demonstrates using select() to handle requests on multiple printer pipes.
1) The document discusses named pipes (also called FIFOs) which allow communication between unrelated processes. Named pipes have a name and persist in the file system.
2) It provides an example of a client/server program that uses a named pipe for communication. The server creates and opens the pipe for reading while the client opens it for writing.
3) select() can be used to multiplex I/O on multiple file descriptors, including named pipes. An example demonstrates using select() to handle requests on multiple printer pipes.
1) The document discusses named pipes (also called FIFOs) which allow communication between unrelated processes. Named pipes have a name and persist in the file system.
2) It provides an example of a client/server program that uses a named pipe for communication. The server creates and opens the pipe for reading while the client opens it for writing.
3) select() can be used to multiplex I/O on multiple file descriptors, including named pipes. An example demonstrates using select() to handle requests on multiple printer pipes.
1) The document discusses named pipes (also called FIFOs) which allow communication between unrelated processes. Named pipes have a name and persist in the file system.
2) It provides an example of a client/server program that uses a named pipe for communication. The server creates and opens the pipe for reading while the client opens it for writing.
3) select() can be used to multiplex I/O on multiple file descriptors, including named pipes. An example demonstrates using select() to handle requests on multiple printer pipes.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online from Scribd
Download as pdf or txt
You are on page 1of 6
Operating Systems
Department of Informatcs Engneerng
FCTUC Unversty of Combra
Named Pipes &
/O Multiplexing 2 Named Pipes (also known as FFOs)
Smar to ppes but aow communcaton between
unreated processes.
Each ppe has a name ().
The ppe s wrtten persstenty n the fe system.
For creatng a named ppe, use the "mkffo" command or
ca mkffo(const char* fename, mode_t mode);
Typcay, ke ppes, they are haf-dupex
Means that they must be open read-ony or wrte-ony
They are opened ke fes, but they are not files
You cannot fseek() a named ppe; wrte() aways appends
to the ppe, read() aways returns data from the begnnng of the ppe.
After data s read from the named ppe, ts no onger
there. Its not a fe, ts an ob|ect n the unx kerne!
If you get a SIGPIPE sgna, ths means that you are tryng to read/wrte from a cosed ppe
A named ppe s a connecton between two processes. A
process bocks unt the other party open the ppe...
Beng t for readng or wrtng.
Its possbe to bypass ths behavor (open t non-bockng
- O_NONBLOCK), but be very, very carefu: f not propery programmed, t can ead to busy watng. If a named ppe s open non-bockng, EOF s ndcated when read() returns 0.
When desgnng a cent/server mutpe cent appcaton,
ths means that ether the ppe s re-opened after each cent dsconnects, or the ppe s open read-wrte.
If opened "read-wrte", the server w not bock unt the
other party connects (snce, he tsef s aso another party!)
9 select()
Carefu: n s the number of the hghest fe
descrptor added of one.
Its not the number of fe descrptors
fd_set A bt set representng fe descrptors
FD_ZERO(fd_set* set) Ceans up the fe descrptor set
FD_SET(nt fd, fd_set* set)
Sets a bt n the fe descrptor set
FD_CLEAR(nt fd, fd_set* set)
Cears a bt n the fe descrptor set
FD_ISSET(nt fd, fd_set* set)
Tests f a fe descrptor s set 10 Example (printerd.c) {...) #de11he BbF_STZE 4096 #de11he hbh_PRThTERS 3 cohs1 chaJ* PRThTER_hAhE|] = { "pJ1h1eJ1", "pJ1h1eJ2", "pJ1h1eJ3" }, // The pJ1h1eJ 11e descJ1p1oJs 1h1 pJ1h1eJ|hbh_PRThTERS], vo1d cJea1e_pJ1h1eJs{) { 1oJ {1h1 1=0, 1<hbh_PRThTERS, 1++) { uh1hk{PRThTER_hAhE|1]), mk111o{PRThTER_hAhE|1], 0_CREAT]0_EXCL]0666), pJ1h1eJ|1] = opeh{PRThTER_hAhE|1], 0_R00hLY]0_h0hBL0CK), asseJ1{pJ1h1eJ|1] >= 0), } } 1h1 ma1h{1h1 aJgc, chaJ* aJgv|]) { cJea1e_pJ1h1eJs{), accep1_Jeques1s{), }