Hacker News new | past | comments | ask | show | jobs | submit login
Anatomy of a system call, part 1 (lwn.net)
215 points by signa11 on July 18, 2014 | hide | past | favorite | 19 comments



Slighty off-topic: Over 100 points and zero comments? Is this article so good that there is literally nothing to add, does the comments section at lwn.net serve as an appropriate outlet or is there some other obvious reason I’m missing?

Back to topic: The comments there mention that binary-compatibility with other unices might have been a reason to have per-architecture syscall numbers, but fail to explain why the more recent architectures (x86_64 and arm, e.g.) would keep that compatibility – certainly tries to run, say, HP-UX binaries on Linux any longer?


Following your off-topic lead and lacking anything on-topic to say...

It seems to be very factual and describe what is with no editorialised position on whether anything is good or bad which reduces the opportunity for an exchange of valid viewpoints.

It might be that the article is interesting but without people feeling knowledgeable enough to add much. And if the article doesn't make any significant errors the knowledgeable people won't jump in with corrections.


From the OP (emphasis added):

> Originally (in the days of Linux 1.x / 2.0) Linux attempted to be binary compatible to existing Unices on common hardware (the personality(2) system call is also part of this). As time passed, compatibility with other Unices became mostly a non-issue – but now we do need to maintain binary compatibility with older Linux binaries


I can understand this for “old” architectures (i386), but if a new architecture is added, there are no binaries with which one could be (in)compatible?


We don't have that compatibility. Even BSDs and GNU/Linux on x86 have completely different calling conventions (ordinary C ABI vs registers + ptr to memory).

Edit: also Linux is made with completely moronic way to return errors (it uses some negative values as errors).


Using the high bit to indicate an error result isn't unknown on other OSes either - see NTSTATUS on Windows, and HRESULT in COM.


This has nothing to do neither with high bit nor with NTSTATUS. For Linux, some values are errors, all others are normal results. lseek cannot return large value for example. At all.


Please explain better ways for a syscall to return an error that negative status, and explain how OS other than Linux get it right.


Its Linux so you don't even need to look at a different OS. Each architecture is different. PowerPC returns the return value and error code in different registers which is very clean.


By setting cpu flag for example. Pretty standard way.


It's funny, I was just this morning digging into syscalls and how they work. I even submitted a link to one of the pages where I learned new things: https://news.ycombinator.com/item?id=8052183. Thanks for posting this one!


Technically this is not anatomy, but physiology.


Fascinating language pedantry.


I don't think it's pedantry. It's the same as some doctor coming to you with the words "The Internet is not working".


> It's the same as some doctor coming to you with the words "The Internet is not working".

The medical equivalent of that would be a patient coming in with "doc, I've go a pain", and when the MD asks where, they answer "I'm not sure". Which happens. In both cases, the professionals need to figure out what the underlying problem is, despite being given unhelpful information.

Now, as far as "The Anatomy of X" is concerned, that's somewhat of an overloaded expression. In this context, we generally do expect to not only get structural but also functional information.

If you expect human language to always follow pre-defined conventions, you're just setting yourself up for a lot of unnecessary grief. Language and the meaning conveyed by it are naturally subject to context variations, drift, re-appropriations, and a whole slew of other transformations.

But even linguistically, "The Anatomy of X" is a victimless crime. I guarantee you that not one reader here clicked on the article and went "oh my, I sure was hoping they'd just print out the structs involved and left it at that".

Anatomy is a word overloaded by context in a way Physiology is not. If the article was named "The Physiology of a System Call", that does invoke a medical context where none was expected.


The strict distinction between "anatomy" and "physiology" in medicine, with the former not including description of function but only structure, is also fairly recent, with older texts frequently using "anatomy" in a broader sense of "let's look inside and see what parts this has and what they do". The borrowing of that sense for the non-medical context happened before usage in medicine became more technical and specific, so more recent developments in medical jargon haven't changed the more generally understood meaning of the English word.

In any case, it's an established English word with a well-understood non-medical meaning that goes back really far in this sense, at least to the early 17th century, with John Donne's An Anatomy of the World (1611) and Robert Burton's The Anatomy of Melancholy (1622).


Interesting, didn't know this usage is so old. I (non-native) thought that it's some hipster programmer talk.


Strictly speaking it means dissection (to chop up or cut into I would more colloquially put it), which is appropriate in this case.

(Finally getting some use out of those years of Greek class!)


What the happen here and topic going wrong ??




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: