Linux kernel programming book

Linux Kernel Programming : A comprehensive guide to kernel internals, writing kernel modules, and kernel synchronization

Key FeaturesDiscover how to write kernel code using the Loadable Kernel Module frameworkExplore industry-grade techniques to perform efficient memory allocation and data synchronization within the kernelUnderstand the essentials of key internals topics such as kernel architecture, memory management, CPU scheduling, and kernel synchronizationBook Description

Linux Kernel Programming is a comprehensive introduction for those new to Linux kernel and module development. This easy-to-follow guide will have you up and running with writing kernel code in next-to-no time. This book uses the latest 5.4 Long-Term Support (LTS) Linux kernel, which will be maintained from November 2019 through to December 2025. By working with the 5.4 LTS kernel throughout the book, you can be confident that your knowledge will continue to be valid for years to come.

You’ll start the journey by learning how to build the kernel from the source. Next, you’ll write your first kernel module using the powerful Loadable Kernel Module (LKM) framework. The following chapters will cover key kernel internals topics including Linux kernel architecture, memory management, and CPU scheduling.

During the course of this book, you’ll delve into the fairly complex topic of concurrency within the kernel, understand the issues it can cause, and learn how they can be addressed with various locking technologies (mutexes, spinlocks, atomic, and refcount operators). You’ll also benefit from more advanced material on cache effects, a primer on lock-free techniques within the kernel, deadlock avoidance (with lockdep), and kernel lock debugging techniques.

By the end of this kernel book, you’ll have a detailed understanding of the fundamentals of writing Linux kernel module code for real-world projects and products.

What you will learnWrite high-quality modular kernel code (LKM framework) for 5.x kernelsConfigure and build a kernel from sourceExplore the Linux kernel architectureGet to grips with key internals regarding memory management within the kernelUnderstand and work with various dynamic kernel memory alloc/dealloc APIsDiscover key internals aspects regarding CPU scheduling within the kernelGain an understanding of kernel concurrency issuesFind out how to work with key kernel synchronization primitivesWho this book is for

This book is for Linux programmers beginning to find their way with Linux kernel development. If you’re a Linux kernel and driver developer looking to overcome frequent and common kernel development issues, or understand kernel intervals, you’ll find plenty of useful information.

You’ll need a solid foundation of Linux CLI and C programming before you can jump in.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Читайте также:  Создание сетевых папок linux

Linux Kernel Programming, published by Packt

License

PacktPublishing/Linux-Kernel-Programming

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

This is the code repository for Linux Kernel Programming, published by Packt.

Linux Kernel Programming, published by Packt

Linux Kernel Programming is a comprehensive introduction for those new to Linux kernel and module development. This easy-to-follow guide will have you up and running with writing kernel code in next-to-no time. This book uses the latest 5.4 Long-Term Support (LTS) Linux kernel, which will be maintained from November 2019 through to December 2025. By working with the 5.4 LTS kernel throughout the book, you can be confident that your knowledge will continue to be valid for years to come.

This book covers the following exciting features:

  • Write high-quality modular kernel code (LKM framework) for 5.x kernels
  • Configure and build a kernel from source
  • Explore the Linux kernel architecture
  • Get to grips with key internals regarding memory management within the kernel
  • Understand and work with various dynamic kernel memory alloc/dealloc APIs Discover key internals aspects regarding CPU scheduling within the kernel Gain an understanding of kernel concurrency issues Learn how to work with key kernel synchronization primitives

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders. For example, ch2.

The code will look like the following:

static int __init miscdrv_init(void) < int ret; struct device *dev; 

Following is what you need for this book: This book is for Linux programmers beginning to find their way with Linux kernel development. Linux kernel and driver developers looking to overcome frequent and common kernel development issues, as well as understand kernel internals, will benefit from this book. A basic understanding of Linux CLI and C programming is required.

With the following software and hardware list you can run all code files present in the book (Chapter 1-13).

Читайте также:  Linux kernel run qemu

Software and Hardware List

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

  • pg 26:
    • 'sudo apt install git fakeroot . ' ; corrections:
      • change pstree to psmisc
      • to install 'tuna' refer https://tuna.readthedocs.io/en/stable/installation.html
      • change hexdump to bsdmainutils (the package name)
      • for 'openjdk-14-jre' installation refer https://java.tutorials24x7.com/blog/how-to-install-openjdk-14-on-ubuntu
      • 'Chapter 9' should be 'Chapter 10'
      • 'Chapter 10' should be 'Chapter 11'
      • the line '// ch4/helloworld_lkm/hellowworld_lkm.c' has the letter 'w' twice; it should be: '// ch4/helloworld_lkm/helloworld_lkm.c' (thanks to @xuhw21)
      • 'via the module_parm_cb() macro' should be 'via the module_param_cb() macro'
      • '(The kernel-mode stack for ' - incomplete sentence; it should be deleted/ignored.
      • the process view after the sentence '. and a total of nine threads:'
        • the first two columns are shown as 'PID TGID'; the order is reversed, it should be 'TGID PID'

        x86_64: 5 : 56 --> 57 : 64PB:64PB : corrected (allows for total of 128 PB)

        Aarch64: 3 : 39 --> 40 : 512G:512G : corrected (allows for total of 1024 GB = 1 TB)

        Aarch64: 4 : 48 --> 49 : 256T:256T : corrected (allows for total of 512 T)

        • pg 388:
          • '. the next available memory chunk is on order 7, of size 256 KB.' should be: '. the next available memory chunk is on order 6, of size 256 KB.
          • '. there is a incorrect reference regarding a folder chp15/kthread_simple/kthread. The correct reference should be ch5/kthread_simple/kthread in part 2 of the book's GitHub [Repository]
          • '. In info/Tip:
          "The material in this section assumes you have at least a base understanding of accessing peripheral device (chip) memory and registers; we have covered this in detail in Chapter 13, Working with Hardware I/O Memory. Please ensure that you understand it before moving forward. 
          "The material in this section assumes you have at least a base understanding of accessing peripheral device (chip) memory and registers; we have covered this in detail in Linux Kernel Programming Part 2 - Chapter 3, Working with Hardware I/O Memory. Please ensure that you understand it before moving forward." 

          Kaiwan N Billimoria taught himself BASIC programming on his dad's IBM PC back in 1983. He was programming in C and Assembly on DOS until he discovered the joys of Unix, and by around 1997, Linux!

          Kaiwan has worked on many aspects of the Linux system programming stack, including Bash scripting, system programming in C, kernel internals, device drivers, and embedded Linux work. He has actively worked on several commercial/FOSS projects. His contributions include drivers to the mainline Linux OS and many smaller projects hosted on GitHub. His Linux passion feeds well into his passion for teaching these topics to engineers, which he has done for well over two decades now. He's also the author of Hands-On System Programming with Linux. It doesn't hurt that he is a recreational ultrarunner too.

          Other books by the authors

          If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
          Simply click on the link to claim your free PDF.

          Источник

          Linux Kernel Programming

          Linux Kernel Programming

          Read it now on the O’Reilly learning platform with a 10-day free trial.

          O’Reilly members get unlimited access to books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.

          Book description

          Learn how to write high-quality kernel module code, solve common Linux kernel programming issues, and understand the fundamentals of Linux kernel internals

          Key Features

          • Discover how to write kernel code using the Loadable Kernel Module framework
          • Explore industry-grade techniques to perform efficient memory allocation and data synchronization within the kernel
          • Understand the essentials of key internals topics such as kernel architecture, memory management, CPU scheduling, and kernel synchronization

          Book Description

          Linux Kernel Programming is a comprehensive introduction for those new to Linux kernel and module development. This easy-to-follow guide will have you up and running with writing kernel code in next-to-no time. This book uses the latest 5.4 Long-Term Support (LTS) Linux kernel, which will be maintained from November 2019 through to December 2025. By working with the 5.4 LTS kernel throughout the book, you can be confident that your knowledge will continue to be valid for years to come.

          You'll start the journey by learning how to build the kernel from the source. Next, you'll write your first kernel module using the powerful Loadable Kernel Module (LKM) framework. The following chapters will cover key kernel internals topics including Linux kernel architecture, memory management, and CPU scheduling.

          During the course of this book, you'll delve into the fairly complex topic of concurrency within the kernel, understand the issues it can cause, and learn how they can be addressed with various locking technologies (mutexes, spinlocks, atomic, and refcount operators). You'll also benefit from more advanced material on cache effects, a primer on lock-free techniques within the kernel, deadlock avoidance (with lockdep), and kernel lock debugging techniques.

          By the end of this kernel book, you'll have a detailed understanding of the fundamentals of writing Linux kernel module code for real-world projects and products.

          What you will learn

          • Write high-quality modular kernel code (LKM framework) for 5.x kernels
          • Configure and build a kernel from source
          • Explore the Linux kernel architecture
          • Get to grips with key internals regarding memory management within the kernel
          • Understand and work with various dynamic kernel memory alloc/dealloc APIs
          • Discover key internals aspects regarding CPU scheduling within the kernel
          • Gain an understanding of kernel concurrency issues
          • Find out how to work with key kernel synchronization primitives

          Who this book is for

          This book is for Linux programmers beginning to find their way with Linux kernel development. If you're a Linux kernel and driver developer looking to overcome frequent and common kernel development issues, or understand kernel intervals, you'll find plenty of useful information.

          You'll need a solid foundation of Linux CLI and C programming before you can jump in.

          Источник

Оцените статью
Adblock
detector