什么是编组?当“编组"某物时会发生什么? [英] What is marshalling? What is happening when something is "marshalled?"

查看:101
本文介绍了什么是编组?当“编组"某物时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道已经问过这个问题,至少这里.

但是没有一个令人满意的答案,至少对我来说不是.关于与非托管代码进行互操作方面的封送,有很多讨论,但是,从一个线程到另一个线程的封送又是怎么回事,就像我们有时在.NET中所做的那样.

这让我问,什么是编组,真的吗?当您给出编组的定义时,您将如何定义它以便解释互操作性的情况以及线程之间编组"的情况?

解决方案

计算通常需要将数据从一个站点移动到另一个站点,并且没有任何共享内存.因此,一种计算会将包含数据的消息发送给另一种.

如果数据非常复杂,如何通过消息发送?

编组是将数据字段或整个相关结构集转换为可在消息中发送的序列化字符串的过程.封送二进制文件 数字,如果消息格式必须为文本,则可以将其转换为十六进制数字字符串.如果消息将携带二进制数据,则二进制数可能会转换为4个little-endian标准化二进制字节,并以这种方式发送.指针更难.人们通常不得不将它们转换为独立于实际内存位置的抽象引用(例如,节点号").

当然,如果封送"数据,则最终必须解组",这是读取串行流并重建传输的数据(结构)的过程.

通常在库中有用于完成此目的的(非)编组例程,有时甚至有一些工具可以制造(非)编组例程上用于发送/接收数据的所有调用. /p>

I know this question has been asked, at least here.

But there wasn't a satisfactory answer, at least not to me. There is a lot of talk about marshalling as regards interoperating with unmanaged code, but what about marshalling from one thread to another, as we have to do in .NET sometimes.

This makes me ask, what is marshalling, really? When you give a definition of marshalling, how would you define it so that it is explaining the case of interoperability, as well as the cases where you are "marshalling" between threads?

解决方案

Computations often need to move data from one site to another, and don't have any shared memory. So one computation sends a message containing the data to the other.

How should that data, if it is arbitrarily complicated, be sent in a message?

Marshalling is the process of converting a data field, or an entire set of related structures, into a serialized string that can be sent in a message. To marshall a binary number, one might convert it to hexadecimal digit string, if the message format must be text. If the message will carry binary data, the binary number might be converted into 4 little-endian normalized binary bytes and sent that way. Pointers are harder; one often has to convert them into an abstract reference (e.g., a "node number") that is independent of the actual memory locations.

Of course, if you "marshall" data, you must eventually "unmarshall", which is the process of reading the serial stream and reconstructing the transmitted data (structure).

Often there are (un)marshalling routines in a library that are used to accomplish this purpose, and sometimes there are even tools that will manufacture all the calls needed on the (un)marshalling routines to send/recieve the data.

这篇关于什么是编组?当“编组"某物时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆