I am currently reading 'Linux Kernel Development' by Robert Love and I do not understand what this bit of assembly is doing.
Basically, in each process kernel stack, there is a struct thread_info
which resides at the end of the stack. Now, on the x86 architecture, we can apparently grab this (assuming 8KB stack size) by using the following assembly
movl $-8192, %eax
andl %esp, %eax
So basically ANDing the stack pointer by 0xffffe000. I'm confused as to what is going on here? I don't see why masking the least significant 13 bits of %esp
takes us to the struct. I know I'll feel stupid once it is explained, but it is bugging me.
Thanks.
Linux kernel programming is fairly easy. It is not required to have access to special hardware. There is still a lot of work to be done. You can allocate as much time as you want and as you can.
The Linux® kernel is the main component of a Linux operating system (OS) and is the core interface between a computer's hardware and its processes. It communicates between the 2, managing resources as efficiently as possible.
The kernel development is a continuous process. A new version of the kernel is released when a set of features and bug fixes are ready. These new versions are called kernel releases. This process initiates with Linus Torvalds, wherein, he releases a new kernel and then opens a 2-week merge window.
Linux Kernel Developer Salary. $127,000 is the 25th percentile. Salaries below this are outliers. $247,000 is the 90th percentile.
The stack grows downwards, so the end of the stack is the lowest address in the stack, and the structure's starting address. And stacks are stored at multiples of 8KB. Therefore, erasing the 13 least significant bits gets the lowest address of the stack and therefore the start of the structure. Does this make sense?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With