5 ms·
> Thanks to Linus Torvalds, we not only have a consensus on architecture, but we've come pretty close to having a consensus on the input output mechanism by whi
by languageserver 4y ago
> Thanks to Linus Torvalds, we not only have a consensus on architecture, but we've come pretty close to having a consensus on the input output mechanism by which programs communicate with their host machines, via the SYSCALL instruction.
Could someone explain this? I cannot find any information online
- justinsaccount 4y agohttps://en.wikipedia.org/wiki/Linux_kernel_interfaces https://en.wikipedia.org/wiki/Linux_kernel_interfaces
- jart 4y agoThe Fifth Bell System Interface, Community Edition https://github.com/jart/cosmopolitan/blob/master/libc/sysv/syscalls.sh https://github.com/jart/cosmopolitan/blob/master/libc/sysv/s...
- throwaway09223 4y agoA syscall is a method for calling a kernel routine to do something outside the current process. All i/o (network, filesystem, ipc), memory allocation, process interaction, signals, etc go through syscalls. open(), read() and write() are all syscalls. If the syscall interface exists then the only thing left to do is to execute the program -- which depends on the cpu executing the machine instructions. If the machine instructions are for the wrong cpu then emulation may come into play.
- chubot 4y agoIt might help to understand API vs. ABI with respect to the C language and CPU architectures. I put definitions here awhile ago, and mentioned the Actually Portable Executable project as an example of taking the ABI philosophy to an extreme, and ignoring APIs (source code). https://www.oilshell.org/cross-ref.html#API https://www.oilshell.org/cross-ref.html#API Links to this thread: https://news.ycombinator.com/item?id=12029321 https://news.ycombinator.com/item?id=12029321 It's unfortunately not explained well in many places, and even experienced C programmers don't understand the details. You won't learn about this in a C programming book, because it's not really part of the C language proper. It sits at an awkward spot between the language, the CPU, and the operating system. ---- The relation to Linus Torvalds is that historically Unix kernels were developed in a single tree and there was no stable ABI. For example I believe OpenBSD and NetBSD are still like this. But Linux is different in that the kernel maintained a stable ABI, and you can run different user utilities on top, without necessarily recompiling them against headers. Highly related blog post and discussion: https://old.reddit.com/r/ProgrammingLanguages/comments/tg55ow/c_isnt_a_programming_language_anymore_faultlore/ https://old.reddit.com/r/ProgrammingLanguages/comments/tg55o... (including comments by me/oilshell explaining the Unix kernel interface issue)
- rfoo 4y agoIn short, a stable ABI is a must for portable (and backward-compatible) binaries. It does not matter where the stable ABI is. It is fine to have a stable userspace ABI only if you control the userspace. (e.g. Windows)
- d110af5ccf 4y agoThis provides some detailed low level information. https://wiki.osdev.org/System_Calls https://wiki.osdev.org/System_Calls