How do kernel functions work?

Usually, when a function is called, the function gets on the stack of the process and the calling function waits. But does the program stack require the right process? But the kernel is not part of any process (I call the kernel the part that performs file management and interprocess communication). But I assume that even the kernel uses some functions to perform various actions. So, how are these functions organized in the kernel if they do not use the process. ??

+4
source share
2 answers

You are confusing different things. Basically, the stack is an area in memory and some hardware support (the register to hold the top of the stack is esp and the register to hold the current base ebp of the stack frame, as well as the push, pop, call, ret commands. I mean x86) . When you installed this esp and the allocated memory for the stack - everything is ready, you can use it. Therefore, to use the stack you do not need to use the "process". The process is a concept of a different order. In other words, nothing contains a kernel to allocate a stack for itself ...

+2
source

, "syscall" (, "" ) x86 Linux . , 0x80 INT... ​​ ( - , HW ). . , ​​, .

+1

All Articles