2019-2020-20199316 "Linux kernel principle and Analysis" in the third week of work

How the operating system works

(A) computer three magic weapons

  • Stored program computer
  • Function call stack mechanism
  • Interrupt mechanism

(B) the stack

(1) related to the stack register

  • ESP: Stack Pointer
  • EBP: base pointer, used as the recording current c function call in the language's base address.
    For the x86 architecture is concerned, stack space is from high address to low address growth.

(2) stack operations

  • push: Address reduce stack 4 bytes (32-bit), then the operand stack Yaru storage unit;
  • pop: stack address increase of 4 bytes (32 bits), then the contents stored back in the register stack.

    (3) Other key register

    CS: EIP: used to point to the next instruction address, its utility in several different situations:
  • Sequentially performed: consecutive addresses always points to the next instruction;
  • Jump / branch: when executing such instructions, CS: EIP values ​​may need to be modified in accordance with a program;
  • call: the current value stored onto stack, then entry point address of the called function;
  • ret: previously saved values ​​from the stack pop, back to CS: EIP in.

(C) experimental conditions


   >cd ~/LinuxKernel/linux-3.9.4
    >rm -rf mykernel
    >patch -p1 < ../mykernel_for_linux3.9.4sc.patch
    >make allnoconfig
    >make


然后进入到mykernel目录,查看mymain.c和myinterrupt.c:

    > cd mykernel


查看mymain.c文件:

    >vi mymain.c


查看myinterrupt.c文件:

    > vi myinterrupt.c

(D) summary

The study is mainly the process of switching. In the operating system, when the time runs out pieces need to switch process, the need to preserve the environment and the progress of the process to run until the next time when it is scheduled, the need to restore this operating environment. I think this is an operating system capable of multi-channel processing difficulty and focus!

Guess you like

Origin www.cnblogs.com/destiny-love/p/11609312.html