Newsgroups: comp.arch Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!sobeco!jlee From: jlee@sobeco.com (j.lee) Subject: Re: bi-endian environments Organization: Groupe Sobeco, Montreal, Canada Distribution: comp Date: Wed, 15 May 91 00:48:48 GMT Message-ID: <1991May15.004848.11929@sobeco.com> References: <159@titccy.cc.titech.ac.jp> <3225@spim.mips.COM> <168@titccy.cc.titech.ac.jp> <3308@spim.mips.COM> Sender: @sobeco.com Nntp-Posting-Host: sobeco.sobeco.com In <3308@spim.mips.COM> cprice@mips.com (Charlie Price) writes: >You *can* arrange to share ONE binary format. >I think the only reasonable one to pick is characters (i.e. bytes). This is what "network byte order" is all about. If I write(2) or mmap(2) a sequence of *bytes* on my system to disk/tape/tty/socket and you can't read(2) or mmap(2) them and get the same sequence of *bytes*, I would argue that someone's device driver is *bust*. On the other hand, if we both try to interpret those same bytes as a sequence of two-byte or four-byte (or even eight-byte) integers, the values we see can depend on our host byte-ordering (endian-ness). >When a page is accessed, and mapped to the process, >the OS must swap the bytes around within the page so that >character-stream order is preserved. >This in-memory page is now in a special state and it has to be >transformed back to the native character-stream order before it >can be written back to disk. >If a memory-mapped file page or shared memory segment page is accessed >by processes that have different endian-ness, the page has to be put into >the proper character-stream order before the access can be granted. Character (byte) stream order is *normally* preserved; in order to do the "conversion" you must shuffle the byte ordering around -- either when you map the page of data, or when you read a value from that page. However, a single, fixed, map-time transformation for *all* pages based only on "processor endian-ness" will not work; the transformation required for each page depends on the size and type (in the case of FP values) of the data being loaded/stored in that page. There is a paper by M. Stumm and S. Zhou of the University of Toronto on this in relation to a Distributed Shared Memory system for Heterogeneous Processors. They discuss a DSM system which shares data between Vaxen and Sun3s -- machines with different endian-ness, FP encoding, and page-size! I'm afraid that the exact reference escapes me at the moment. However the point is that data sharing between heterogeneous machines *can* be done, but requires knowledge of the structure and encoding of the data being exchanged. (The X11 protocol is a case in point.) I'm not sure whether or not we've tried to say the same thing, but if so, I hope that what I have said makes the point clearer. Jeff Lee -- jlee@sobeco.com || jonah@cs.toronto.edu