Example: quiz answers

Linux Kernel 2.4 Internals - Linux Documentation Project

Linux Kernel Internals Linux Kernel Internals Table of Contents Linux Kernel Tigran Aivazian 1. 2. Process and Interrupt 3. Virtual Filesystem (VFS)..2. 4. Linux Page 5. IPC 1. Building the Linux Kernel Booting: Booting: BIOS Booting: bootsector and Using LILO as a High level SMP Bootup on Freeing initialisation data and Processing Kernel command 2. Process and Interrupt Task Structure and Process Creation and termination of tasks and Kernel Linux Linux linked list Wait Kernel Bottom Task How System Calls Are Implemented on i386 Architecture?..25. Atomic Spinlocks, Read write Spinlocks and Big Reader Semaphores and read/write Kernel Support for Loading 3.

Linux Kernel 2.4 Internals Tigran Aivazian tigran@veritas.com 7 August 2002 (29 Av 6001) Introduction to the Linux 2.4 kernel. The latest copy of this document can be always downloaded from:

Tags:

  Linux, Internal, Kernel, Linux kernel 2, 4 internals

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Linux Kernel 2.4 Internals - Linux Documentation Project

1 Linux Kernel Internals Linux Kernel Internals Table of Contents Linux Kernel Tigran Aivazian 1. 2. Process and Interrupt 3. Virtual Filesystem (VFS)..2. 4. Linux Page 5. IPC 1. Building the Linux Kernel Booting: Booting: BIOS Booting: bootsector and Using LILO as a High level SMP Bootup on Freeing initialisation data and Processing Kernel command 2. Process and Interrupt Task Structure and Process Creation and termination of tasks and Kernel Linux Linux linked list Wait Kernel Bottom Task How System Calls Are Implemented on i386 Architecture?..25. Atomic Spinlocks, Read write Spinlocks and Big Reader Semaphores and read/write Kernel Support for Loading 3.

2 Virtual Filesystem (VFS)..33. Inode Caches and Interaction with Filesystem File Descriptor File Structure Superblock and Mountpoint Example Virtual Filesystem: Example Disk Filesystem: Execution Domains and Binary 4. Linux Page 5. IPC Semaphore System Call sys_semget()..53. sys_semctl()..53. i Linux Kernel Internals Table of Contents Linux Kernel Internals sys_semop()..53. Non blocking Semaphore Failing Semaphore Blocking Semaphore Semaphore Specific Support struct struct struct struct struct struct struct Semaphore Support newary()..57. freeary()..57. semctl_down()..57. semctl_nolock()..58. IPC_INFO and semctl_main().

3 58. count_semncnt()..59. count_semzcnt()..59. update_queue()..59. try_atomic_semop()..60. sem_revalidate()..60. freeundos()..60. alloc_undo()..61. sem_exit()..61. Message Message System Call sys_msgget()..61. sys_msgctl()..62. IPC_INFO ( or MSG_INFO)..62. IPC_STAT ( or MSG_STAT)..62. sys_msgsnd()..62. ii Linux Kernel Internals Table of Contents Linux Kernel Internals sys_msgrcv()..63. Message Specific struct struct struct struct struct struct struct Message Support newque()..66. freeque()..67. ss_wakeup()..67. ss_add()..67. ss_del()..67. expunge_all()..67. load_msg()..67. store_msg()..68. free_msg()..68. convert_mode().

4 68. testmsg()..68. pipelined_send()..68. copy_msqid_to_user()..69. copy_msqid_from_user()..69. Shared Shared Memory System Call sys_shmget()..69. sys_shmctl()..69. SHM_STAT, SHM_LOCK, sys_shmat()..70. sys_shmdt()..71. Shared Memory Support struct struct struct struct struct Shared Memory Support newseg()..73. shm_get_stat()..73. shmem_lock()..73. iii Linux Kernel Internals Table of Contents Linux Kernel Internals shm_destroy()..74. shm_inc()..74. shm_close()..74. shmem_file_setup()..74. Linux IPC Generic Linux IPC Primitives used with Semaphores, Messages,and Shared ipc_alloc()..74. ipc_addid()..75. ipc_rmid().

5 75. ipc_buildid()..75. ipc_checkid()..75. grow_ary()..75. ipc_findkey()..75. ipcperms()..76. ipc_lock()..76. ipc_unlock()..76. ipc_lockall()..76. ipc_unlockall()..76. ipc_get()..76. ipc_parse_version()..76. Generic IPC Structures used with Semaphores,Messages, and Shared struct struct struct iv Linux Kernel Internals Tigran Aivazian 7 August 2002 (29 Av 6001). Introduction to the Linux Kernel . The latest copy of this document can be always downloaded from: This guide is now part of the Linux Documentation Project and can also be downloaded in various formats from: or can be read online (latest version) at: This Documentation is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

6 The author is working as senior Linux Kernel engineer at VERITAS Software Ltd and wrote this book for the purpose of supporting the short training course/lectures he gave on this subject, internally at VERITAS. Thanks to Juan J. Quintela Francis Galiegue Hakjun Mun Matt Kraai Nicholas Dronen Samuel S Chessman Nadeem Hasan Michael Svetlik ( @ssi schaefer ) for various corrections and suggestions. The Linux Page Cache chapter was written by: Christoph Hellwig The IPC Mechanisms chapter was written by: Russell Weight and Mingming Cao 1. Booting Building the Linux Kernel Image Booting: Overview Booting: BIOS POST. Booting: bootsector and setup Using LILO as a bootloader High level initialisation SMP Bootup on x86.

7 Freeing initialisation data and code Processing Kernel command line 2. Process and Interrupt Management Task Structure and Process Table Creation and termination of tasks and Kernel threads Linux Scheduler Linux linked list implementation Wait Queues Kernel Timers Bottom Halves Task Queues Tasklets Softirqs How System Calls Are Implemented on i386 Architecture? Linux Kernel Internals 1. Linux Kernel Internals Atomic Operations Spinlocks, Read write Spinlocks and Big Reader Spinlocks Semaphores and read/write Semaphores Kernel Support for Loading Modules 3. Virtual Filesystem (VFS). Inode Caches and Interaction with Dcache Filesystem Registration/Unregistration File Descriptor Management File Structure Management Superblock and Mountpoint Management Example Virtual Filesystem: pipefs Example Disk Filesystem: BFS.

8 Execution Domains and Binary Formats 4. Linux Page Cache 5. IPC mechanisms Semaphores Message queues Shared Memory Linux IPC Primitives 1. Booting Building the Linux Kernel Image This section explains the steps taken during compilation of the Linux Kernel and the output produced at each stage. The build process depends on the architecture so I would like to emphasize that we only consider building a Linux /x86 Kernel . When the user types 'make zImage' or 'make bzImage' the resulting bootable Kernel image is stored as arch/i386/boot/zImage or arch/i386/boot/bzImage respectively. Here is how the image is built: 1. C and assembly source files are compiled into ELF relocatable object format (.)

9 O) and some of them are grouped logically into archives (.a) using ar(1). 2. Using ld(1), the above .o and .a are linked into vmlinux which is a statically linked, non stripped ELF 32 bit LSB 80386 executable file. 3. is produced by nm vmlinux, irrelevant or uninteresting symbols are grepped out. 4. Enter directory arch/i386/boot. 5. Bootsector asm code is preprocessed either with or without D__BIG_KERNEL__, depending on whether the target is bzImage or zImage, into or respectively. 6. is assembled and then converted into 'raw binary' form called bbootsect (or assembled and raw converted into bootsect for zImage).

10 3. Virtual Filesystem (VFS) 2. Linux Kernel Internals 7. Setup code ( includes ) is preprocessed into for bzImage or for zImage. In the same way as the bootsector code, the difference is marked by D__BIG_KERNEL__ present for bzImage. The result is then converted into 'raw binary' form called bsetup. 8. Enter directory arch/i386/boot/compressed and convert /usr/src/ Linux /vmlinux to $tmppiggy (tmp filename) in raw binary format, removing .note and .comment ELF sections. 9. gzip 9 < $tmppiggy > $ 10. Link $ into ELF relocatable (ld r) 11. Compile compression routines and (still in arch/i386/boot/compressed directory) into ELF objects and 12.