lundi, janvier 28, 2008

A nice book

Learning basics in Operating Systems - mainly basics like fork() wait() .. and threads -, I'm reading a nice book, called "Systemes d'Exploitation" , from Bart Lamiroy, Laurent Najman, Hughues Talbot,
(Pearson Education, 2006 ISBN : 2-7440-7193-5)

.. and I spent the entire afternoon playing with structure alignments. The problem is very simple: two structures, containing the same members, but not in the same order. The memory occupation differs completely because of alignment. I tested my little program on several OS, but I need someone to test on windows ( please send me your results, since I don't use Windows at all)

I now remember the problem: there is a similar issue in OpenOffice.org bridges: imagine two API's, not ordering the same objects the same way, using different rules for alignment, padding and so on.
Now imagine a proxy in the middle, allowing in a transparent way, the exchanges between two ( or more) APIs.

For speed reasons, the proxy is written in assembler. that's exactly the reason why there is one bridge per peer OS/arch, and why this is not an easy task.

For the curious, I put everything there (I'll use the .c file to illustrate the memory occupation in my course)

Last but not least, feel free to drop me a mail if my code is dirty (very probable).
e.g., I had to solve some warnings issues when building on AMD64.

Update: fixed little leaks + replaced int with short