user2277550
user2277550

Reputation: 619

How the kernel functions work?

Normally during a function call the function gets pushed into the stack part of the process and the calling function waits. But the program stack requires a process right? But the kernel is not part of any process (by kernel I mean the part that does file management and interprocess communication ) . But I assume even the kernel uses some kinds of functions to get various things done. So how are those functions in the kernel organized if they don’t use a process.??

Upvotes: 4

Views: 362

Answers (2)

timday
timday

Reputation: 24892

Related, there's a nice summary of how a "syscall" is made (the mechanism by which non-kernel processes call "into" the kernel) on x86 Linux here. The short story is, the calling process generates an interrupt with an 0x80 INT instruction... and then the kernel handles the interrupt (which is something kernels are quite good at, what with needing to deal with HW interrupts from peripherals and chipset and the like). See the article for the gnarly details of how the kernel figures out who created the interrupt and what they wanted.

Upvotes: 1

Alex Hoppus
Alex Hoppus

Reputation: 3935

You confusing things of a different sort. Basically stack is a region in memory and some hardware support (register to hold top of the stack - esp and register to hold current stack frame base ebp and push, pop, call, ret instructions. I mean x86). When you have established this esp and allocated memory for the stack - you are done, you can use it. So to use a stack you don't need to use a "process". Process is a conception of a different order. In other words nothing holds kernel from allocating a stack for itself ...

Upvotes: 2

Related Questions