LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   kernel learning (https://www.linuxquestions.org/questions/linux-kernel-70/kernel-learning-4175622831/)

zlin 02-01-2018 01:19 AM

kernel learning
 
I want to know the role assemble language has played in learning linux kernel?

pan64 02-01-2018 03:07 AM

Hi and welcome to LQ.
Without knowing your level of knowledge about it it will be really hard (to answer).
But basically you do not need start with assembler to learn kernel.

Mara 02-01-2018 02:29 PM

You need to know assembly only if you enter in the low level architecture code (like boot, memory management unit) or do very high performance optimizations using specific instructions. If you're doing typical kernel development in the core code or drivers, you do not need to learn assembly.

sundialsvcs 02-06-2018 07:49 AM

You will find some assembly-level code in the /arch subtree.

Some of the code is pure-assembler, such as the so-called "trampoline" which hands control from the boot-loader to the kernel. Much of it takes the form of functions with asm {...} blocks which are used when specific machine instructions must be issued on a particular architecture.

Since Linux runs on well over twenty different architectures – "from mainframes to microwave ovens" – the use of assembly code is confined to these areas. Also notice how it is used to implement functions which are called by non-assembly code, and how the actual use of assembly code is minimized. (Because "compilers write better code than we do.")

The source-code sometimes uses macros, which are implemented on some architectures and no-ops on others.

Unlike "user-land" source code, the kernel code does not use any sort of "runtime library." (There is no glibc.)

Today's microprocessors aren't engineered to be programmed "by hand." They're engineered to accept object-code that has been produced by a compiler. Chip designers work closely with compiler designers, and also produce their own compilers. Assembly is now used only where there is no other alternative – where you are obliged to specify exactly what the CPU is to do. At all other times, "the compiler will produce better object-code than you would."


All times are GMT -5. The time now is 12:55 PM.