Linux kernel Analysis Job: How the operating system works: Complete a simple time slice rotation multi-channel program kernel code

Source: Internet
Author: User

How the computer works

Three Magic Weapon: Store program computer, function call stack, interrupt mechanism.

Stack

Function call Framework

Passing parameters

Save return address

Provides local variable space

Stack-related registers

ESP stacking pointer (stack pointer)

EBP base point pointer (base pointer)

Stack operations

Push;pop

EBP serves as a record of the current function call base-

Other key registers

Interrupt

Call command: 1, the EIP of the next instruction to save the address a at the top of the stack; 2. Set the EIP to point at the beginning of the called Program code

1. Call XXX

2. Enter XXX

PUSHL%EBP

Movl%esp,%ebp

3. Exit XXX

MOVL%ebp,%esp

Pop%EBP

Ret

Summary: How the operating system works

Each program has its own execution flow, when the interrupt occurs, the CPU presses the current EIP into the kernel stack, and then points the EIP to the interrupt handler's entry. Set up a cycle, and then to determine whether or not to dispatch, this is the establishment of a scheduling mechanism, there will be a process of scheduling the switch. Because it is time-slice rotation, it is necessary to set up a time slice to set up a dispatch flag when the time slice is exhausted. The overall is the time slice ran out when set the dispatch flag, and then determine whether the need for scheduling with an infinite loop control, need to dispatch the process of switching.

Li Hai Empty original works reprint please indicate the source "Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000

Linux kernel Analysis Job: How the operating system works: Complete a simple time slice rotation multi-channel program kernel code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.