A simple loop multi-channel program kernel code implementation

Source: Internet
Author: User

Zhang Han + original works reproduced please specify the source + "Linux kernel analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000


First of all. Read the core code of the program

void __init My_start_kernel (void)
{
int i = 0;
while (1)
{
i++;
if (i%100000 = = 0)
PRINTK (kern_notice "My_start_kernel here%d \ n", i);

}
}

This is the startup function of the kernel code. C language writing. The loop portion is 100,000 times per run. Outputs a statement.

void My_timer_handler (void)
{
PRINTK (kern_notice "\n>>>>>>>>>>>>>>>>>my_timer_handler here <<<<<<<<<<<<<<<<<<\n\n ");
}

This code is called when the time is interrupted. Output a statement each time it is called.

It then consolidates the code that was written and then consolidates it into the Linux Kernel-3.9.4.


or download Mykernel_for_linux3.9.4sc.patch directly

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdtaxmzy0nzq1mw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

Then download the Linux kernel-3.9.4

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdtaxmzy0nzq1mw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

After the download is complete, unzip.

Enter the extracted directory:

    • CD linux-3.9.4
compile your own code into the linux-3.9.4 .

    • Patch-p1 <. /mykernel_for_linux3.9.4sc.patch
    • Make Allnoconfig
    • Make
Finally, install QEMU and execute kernel.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvdtaxmzy0nzq1mw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

last. Execution Kernel
execution results. The display of the terminal is in fact constantly changing. A section (assuming that the flicker is too fast, to increase the value of the function to slow down the speed of change)

Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

A simple loop multi-channel program kernel code implementation

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.