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