Stack in Linux: User State Stack /Kernel Stack /Interrupt Stack

  
 

Linux has a variety of stacks, it is easy to get rid of, simply explain: 1, user state stack: at the bottom of the process user state address space, as we usually understand and understand, is a section of the virtual address space, Not much to say ~ 2, the kernel stack: is independent of the user state stack, when the user state and kernel mode switch, you need to switch. The default 8k, can be modified by the kernel configuration item and put together with the thread_info structure, common one union: thread_union,


Click (here) to collapse or open

1. Union thread_union {2. struct thread_info thread_info;

3. unsigned long stack[THREAD_SIZE/sizeof(long)];

4. }; placed in a special section: __(" .data.init_task")))


Click (here) to collapse or open

1. union thread_union init_thread_union 2. __attribute__((__section__(".data .init_task"))) =

3. { INIT_THREAD_INFO(init_task) };



Click (here) to collapse or open

1. ENTRY(stack_start)2. .long init_thread_union+THREAD_SIZE

3. .long __BOOT_DS

The default is shared with the interrupt stack, which can be modified by the kernel configuration item, ie Each process has its own kernel stack 3. The interrupt stack: the default is shared with the kernel stack and the contents of the kernel stack are independent, interrupts, exceptions, and soft interrupts are used. This stack uses the kernel stack of the interrupted process. >

Copyright © Windows knowledge All Rights Reserved