Hi, what is main difference between shared memory and pipe in unix programming?
+3
A:
Taken from this article
(unnamed) Pipes
- Can switch between blocking and non-blocking mode
- Don't have to free them when done
- Are automatically inherited by children
- Must read and write in a linear fashion
Shared Memory
- Can store structures
- Won't ever block - positive
- Can have as many programs read or write to it as you need
- Won't ever block - negative: must use semaphores or your own spin-locks
- It's possible for it to not be freed even when all programs exit
Sachin Shanbhag
2010-09-09 11:26:10