英文:
How do Mach ports and Channel in Go Language relate with each other?
问题
Mach端口被广泛用作XNU(OS X和iOS的内核)中的进程间通信机制,它们充当消息队列的端点。
Go Channel被广泛认为是基于C. A. R. Hoare的通信顺序进程模型。那么Mach端口呢?不论端口的安全性和权限属性以及Go Channel的类型安全性如何,它们在本质上是否以相同的模式工作?
英文:
The Mach ports which are widely used as a mechanism for IPC in XNU(, the kernel for OS X and iOS), act as endpoints of queue of messages.
Go Channel is well known to be modeled after C. A. R. Hoare's Communicating Sequential Processes. How about Mach ports? Regardless of the security and rights properties of ports and type safety of Go Channel, are they working in the same pattern in nature?
答案1
得分: 2
根据wikipedia的说法,Mach端口是:
用于任务之间通信的受保护消息队列;任务拥有每个端口的发送和接收权限。
-
Go语言在其内存模型中实现了一些CSP概念。Mach端口的实现可以选择遵循CSP,但也可以不遵循。
-
Mach端口是一个更高级的结构,由操作系统内核管理,并且用于通信的是两个独立的内存空间。Go通道(通常)用于通信的是两个goroutine。
-
Go通道可以是带缓冲的(实际上构建了一个队列),但也可以不带缓冲,而Mach端口始终是队列。
-
Go通道是有类型的,而Mach端口不关心传输的信息是什么。
-
Go通道不能用于通信两个独立的进程,而Mach端口可以。
英文:
According to wikipedia a Mach port is:
> a protected message queue for communication between tasks; tasks own send and receive rights to each port
-
Go implements some of the CSP concepts in its memory model. Mach port implementations could but don't have to, follow CSP.
-
A Mach port is a much higher level structure, managed by the OS kernel and communicating two separate memory spaces. Go channels (usually) communicate two goroutines.
-
Go channels can be buffered (effectively building a queue) but don't have to be, whereas Mach ports are always queues.
-
Go channels are typed, Mach ports don't care about the information being transmitted.
-
A Go channel cannot be used to communicate two separate processes, a Mach port can.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论