Splitting the kernel

Alright, we know that the Kernel is the core of the OS. So lets see what are the things the Kernel do for the OS.

01. Process Management

The kernel will manage all processors which happening in the OS.

02. Memory Management 

The Linux Kernel has a ability to process on top of limited resources. This was done by it’s memory management.

03. File Systems

Unix based on file system concept. Almost everything can be treated as a file. Structure file system on top of hardware. You will understand this concept more while we working on drivers.

04. Device Control

Both device controlling is done by the Kernel too.

05. Networking

The Networking must managed by the OS. Because we can’t sure when will the network is working.

Loadable Modules

Each pieces of the code can be add to Kernel at run-time is called a module. Each module is made up of object code that can be dynamically linked to the running kernel by the `insmod` program and can be unlinked by `rmmod` program. This facility enable us to test the driver module at the runtime.

The system call interface

This figure shows us how the Linux OS is build up. Son now we are going to add a module to the Kernel ( or to  Kernel Space) and add a device software (program) to user space and the interact with this to spaces. Simply this is what we do by making Linux device drivers. Yeah, its seems simple, but need to be carefull.

Classes of Devices & Modules

The Unix way of looking at devices distinguishes between three device types.

  1. Char Module
  2. Block Module
  3. Network Module

Character devices (Char)

a device can access as a stream of bytes, like a file. The char drivers have this behavior. Such drivers usually implement at least open, close, read & write system calls.  You can see this type of devices at `/dev/console` (Text console) , `/dev/ttyxx` (Serial prots), etc.
In a regular file, you can always move back and forward. But in char drivers are just data channels. You can only access sequentially.

Block Devices

Access by a filesystem nodes in /dev/. For example hard disk -> /dev/sda0 , ect.

Network interfaces

A device that is able to exchange data with other hosts is call a network interface. It isn’t map to node in file system (/dev/). The Unix way to provide access to interface is still by assingining a unique name to them (eth0, wlan0, ect.). Instead of read & write, the kernel calls functions related to packet transmission.
So, in USB we can tread them as a Network interface or a Block module or even a char module some times.

Yeah, that’s how the devices can be categorized…

***Please note that all of the content on this post was originally published on champlnx.blogspot.com. We have migrated these posts to www.champlnx.com for your convenience and continued access.

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *