Driver interview sharing in Linux system

picture

1. How many types of drivers are there?

  • character device driver

  • block device driver

  • network device driver

2. What are the interfaces that character device drivers need to implement?

  • Open, close, read, write, ioctl and other interfaces.

3. The role of the major device number and the minor device number

  • The major device number and minor device number are used to identify the device in the system, the major device number is used to identify the type of device, and the minor device number is used to identify the specific device so that the system can identify the specific device.

4. The role of the cross compiler

  • Generate an executable program on one platform for another platform. For example, an executable program for the arm platform is generated on the x86 platform. Usually the embedded system is based on the arm platform. Since the computing power of the arm platform is relatively low, compiling large programs is slow, so the cross compiler is used to compile on the x86 platform, which greatly reduces the compilation time.

5. The difference between hard links and soft links

  • The soft link is equivalent to the shortcut of the window system, and the content stored in the soft link file is the absolute path of the source file. Deleting the source file will invalidate the soft link.

  • A hard link is another name that points to a file or directory that shares the same inode as the source file or directory, but has a different name. Deleting source files does not affect hard-linked files.

6. What are the components of the Linux kernel?

  • Process scheduling (SCHED), inter-process communication (IPC), memory management (MM), virtual file system (VFS), network interface (NET)

7. What synchronization methods does the Linux kernel have?

  • Atomic operations, semaphores, spin locks, read-write locks, sequential locks, etc.

8. What are the communication methods between user space and kernel space?

  • syscalls, signals, procfs, mmap, netlink, etc.

9. What is the relationship between BootLoader, Linux kernel, and root file system?

  • As soon as the system is powered on, BootLoader is executed to initialize the processor and peripherals, bringing the system's hardware and software environment to an appropriate state.

  • Then read the Linux kernel and the root file system from the non-volatile memory into the memory and execute the Linux kernel.

  • After the Linux kernel is initialized, a file system is mounted as the root file system.

10. The role of EXPORT_SYMBOL macro and EXPORT_SYMBOL_GPL macro in the linux kernel

  • The EXPORT_SYMBOL macro is used to export global variables and functions in the kernel module so that they can be called by other modules.

  • The EXPORT_SYMBOL_GPL macro is used to export global variables and functions in the kernel module, but it can only be called by GPL-licensed modules.

11. The role of container_of(ptr, type, member)

  • Knowing the address ptr of the member member of the structure type, find the starting address of the structure type

12. The difference between kmalloc and vmalloc

  • All are used for kernel space to apply for memory

  • kmalloc can apply for smaller memory; vmalloc can apply for larger memory

  • kmalloc guarantees that the requested memory is physically continuous; vmalloc guarantees that the requested memory is continuous in the virtual address space, but may not be physically continuous

13. What is the role of the memory management unit MMU?

  • address mapping.

  • Memory allocation and deallocation.

  • memory protection.

  • Memory expansion.

14. Briefly describe the process of MMU converting VA to PA

  • Taking the three-level page table as an example, the MMU obtains the base address of the first-level page table PGD by accessing the base address register of the page table, and then combines the PGD index in the virtual address to find the base address of the next-level page table PTE; the PTE is obtained The base address of the virtual address is combined with the PTE index in the virtual address to find the PFN, and then added to the VA to obtain the physical address.

15. What are the general methods of memory allocation in the operating system, and what are the advantages and disadvantages of each?

  • Paging storage management : The advantage is that no continuous memory space is required, and the memory utilization rate is high (only small in-page fragmentation); the disadvantage is that it is not easy to implement memory sharing and protection.

  • Segmented storage management : The advantage is that it is easy to implement segment memory sharing and protection; the disadvantage is that each segment requires continuous memory space, and the memory utilization rate is low (external fragmentation will be generated).

  • Segment page storage management : the advantage is that no continuous memory space is required, the memory utilization rate is high (only small in-page fragments), and it is easy to realize segment memory sharing and protection; the disadvantage is that the management software is more complex and requires more hardware And the occupied memory has also increased, making the execution speed drop.

end

Guess you like

Origin blog.csdn.net/weixin_41114301/article/details/132646065