Linux Kernel 入门

 Linux Kernel Basics

How to find your current running version?

yubao@yubao-ThinkPad-E560:~/MyProjects/Linux/driver/CharacterDeviceDriver$ uname -r
4.13.0-36-generic

 

Major number: 4

Minor number: 13 (even: stable; odd: experimental)

Revision number: 0

Where is the kernel source location?

unzip tar in /usr/src

Kernal Space and User Space

> Kernal space is where the core of the operating system runs and provides its services.

> Userspace is that set of memory locations in which user processes (i.e., everything other than the kernel) run. A process is an executing instance of a program. One of the roles of the kernel is to manage individual user process within this space and to prevent them from interfering with each other.

Kernel space can be accessed by user processes only through the use of system calls. System calls are requests in the Unix-like operating system by an active process for a service performed by the kernel, such as input/output or process creation.

Kernel Modules

Kernel Modules can be classified into two types:

> Static modules

> Dynamic modules

Static Modules

These are compiled as a part of the kernel and are available at any time. These make the kernel larger and has the disadvantage of requiring us to rebuild and reboot the kernel every time we want new functionality.

Dynamic Modules

These modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system.

Dynamic Modules have the advantage that it uses the Memory more efficiently than the Statically linked drivers.

Kernal Roles

> Process management

The kernel is in charge of creating and destroying processes and handling their connection to the outside world (input and output).

Communication among different processes (through signals, pipes, or inter-process communication primitives) is basic to the overall system functionality and is also handled

 by the kernel.

The scheduler, which controls how processes share the CPU, is part of process management.

> Memory management

> File Systems

The kernel builds a structured filesystem on top of unstructured hardware, and the resulting file concept is heavily used throughout the whole system.

> Device control

Almost every system operation eventually maps to a physical device. With the exception of the processor, memory, and a very few other entities, any and all device control operations are performed by code that is specific to the device being addressed. That code is called a device driver.

The kernel must have embedded in it a device driver for every peripheral present on a system., from the hard drive to the keyboard and the tape drive.

> Networking

Development package Installation

dkms - dynamic kernel module support package

 

posted on 2018-03-10 21:14  LiuYubao  阅读(420)  评论(0编辑  收藏  举报

导航