管道和套接字 - “消息传递”或“共享内存”?
好吧,这是一个愚蠢的问题...
管道、FIFO 和套接字是共享内存还是消息传递..?
起初我以为它们是共享内存,因为管道使用 read() 和 write(),但现在我完全困惑了。从技术上讲,“消息”存储在内核的地址空间中,那么它是消息还是存储的内存?几个小时后我要参加操作系统简介考试,我只需要解决这个问题。提前致谢!
Ok, this is a stupid question...
Are pipes, FIFOs, and sockets shared memory or message passing..?
At first I thought they were shared memory because pipes use read() and write(), but now I'm just totally confused. Technically the "messages" are stored in the kernal's address space, so is it a message or stored memory? I have an exam for Intro to OS's in a few hours, and I just need this cleared up. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
消息传递,因为它们需要双方的参与,例如在套接字的情况下,发送者和接收者。它们可以使用共享内存来实现,但通信模式是消息传递
message passing, as they require participation on both sides, sender and receiver in case of sockets for example. they can be implemented using shared memory, but communication pattern is message passing
这是消息传递。您指定一个要写入套接字缓冲区的缓冲区,然后使用 getTxAvailable() 或其他方法事先了解它有多少可用空间。它并不是真正的共享内存,因为它执行缓冲区位块传输操作来帮助封装套接字。如果您谈论的是客户端上的套接字到服务器上的套接字,那么这也是消息传递。 Java 直接缓冲区或文件映射内存之类的东西就是共享内存。
It's message passing. You specify a buffer to write into the socket buffer, and you find out how much space it has available beforehand using getTxAvailable() or whatever. It's not really shared memory as it does a buffer blit operation to help encapsulation of the socket. If you're talking about socket on client to socket on server, that's also message passing. Something like a Java direct buffer or file-mapped memory is shared memory.