<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
marshalling	O
or	O
marshaling	O
(	O
US	O
spelling	O
)	O
is	O
the	O
process	B-Operating_System
of	O
transforming	O
the	O
memory	B-Architecture
representation	O
of	O
an	O
object	O
into	O
a	O
data	O
format	O
suitable	O
for	O
storage	B-General_Concept
or	O
transmission	O
.	O
</s>
<s>
It	O
is	O
typically	O
used	O
when	O
data	O
must	O
be	O
moved	O
between	O
different	O
parts	O
of	O
a	O
computer	B-Application
program	I-Application
or	O
from	O
one	O
program	O
to	O
another	O
.	O
</s>
<s>
Marshalling	O
can	O
be	O
somewhat	O
similar	O
to	O
or	O
synonymous	O
with	O
serialization	B-Application
.	O
</s>
<s>
Marshalling	O
is	O
describing	O
an	O
intent	O
or	O
process	B-Operating_System
to	O
transfer	O
some	O
object	O
from	O
a	O
client	O
to	O
server	O
.	O
</s>
<s>
Serialization	B-Application
does	O
not	O
necessarily	O
have	O
this	O
same	O
intent	O
,	O
since	O
it	O
is	O
only	O
concerned	O
about	O
transforming	O
data	O
,	O
for	O
example	O
,	O
into	O
a	O
stream	O
of	O
bytes	O
.	O
</s>
<s>
Marshalling	O
and	O
serialization	B-Application
might	O
be	O
done	O
differently	O
,	O
but	O
some	O
form	O
of	O
serialization	B-Application
is	O
usually	O
used	O
to	O
do	O
marshalling	O
.	O
</s>
<s>
The	O
inverse	O
process	B-Operating_System
of	O
marshalling	O
is	O
called	O
unmarshalling	B-Application
(	O
or	O
demarshalling	O
,	O
similar	O
to	O
deserialization	B-Application
)	O
.	O
</s>
<s>
An	O
unmarshalling	B-Application
interface	O
takes	O
a	O
serialized	B-Application
object	I-Application
and	O
transforms	O
it	O
into	O
an	O
internal	O
data	O
structure	O
.	O
</s>
<s>
The	O
accurate	O
definition	O
of	O
marshalling	O
differs	O
across	O
programming	O
languages	O
such	O
as	O
Python	B-Language
,	O
Java	B-Language
,	O
and	O
.NET	B-Application
,	O
and	O
in	O
some	O
contexts	O
,	O
is	O
used	O
interchangeably	O
with	O
serialization	B-Application
.	O
</s>
<s>
To	O
"	O
serialize	B-Application
"	O
an	O
object	O
means	O
to	O
convert	O
its	O
state	O
into	O
a	O
byte	O
stream	O
in	O
such	O
a	O
way	O
that	O
the	O
byte	O
stream	O
can	O
be	O
converted	O
back	O
into	O
a	O
copy	O
of	O
the	O
object	O
.	O
</s>
<s>
The	O
term	O
"	O
marshal	O
"	O
is	O
used	O
for	O
a	O
specific	O
type	O
of	O
"	O
serialization	B-Application
"	O
in	O
the	O
Python	B-Language
standard	O
library	O
–	O
storing	O
internal	O
python	B-Language
objects	O
:	O
</s>
<s>
In	O
the	O
Java-related	O
,	O
marshalling	O
is	O
used	O
when	O
serialising	O
objects	O
for	O
remote	B-Operating_System
invocation	I-Operating_System
.	O
</s>
<s>
Hence	O
,	O
in	O
order	O
to	O
convert	O
the	O
object	O
state	O
and	O
codebase(s )	O
,	O
unmarshalling	B-Application
must	O
be	O
done	O
.	O
</s>
<s>
The	O
unmarshaller	O
interface	O
automatically	O
converts	O
the	O
marshalled	O
data	O
containing	O
codebase(s )	O
into	O
an	O
executable	O
Java	B-Language
object	O
in	O
JAXB	B-Language
.	O
</s>
<s>
In	O
Microsoft	O
.NET	B-Application
,	O
marshalling	O
is	O
also	O
used	O
to	O
refer	O
to	O
serialization	B-Application
when	O
using	O
remote	O
calls	O
:	O
</s>
<s>
Marshalling	O
is	O
used	O
within	O
implementations	O
of	O
different	O
remote	B-Operating_System
procedure	I-Operating_System
call	I-Operating_System
(	O
RPC	O
)	O
mechanisms	O
,	O
where	O
it	O
is	O
necessary	O
to	O
transport	O
data	O
between	O
processes	O
and/or	O
between	O
threads	B-Operating_System
.	O
</s>
<s>
In	O
Microsoft	O
's	O
Component	B-Application
Object	I-Application
Model	I-Application
(	O
COM	O
)	O
,	O
interface	O
pointers	O
must	O
be	O
marshalled	O
when	O
crossing	O
COM	O
apartment	O
boundaries	O
.	O
</s>
<s>
In	O
the	O
.NET	B-Application
Framework	I-Application
,	O
the	O
conversion	O
between	O
an	O
unmanaged	O
type	O
and	O
a	O
CLR	O
type	O
,	O
as	O
in	O
the	O
P/Invoke	O
process	B-Operating_System
,	O
is	O
also	O
an	O
example	O
of	O
an	O
action	O
that	O
requires	O
marshalling	O
to	O
take	O
place	O
.	O
</s>
<s>
Additionally	O
,	O
marshalling	O
is	O
used	O
extensively	O
within	O
scripts	O
and	O
applications	O
that	O
use	O
the	O
XPCOM	B-Application
technologies	O
provided	O
within	O
the	O
Mozilla	B-Application
application	I-Application
framework	I-Application
.	O
</s>
<s>
The	O
Mozilla	B-Application
Firefox	I-Application
browser	O
is	O
a	O
popular	O
application	O
built	O
with	O
this	O
framework	O
,	O
that	O
additionally	O
allows	O
scripting	B-Language
languages	I-Language
to	O
use	O
XPCOM	B-Application
through	O
XPConnect	O
(	O
Cross-Platform	O
Connect	O
)	O
.	O
</s>
<s>
In	O
the	O
Microsoft	B-Application
Windows	I-Application
family	O
of	O
operating	O
systems	O
the	O
entire	O
set	O
of	O
device	O
drivers	O
for	O
Direct3D	B-Application
are	O
kernel-mode	O
drivers	O
.	O
</s>
<s>
This	O
is	O
an	O
issue	O
because	O
calling	O
kernel-mode	O
operations	O
from	O
user-mode	O
requires	O
performing	O
a	O
system	B-Operating_System
call	I-Operating_System
,	O
and	O
this	O
inevitably	O
forces	O
the	O
CPU	B-General_Concept
to	O
switch	O
to	O
"	O
kernel	O
mode	O
"	O
.	O
</s>
<s>
During	O
this	O
time	O
,	O
the	O
CPU	B-General_Concept
is	O
unable	O
to	O
perform	O
any	O
operations	O
.	O
</s>
<s>
Linux	O
OpenGL	B-Application
drivers	O
are	O
split	O
in	O
two	O
:	O
a	O
kernel-driver	O
and	O
a	O
user-space	O
driver	O
.	O
</s>
<s>
The	O
user-space	O
driver	O
does	O
all	O
the	O
translation	O
of	O
OpenGL	B-Application
commands	O
into	O
machine	O
code	O
to	O
be	O
submitted	O
to	O
the	O
GPU	B-Architecture
.	O
</s>
<s>
To	O
reduce	O
the	O
number	O
of	O
system	B-Operating_System
calls	I-Operating_System
,	O
the	O
user-space	O
driver	O
implements	O
marshalling	O
.	O
</s>
<s>
If	O
the	O
GPU	B-Architecture
's	O
command	O
buffer	O
is	O
full	O
of	O
rendering	O
data	O
,	O
the	O
API	O
could	O
simply	O
store	O
the	O
requested	O
rendering	O
call	O
in	O
a	O
temporary	O
buffer	O
and	O
,	O
when	O
the	O
command	O
buffer	O
is	O
close	O
to	O
being	O
empty	O
,	O
it	O
can	O
perform	O
a	O
switch	O
to	O
kernel-mode	O
and	O
add	O
a	O
number	O
of	O
stored	O
commands	O
all	O
at	O
once	O
.	O
</s>
<s>
XML	B-Protocol
is	O
one	O
means	O
of	O
transferring	O
data	O
between	O
systems	O
.	O
</s>
<s>
of	O
the	O
Microsoft	O
Office	O
suite	O
(	O
see	O
Office	B-Operating_System
Open	I-Operating_System
XML	I-Operating_System
)	O
.	O
</s>
<s>
While	O
this	O
typically	O
results	O
in	O
a	O
verbose	O
wire	O
format	O
,	O
XML	B-Protocol
's	O
fully-bracketed	O
"	O
start-tag	O
"	O
,	O
"	O
end-tag	O
"	O
syntax	O
allows	O
provision	O
of	O
more	O
accurate	O
diagnostics	O
and	O
easier	O
recovery	O
from	O
transmission	O
or	O
disk	O
errors	O
.	O
</s>
<s>
In	O
addition	O
,	O
because	O
the	O
tags	O
occur	O
repeatedly	O
,	O
one	O
can	O
use	O
standard	O
compression	O
methods	O
to	O
shrink	O
the	O
content	O
—	O
all	O
the	O
Office	O
file	O
formats	O
are	O
created	O
by	O
zipping	O
the	O
raw	O
XML	B-Protocol
.	O
</s>
<s>
Alternative	O
formats	O
such	O
as	O
JSON	B-General_Concept
(	O
JavaScript	B-General_Concept
Object	I-General_Concept
Notation	I-General_Concept
)	O
are	O
more	O
concise	O
,	O
but	O
correspondingly	O
less	O
robust	O
for	O
error	O
recovery	O
.	O
</s>
<s>
Hence	O
,	O
unmarshalling	B-Application
is	O
generally	O
used	O
in	O
the	O
receiver	O
end	O
of	O
the	O
implementations	O
of	O
Remote	B-Operating_System
Method	I-Operating_System
Invocation	I-Operating_System
(	O
RMI	O
)	O
and	O
Remote	B-Operating_System
procedure	I-Operating_System
call	I-Operating_System
(	O
RPC	O
)	O
mechanisms	O
to	O
unmarshal	O
transmitted	O
objects	O
in	O
an	O
executable	O
form	O
.	O
</s>
<s>
JAXB	B-Language
or	O
Java	B-Language
Architecture	I-Language
for	I-Language
XML	I-Language
Binding	I-Language
is	O
the	O
most	O
common	O
framework	O
used	O
by	O
developers	O
to	O
marshal	O
and	O
unmarshal	O
Java	B-Language
objects	O
.	O
</s>
<s>
JAXB	B-Language
provides	O
for	O
the	O
interconversion	O
between	O
fundamental	O
data	O
types	O
supported	O
by	O
Java	B-Language
and	O
standard	O
XML	B-Protocol
schema	O
data	O
types	O
.	O
</s>
<s>
XmlSerializer	O
is	O
the	O
framework	O
used	O
by	O
C#	B-Application
developers	O
to	O
marshal	O
and	O
unmarshal	O
C#	B-Application
objects	O
.	O
</s>
<s>
One	O
of	O
the	O
advantages	O
of	O
C#	B-Application
over	O
Java	B-Language
is	O
that	O
C#	B-Application
natively	O
supports	O
marshalling	O
due	O
to	O
the	O
inclusion	O
of	O
XmlSerializer	O
class	O
.	O
</s>
<s>
Java	B-Language
,	O
on	O
the	O
other	O
hand	O
requires	O
a	O
non-native	O
glue	B-General_Concept
code	I-General_Concept
in	O
the	O
form	O
of	O
JAXB	B-Language
to	O
support	O
marshalling	O
.	O
</s>
<s>
An	O
example	O
of	O
unmarshalling	B-Application
is	O
the	O
conversion	O
of	O
an	O
XML	B-Protocol
representation	O
of	O
an	O
object	O
to	O
the	O
default	O
representation	O
of	O
the	O
object	O
in	O
any	O
programming	O
language	O
.	O
</s>
<s>
XML	B-Protocol
representation	O
of	O
Student	O
object	O
:	O
</s>
<s>
Unmarshalling	B-Application
converts	O
the	O
XML	B-Protocol
representation	O
of	O
Code	O
Snippet	O
1	O
to	O
the	O
default	O
executable	O
Java	B-Language
representation	O
of	O
Code	O
Snippet	O
2	O
.	O
</s>
<s>
The	O
process	B-Operating_System
of	O
unmarshalling	B-Application
XML	B-Protocol
data	O
into	O
an	O
executable	O
Java	B-Language
object	O
is	O
taken	O
care	O
of	O
by	O
the	O
in-built	O
Unmarshaller	O
class	O
.	O
</s>
<s>
The	O
unmarshal	O
methods	O
defined	O
in	O
the	O
Unmarshaller	O
class	O
are	O
overloaded	B-Language
to	O
accept	O
XML	B-Protocol
from	O
different	O
types	O
of	O
input	O
such	O
as	O
a	O
File	O
,	O
FileInputStream	O
,	O
or	O
URL	O
.	O
</s>
<s>
Unmarshal	O
methods	O
can	O
deserialize	B-Application
an	O
entire	O
XML	B-Protocol
document	I-Protocol
or	O
a	O
small	O
part	O
of	O
it	O
.	O
</s>
<s>
When	O
the	O
XML	B-Protocol
root	O
element	O
is	O
globally	O
declared	O
,	O
these	O
methods	O
utilize	O
the	O
JAXBContext	O
's	O
mapping	O
of	O
XML	B-Protocol
root	O
elements	O
to	O
JAXB	B-Language
mapped	O
classes	O
to	O
initiate	O
the	O
unmarshalling	B-Application
.	O
</s>
<s>
If	O
the	O
mappings	O
are	O
not	O
sufficient	O
and	O
the	O
root	O
elements	O
are	O
declared	O
locally	O
,	O
the	O
unmarshal	O
methods	O
use	O
declaredType	O
methods	O
for	O
the	O
unmarshalling	B-Application
process	B-Operating_System
.	O
</s>
<s>
The	O
unmarshal	O
method	O
uses	O
JAXBContext	O
to	O
unmarshal	O
the	O
XML	B-Protocol
data	O
,	O
when	O
the	O
root	O
element	O
is	O
globally	O
declared	O
.	O
</s>
<s>
The	O
JAXBContext	O
object	O
always	O
maintains	O
a	O
mapping	O
of	O
the	O
globally	O
declared	O
XML	B-Protocol
element	O
and	O
its	O
name	O
to	O
a	O
JAXB	B-Language
mapped	O
class	O
.	O
</s>
<s>
If	O
the	O
XML	B-Protocol
element	O
name	O
or	O
its	O
@xsi	O
:type	O
attribute	O
matches	O
the	O
JAXB	B-Language
mapped	O
class	O
,	O
the	O
unmarshal	O
method	O
transforms	O
the	O
XML	B-Protocol
data	O
using	O
the	O
appropriate	O
JAXB	B-Language
mapped	O
class	O
.	O
</s>
<s>
However	O
,	O
if	O
the	O
XML	B-Protocol
element	O
name	O
has	O
no	O
match	O
,	O
the	O
unmarshal	O
process	B-Operating_System
will	O
abort	O
and	O
throw	O
an	O
UnmarshalException	O
.	O
</s>
<s>
By	O
an	O
order	O
of	O
precedence	O
,	O
even	O
if	O
the	O
root	O
name	O
has	O
a	O
mapping	O
to	O
an	O
appropriate	O
JAXB	B-Language
class	O
,	O
the	O
declaredType	O
overrides	O
the	O
mapping	O
.	O
</s>
<s>
However	O
,	O
if	O
the	O
@xsi	O
:type	O
attribute	O
of	O
the	O
XML	B-Protocol
data	O
has	O
a	O
mapping	O
to	O
an	O
appropriate	O
JAXB	B-Language
class	O
,	O
then	O
this	O
takes	O
precedence	O
over	O
declaredType	O
parameter	O
.	O
</s>
