Android Deep Exploration--tenth chapter reading notes and Experiences

Source: Internet
Author: User

The call technology of embedded Linux

--10th Chapter reading notes and Experience

The PRINTK function is understood through the study in this chapter. This function is similar to the printf function for printing kernel debugging information. Just the former runs in kernel space and the latter runs in user space. Linux kernel programs such as Linux drivers can only use the PRINTK function to output debugging information. Prototype of the PRINTK function: Asmlinkkage int printk (const char *fmt,...). The PRINTK file is a simple text file with 4 numbers, and the default value of the file is Q 6 4 1 7. 6 represents the level at which messages are output to the console, and only output information above that level is output to the console. 4 represents the default message log level. If you do not make a log level in the PRINTK function, the value is used as the default level. 1 indicates the minimum value (highest priority) at which the console log level can be set. 7 represents the default value for the console log level.

The commands for querying log messages are:

#dmesg

#cat/var/long/syslog

#cat/proc/kmsg

#dmesg | grep PRINTK

Cat/var/log/syslog |grep PRINTK

Tail–n 10/var/log/syslog

Extensive use of the PRINTK function to manipulate log files or console device files can severely affect the performance of Linux drivers. Therefore, this requires that the Linux driver use the PRINTK function to output messages only during the development phase.

In Linux file systems,/proc is often used as a tool for data interaction between kernel space and user space. The/proc file system behaves in a similar manner to the device file system. /proc is a virtual file system, which is a memory map. All read and write/proc are read and write to memory. Therefore, reading and writing the/proc file system is much faster than reading/writing the/dev file system. As a result, the/proc file system can also serve as a tool for Linux to interact with user-space programs.

Android Deep Exploration--tenth chapter reading notes and Experiences

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.