SlideShare a Scribd company logo
1 of 11
Download to read offline
Linux Kernel Module Programming
What are kernel modules?
Kernel modules are piece of code, that can be loaded and unloaded from kernel on demand.
Kernel modules offers an easy way to extend the functionality of the base kernel without having to
rebuild or recompile the kernel again. Most of the drivers are implemented as a Linux kernel modules.
When those drivers are not needed, we can unload only that specific driver, which will reduce the kernel
image size.
The kernel modules will have a .ko extension. On a normal linux system, the kernel modules will reside
inside /lib/modules/<kernel_version>/kernel/ directory.
I. Utilities to Manipulate Kernel Modules
1. lsmod – List Modules that Loaded Already
lsmod command will list modules that are already loaded in the kernel as shown beblow.
2. insmod – Insert Module into Kernel
insmod command will insert a new module into the kernel as shown below.
# insmod /lib/modules/3.5.0-19-generic/kernel/fs/squashfs/ squashfs.ko
# lsmod | grep "squash"
squashfs 35834 0
3. modinfo – Display Module Info
modinfo command will display information about a kernel module as shown below.
# modinfo /lib/modules/3.5.0-19-generic/kernel/fs/squashfs/squashfs.ko
4. rmmod – Remove Module from Kernel
rmmod command will remove a module from the kernel. You cannot remove a module which is already
used by any program.
# rmmod squashfs.ko
5. modprobe – Add or Remove modules from the kernel
modprobe is an intelligent command which will load/unload modules based on the dependency between
modules. Refer to modprobe commands for more detailed examples.
II. Write a Simple Hello World Kernel Module
1. Installing the linux headers
You need to install the linux-headers-.. first as shown below. Depending on your distro, use apt-get or
yum.
# apt-get install build-essential linux-headers-$(uname -r)
2. Hello World Module Source Code
Next, create the following hello.c module in C programming language.
#include <linux/module.h> // included for all kernel modules
#include <linux/kernel.h> // included for KERN_INFO
#include <linux/init.h> // included for __init and __exit macros
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lakshmanan");
MODULE_DESCRIPTION("A Simple Hello World module");
static int __init hello_init(void)
{
printk(KERN_INFO "Hello world!n");
return 0;
// Non-zero return means that the module couldn't be loaded.
}
static void __exit hello_cleanup(void)
{
printk(KERN_INFO "Cleaning up module.n");
}
module_init(hello_init);
module_exit(hello_cleanup);
Warning: All kernel modules will operate on kernel space, a highly privileged mode. So be careful with
what you write in a kernel module.
3. Create Makefile to Compile Kernel Module
The following makefile can be used to compile the above basic hello world kernel module.
obj-m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Use the make command to compile hello world kernel module as shown below.
# make
make -C /lib/modules/3.5.0-19-generic/build M=/home/lakshmanan/a
modules
make[1]: Entering directory `/usr/src/linux-headers-3.5.0-19-generic'
CC [M] /home/lakshmanan/a/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/lakshmanan/a/hello.mod.o
LD [M] /home/lakshmanan/a/hello.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-19-generic'
The above will create hello.ko file, which is our sample Kernel module.
4. Insert or Remove the Sample Kernel Module
Now that we have our hello.ko file, we can insert this module to the kernel by using insmod command as
shown below.
# insmod hello.ko
# dmesg | tail -1
[ 8394.731865] Hello world!
# rmmod hello.ko
# dmesg | tail -1
[ 8707.989819] Cleaning up module.
When a module is inserted into the kernel, the module_init macro will be invoked, which will call the
function hello_init. Similarly, when the module is removed with rmmod, module_exit macro will be
invoked, which will call the hello_exit. Using dmesg command, we can see the output from the sample
Kernel module.
Please note that printk is a function which is defined in kernel, and it behaves similar to the printf in the
IO library. Remember that you cannot use any of the library functions from the kernel module.
Embedded Linux
Embedded Linux is the usage of the Linux kernel and various open-source components in embedded
systems.
Advantages of Using Linux in embedded systems.
Re-using components
• The key advantage of Linux and open-source in embedded systems is the ability to re-use
components
• The open-source ecosystem already provides many components for standard features, from
hardware support to network protocols, going through multimedia, graphic, cryptographic
libraries, etc.
• As soon as a hardware device, or a protocol, or a feature is wide-spread enough, high chance of
having open-source components that support it.
Low cost
• Free software can be duplicated on as many devices as you want, free of charge.
• If your embedded system uses only free software, you can reduce the cost of software licenses to
zero. Even the development tools are free, unless you choose a commercial embedded Linux
edition.
Full control
• With open-source, you have the source code for all components in your system
• Allows unlimited modifications, changes, tuning, debugging, optimization, for an unlimited
period of time
• Allows to have full control over the software part of your system
Quality
• Many open-source components are widely used, on millions of systems
• Usually higher quality than what an in-house development can produce, or even proprietary
vendors
• Allows to design your system with high-quality components at the foundations
Eases testing of new features
• Open-source being freely available, it is easy to get a piece of software and evaluate it
• Allows to easily study several options while making a choice
Community support
• Open-source software components are developed by communities of developers and users
• This community can provide a high-quality support: you can directly contact the main developers
of the component you are using.
• Taking part into the community
Possibility of taking part into the development community of some of the components used in the
embedded systems: bug reporting, test of new versions or features, patches that fix bugs or add new
features, etc.
Examples of Embedded Linux
• Personal routers
• Television
• Point of sale terminal
• Laser cutting machine
• Viticulture machine
Embedded hardware for Linux system
• The Linux kernel and most other architecture-dependent component support a wide range of 32
and 64 bits architectures
• x86 and x86-64, as found on PC platforms, but also embedded systems (multimedia, industrial)
• ARM, with hundreds of different SoC (multimedia, industrial)
• PowerPC (mainly real-time, industrial applications)
• MIPS (mainly networking applications)
• SuperH (mainly set top box and multimedia applications)
• Blackfin (DSP architecture)
• Microblaze (soft-core for Xilinx FPGA)
• Coldfire, SCore, Tile, Xtensa, Cris, FRV, AVR32, M32R
Embedded Linux system archirecture.
Software components
● Cross-compilation toolchain
● Compiler that runs on the development machine, but generates code for the target
● Bootloader
● Started by the hardware, responsible for basic initialization, loading and executing the kernel
● Linux Kernel
● Contains the process and memory management, network stack, device drivers and provides
services to user space applications
● C library
● The interface between the kernel and the user space applications
● Libraries and applications
● Third-party or in-house
Embedded Linux work
Several distinct tasks are needed when deploying embedded Linux in a product:
• Board Support Package development
• A BSP contains a bootloader and kernel with the suitable device drivers for the targeted
hardware
• Purpose of our Kernel Development training
• System integration
• Integrate all the components, bootloader, kernel, third-party libraries and applications and in-
house applications into a working system
• Purpose of this training
• Development of applications
• Normal Linux applications, but using specifically chosen libraries
Application Specific Operating Systems
Application specific customization became all the more important with the advent of application
domains such as multimedia, database, parallel computing etc., which demand high performance and
high functionality. Resource management and communication/sharing between applications is to be done
by the operating system code running as library routines in each application. Since these library routines
can be made application-specific, the programmer has the flexibility to easily modify them whenever
that is necessary for performance.
Need for customized operating systems
Greater Performance
One of the primary motivation for such a system is greater performance. Problems with traditional
operating systems is that they hide information behind high-level abstractions like processes, page table
structures, IPC etc. And hence they provide a virtual machine to the user. Thus they give a fixed
implementation to all applications thereby making domain specific optimizations impossible. General
purpose implementations do reduce performance to a great extent and that application specific virtual
memory policies can increase application performance.
More Functionality and flexibility
Further move towards customization is motivated by a need for more functionality. New application
domains like multimedia need different sets of services. Incorporating all the services is not a good idea,
because one may not use number of those service but still have to pay for them in the form of OS
overhead.
Sophisticated Security
Modern application technologies such as Java require sophisticated security in the form of access
controls, that default operating systems may not provide.
Simplicity
Simple rather than a complex kernel is easy to implement and is efficient. One may draw an analogy to
RISC systems for this aspect.
Issues and Problems
• Protection and Sharing
• Too much of flexibility
• Application programmers aren’t operating systems designers
• Backward compatibility and Portability
Extensible Application Specific Operating Systems
SPIN
SPIN investigates kernels that allow applications to make policy decisions. All management policies are
defined by embedded implementations called spindles. These spindles are dynamically loaded into the
kernel.
Merits:
Secure because of the use of type safe language and compiler checks
Good amount of extensibility, relatively with less burden on user
Demerits:
High overhead due to cross domain calls
Fair sharing across applications is not possible
Not reflective i.e. it cannot monitor and modify its own behavior as it executes
Aegis – an Exokernel
Aegis uses the familiar “end-to-end” argument that applies to low-level communications protocols.
Maximum opportunity for application-level resource management is assured by designing a thin
exokernel. The job of exokernel is to a. track ownership of resources b. perform access control.
Merits:
Truly extensible and flexible as it exposes the hardware
Very efficient
Demerits:
Too flexible and hence may lead to portability and compatibility problems
Less secure – it expects a high degree of trust
Highly Complex software support is needed
SPACE
SPACE uses processors, address spaces, and a generalized exception mechanism as the basic
abstractions. The processor has more than one privilege mode and thus arbitrary number of domains can
exist in an address space.
Merits:
Virtualized resources as the fundamental abstraction and hence more customizable .
Demerits:
Building applications in terms of spaces, domains, and portals is highly complex and lacks portability.
Synthetix
This work is a follow on from Synthesis project. It makes use of feedback from the system and use it to
dynamically modify the code. The make use of the information from dynamically changing conditions.
They use this technique not only for designing OS but also for seamless mobility and few others.
Merits:
Absolutely no burden on user
There are no problems of portability, security etc.. in fact it is implemented on HP-UX
Demerits:
No full support for customization
Kea
In Kea kernel can be reconfigured through RPC mechanism. RPC in Kea is very general unlike others
and eliminate unnecessary steps often made in a general RPC system (like in LRPC). Kea has domains,
threads, inter-domain calls and portals as abstractions.
Merits:
Provides a neat interface through user : user can use usual semantics to configure kernel
Demerits:
Huge penalty is incurred because of number of cross domain calls
Vino
VINO is a downloadable system, that uses sand-boxing [] to enforce trust and security. Sandboxing is a
technique developed to allow embedding of untrusted application code inside trusted programs.
Extensions are written in c++ and are compiler by a trusted compiler. This trusted code is then
downloaded into the kernel. Each extension in VINO is run in the context of a transaction.
Merits:
Performance is only slightly worse than unprotected c++
Extensions can be implemented in conventional languages
Demerits:
Security of the system is heavily dependent on compiler. There is no guard if a malicious user tricks the
compiler
Spring
Spring is also another micro-kernel based operating system developed to build operating system out of
replaceable parts.
Nach OS
Nach os is a new teaching operating system and simulation environment. It makes it possible to give
assignments that require students to write significant portions of each of the major pieces of a modern
operating system: thread management, file systems, multiprogramming, virtual memory, and
networking. The concepts are necessary to understand the computer systems of today and of the future:
concurrency and synchronization, caching and locality, the trade-off between simplicity and
performance, building reliability from unreliable components, dynamic scheduling, the power of a level
of translation, distributed computing, layering, and virtualization.
Basic services of Nach OS
1. Thread Management
Basic working thread system and an implementation of semaphores. The assignment is to
implement Mesa-style locks and condition variables using semaphores, and then to implement
solutions to a number of concurrency problems using these synchronization primitives.
2. File Systems
Real file systems can be very complex artifacts. The UNIX file system, for example, has at least
three levels of indirection – the per-process file descriptor table, the system-wide open file table,
and the in-core inode table – before one even gets to disk blocks.
3. Multiprogramming
The code to create a user address space, load a Nachos file containing an executable image into
user memory, and then to run the program is provided. Initial code is restricted to running only a
single user program at a time.
4. Virtual Memory
It asks students to replace their simple memory management code from the previous assignment
with a true virtual memory system, that is, one that presents to each user program the abstraction
of an (almost) unlimited virtual memory size by using main memory as a cache for the disk. No
new hardware or operating system components are provided.
5. Networking
At the hardware level, we simulate the behavior a network of workstations, each running Nachos,
by connecting the UNIX processes running Nachos via sockets. The Nachos operating system
and user programs running on it can communicate with other machines" running Nachos simply
by sending messages into the emulated network the transmission is actually accomplished by
socket send and receive.
Introduction to Service Oriented Operating System
The S(o)OS project addressed future distributed systems on the level of a holistic operating system
architecture by drawing from Service Oriented Architectures and the strength of Grids. This decouples
the OS from the underlying resource infrastructure, thus making execution across an almost unlimited
number of varying devices possible, independent from the actual hardware.
S(o)OS investigated alternative Operating System Architectures that base on a modular principle, where
not only the individual modules may be replaced according to the respective resource specifics, but,
more importantly, where also the modules may be distributed according to the executing process’
requirements. The Operating System thus becomes a dynamic service oriented infrastructure in which
each executing process may specify the required services which are detected, deployed and adapted on
the fly.
S(o)OS examined how code can be segmented in a fashion that allows for concurrent execution over a
heterogeneous infrastructure by combining the two approaches above. This principle implicitly supports
parallelisation of code in a fashion that reduces the communication overhead. With the information
about the code behaviour and dependencies, further optimisation steps can be taken related to the
infrastructure’s communication layout, cache and memory limitations, resource specific capabilities and
restrictions etc. Depending on the size and complexity of the segments, on-the-fly adaptation steps may
furthermore be taken to increase heterogeneity and in particular to improve performance by exploiting
the resource features.
Introduction to Ubuntu Edge OS (Ubuntu Touch)
Ubuntu Touch (also known as Ubuntu Phone) is a mobile version of the Ubuntu operating system
developed by Canonical UK Ltd and Ubuntu Community. It is designed primarily for touchscreen
mobile devices such as smartphones and tablet computers.
Canonical released Ubuntu Touch 1.0, the first developer/partner version on 17 October 2013, along
with Ubuntu 13.10 that "primarily supports the Galaxy Nexus and Nexus 4 phones, though there are
images available for other phones and tablets". Ubuntu Touch uses the Qt 5-based touch user interface
and various software frameworks originally developed for Maemo and MeeGo such as oFono as
telephony stack, accounts-sso for single sign-on, and Maliit for input. Utilizing libhybris the system can
often be used with Linux kernels used in Android, which makes it easily ported to most recent Android
smartphones.
Ubuntu Touch utilizes the same core technologies as the Ubuntu Desktop, so applications designed for
the latter platform run on the former and vice versa. Additionally, Ubuntu Desktop components come
with the Ubuntu Touch system; allowing Ubuntu Touch devices to provide a full desktop experience
when connected to an external monitor. Ubuntu Touch devices can be equipped with a full Ubuntu
session and may change into a full desktop operating system when plugged into a docking station. If
plugged the device can use all the features of Ubuntu and user can perform office work or even play
ARM-ready games on such device.
Architecture:

More Related Content

What's hot

[DEFCON 16] Bypassing pre-boot authentication passwords by instrumenting the...
[DEFCON 16] Bypassing pre-boot authentication passwords  by instrumenting the...[DEFCON 16] Bypassing pre-boot authentication passwords  by instrumenting the...
[DEFCON 16] Bypassing pre-boot authentication passwords by instrumenting the...Moabi.com
 
Evolving role of Software,Legacy software,CASE tools,Process Models,CMMI
Evolving role of Software,Legacy software,CASE tools,Process Models,CMMIEvolving role of Software,Legacy software,CASE tools,Process Models,CMMI
Evolving role of Software,Legacy software,CASE tools,Process Models,CMMInimmik4u
 
用Raspberry PI學Linux驅動程式
用Raspberry PI學Linux驅動程式用Raspberry PI學Linux驅動程式
用Raspberry PI學Linux驅動程式Stanley Ho
 
Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)Sri Prasanna
 
6 Weeks Summer Training on Java By SSDN Technologies
6 Weeks Summer Training on Java By SSDN Technologies6 Weeks Summer Training on Java By SSDN Technologies
6 Weeks Summer Training on Java By SSDN TechnologiesDavid Son
 
java.io - streams and files
java.io - streams and filesjava.io - streams and files
java.io - streams and filesMarcello Thiry
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/CoreShay Cohen
 
Linker and Loader Explained
Linker and Loader  ExplainedLinker and Loader  Explained
Linker and Loader ExplainedAdarsh Kr Sinha
 
Serialization in java
Serialization in javaSerialization in java
Serialization in javaJanu Jahnavi
 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loaderbabyparul
 
Fast detection of Android malware: machine learning approach
Fast detection of Android malware: machine learning approachFast detection of Android malware: machine learning approach
Fast detection of Android malware: machine learning approachYury Leonychev
 
Encoded Attacks And Countermeasures
Encoded Attacks And CountermeasuresEncoded Attacks And Countermeasures
Encoded Attacks And CountermeasuresMarco Morana
 
Basic Graphics in Java
Basic Graphics in JavaBasic Graphics in Java
Basic Graphics in JavaPrakash Kumar
 

What's hot (20)

[DEFCON 16] Bypassing pre-boot authentication passwords by instrumenting the...
[DEFCON 16] Bypassing pre-boot authentication passwords  by instrumenting the...[DEFCON 16] Bypassing pre-boot authentication passwords  by instrumenting the...
[DEFCON 16] Bypassing pre-boot authentication passwords by instrumenting the...
 
Socket System Calls
Socket System CallsSocket System Calls
Socket System Calls
 
Shell programming
Shell programmingShell programming
Shell programming
 
Linux Programming
Linux ProgrammingLinux Programming
Linux Programming
 
Code generation
Code generationCode generation
Code generation
 
Evolving role of Software,Legacy software,CASE tools,Process Models,CMMI
Evolving role of Software,Legacy software,CASE tools,Process Models,CMMIEvolving role of Software,Legacy software,CASE tools,Process Models,CMMI
Evolving role of Software,Legacy software,CASE tools,Process Models,CMMI
 
用Raspberry PI學Linux驅動程式
用Raspberry PI學Linux驅動程式用Raspberry PI學Linux驅動程式
用Raspberry PI學Linux驅動程式
 
Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)
 
6 Weeks Summer Training on Java By SSDN Technologies
6 Weeks Summer Training on Java By SSDN Technologies6 Weeks Summer Training on Java By SSDN Technologies
6 Weeks Summer Training on Java By SSDN Technologies
 
java.io - streams and files
java.io - streams and filesjava.io - streams and files
java.io - streams and files
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
 
DDBMS Paper with Solution
DDBMS Paper with SolutionDDBMS Paper with Solution
DDBMS Paper with Solution
 
Linker and Loader Explained
Linker and Loader  ExplainedLinker and Loader  Explained
Linker and Loader Explained
 
Serialization in java
Serialization in javaSerialization in java
Serialization in java
 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
 
Fast detection of Android malware: machine learning approach
Fast detection of Android malware: machine learning approachFast detection of Android malware: machine learning approach
Fast detection of Android malware: machine learning approach
 
Encoded Attacks And Countermeasures
Encoded Attacks And CountermeasuresEncoded Attacks And Countermeasures
Encoded Attacks And Countermeasures
 
JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING
 
History of java'
History of java'History of java'
History of java'
 
Basic Graphics in Java
Basic Graphics in JavaBasic Graphics in Java
Basic Graphics in Java
 

Viewers also liked

Apache Pig: A big data processor
Apache Pig: A big data processorApache Pig: A big data processor
Apache Pig: A big data processorTushar B Kute
 
Nach os network
Nach os networkNach os network
Nach os networknaniix21_3
 
Study techniques of programming in c at kkwpss
Study techniques of programming in c at kkwpssStudy techniques of programming in c at kkwpss
Study techniques of programming in c at kkwpssTushar B Kute
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Tushar B Kute
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in LinuxTushar B Kute
 
Mobile Computing UNIT-6
Mobile Computing UNIT-6Mobile Computing UNIT-6
Mobile Computing UNIT-6Ramesh Babu
 
Flux PayDirect NACH IndusInd Bank Case Study
Flux PayDirect NACH IndusInd Bank Case StudyFlux PayDirect NACH IndusInd Bank Case Study
Flux PayDirect NACH IndusInd Bank Case Studyevolvus
 
Embedded systems class notes
Embedded systems  class notes Embedded systems  class notes
Embedded systems class notes Dr.YNM
 

Viewers also liked (10)

Nachos
NachosNachos
Nachos
 
Apache Pig: A big data processor
Apache Pig: A big data processorApache Pig: A big data processor
Apache Pig: A big data processor
 
Nach os network
Nach os networkNach os network
Nach os network
 
Study techniques of programming in c at kkwpss
Study techniques of programming in c at kkwpssStudy techniques of programming in c at kkwpss
Study techniques of programming in c at kkwpss
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in Linux
 
Mobile Computing UNIT-6
Mobile Computing UNIT-6Mobile Computing UNIT-6
Mobile Computing UNIT-6
 
Flux PayDirect NACH IndusInd Bank Case Study
Flux PayDirect NACH IndusInd Bank Case StudyFlux PayDirect NACH IndusInd Bank Case Study
Flux PayDirect NACH IndusInd Bank Case Study
 
File systems for Embedded Linux
File systems for Embedded LinuxFile systems for Embedded Linux
File systems for Embedded Linux
 
Embedded systems class notes
Embedded systems  class notes Embedded systems  class notes
Embedded systems class notes
 

Similar to Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute

Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modulesdibyajyotig
 
Device Drivers and Running Modules
Device Drivers and Running ModulesDevice Drivers and Running Modules
Device Drivers and Running ModulesYourHelper1
 
Linux for embedded_systems
Linux for embedded_systemsLinux for embedded_systems
Linux for embedded_systemsVandana Salve
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel DevelopmentPriyank Kapadia
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module ProgrammingSaurabh Bangad
 
Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoSherif Mousa
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMSherif Mousa
 
Building Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionBuilding Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionSherif Mousa
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded LinuxTushar B Kute
 
Lec 01_Linux System Administration (1).pptx
Lec 01_Linux System Administration (1).pptxLec 01_Linux System Administration (1).pptx
Lec 01_Linux System Administration (1).pptxShabanaShafi3
 
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungdns -
 
Kernel module programming
Kernel module programmingKernel module programming
Kernel module programmingVandana Salve
 
Ap 06 4_10_simek
Ap 06 4_10_simekAp 06 4_10_simek
Ap 06 4_10_simekNguyen Vinh
 
Docker Online Meetup #31: Unikernels
Docker Online Meetup #31: UnikernelsDocker Online Meetup #31: Unikernels
Docker Online Meetup #31: UnikernelsDocker, Inc.
 
Regarding About Operating System Structure
Regarding About Operating System StructureRegarding About Operating System Structure
Regarding About Operating System Structuresankarkvdc
 
Windows Architecture Explained by Stacksol
Windows Architecture Explained by StacksolWindows Architecture Explained by Stacksol
Windows Architecture Explained by StacksolStacksol
 

Similar to Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute (20)

Studienarb linux kernel-dev
Studienarb linux kernel-devStudienarb linux kernel-dev
Studienarb linux kernel-dev
 
Linux Device Driver’s
Linux Device Driver’sLinux Device Driver’s
Linux Device Driver’s
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
 
Device Drivers and Running Modules
Device Drivers and Running ModulesDevice Drivers and Running Modules
Device Drivers and Running Modules
 
Device Drivers
Device DriversDevice Drivers
Device Drivers
 
Linux for embedded_systems
Linux for embedded_systemsLinux for embedded_systems
Linux for embedded_systems
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
 
Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to Yocto
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
 
Building Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionBuilding Embedded Linux Systems Introduction
Building Embedded Linux Systems Introduction
 
Walking around linux kernel
Walking around linux kernelWalking around linux kernel
Walking around linux kernel
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded Linux
 
Lec 01_Linux System Administration (1).pptx
Lec 01_Linux System Administration (1).pptxLec 01_Linux System Administration (1).pptx
Lec 01_Linux System Administration (1).pptx
 
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesung
 
Kernel module programming
Kernel module programmingKernel module programming
Kernel module programming
 
Ap 06 4_10_simek
Ap 06 4_10_simekAp 06 4_10_simek
Ap 06 4_10_simek
 
Docker Online Meetup #31: Unikernels
Docker Online Meetup #31: UnikernelsDocker Online Meetup #31: Unikernels
Docker Online Meetup #31: Unikernels
 
Regarding About Operating System Structure
Regarding About Operating System StructureRegarding About Operating System Structure
Regarding About Operating System Structure
 
Windows Architecture Explained by Stacksol
Windows Architecture Explained by StacksolWindows Architecture Explained by Stacksol
Windows Architecture Explained by Stacksol
 

More from Tushar B Kute

01 Introduction to Android
01 Introduction to Android01 Introduction to Android
01 Introduction to AndroidTushar B Kute
 
Ubuntu OS and it's Flavours
Ubuntu OS and it's FlavoursUbuntu OS and it's Flavours
Ubuntu OS and it's FlavoursTushar B Kute
 
Install Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteInstall Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteTushar B Kute
 
Install Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteInstall Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteTushar B Kute
 
Share File easily between computers using sftp
Share File easily between computers using sftpShare File easily between computers using sftp
Share File easily between computers using sftpTushar B Kute
 
Implementation of FIFO in Linux
Implementation of FIFO in LinuxImplementation of FIFO in Linux
Implementation of FIFO in LinuxTushar B Kute
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in LinuxTushar B Kute
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsTushar B Kute
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxTushar B Kute
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxTushar B Kute
 
Open source applications softwares
Open source applications softwaresOpen source applications softwares
Open source applications softwaresTushar B Kute
 
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)Tushar B Kute
 
Technical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrcTechnical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrcTushar B Kute
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteTushar B Kute
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteTushar B Kute
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command ShellTushar B Kute
 
Module 01 Introduction to Linux
Module 01 Introduction to LinuxModule 01 Introduction to Linux
Module 01 Introduction to LinuxTushar B Kute
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on LinuxTushar B Kute
 

More from Tushar B Kute (20)

01 Introduction to Android
01 Introduction to Android01 Introduction to Android
01 Introduction to Android
 
Ubuntu OS and it's Flavours
Ubuntu OS and it's FlavoursUbuntu OS and it's Flavours
Ubuntu OS and it's Flavours
 
Install Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteInstall Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. Kute
 
Install Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteInstall Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. Kute
 
Share File easily between computers using sftp
Share File easily between computers using sftpShare File easily between computers using sftp
Share File easily between computers using sftp
 
Implementation of FIFO in Linux
Implementation of FIFO in LinuxImplementation of FIFO in Linux
Implementation of FIFO in Linux
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in Linux
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix Threads
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in Linux
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
 
Open source applications softwares
Open source applications softwaresOpen source applications softwares
Open source applications softwares
 
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
 
Technical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrcTechnical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrc
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
Module 01 Introduction to Linux
Module 01 Introduction to LinuxModule 01 Introduction to Linux
Module 01 Introduction to Linux
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on Linux
 
See through C
See through CSee through C
See through C
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute

  • 1. Linux Kernel Module Programming What are kernel modules? Kernel modules are piece of code, that can be loaded and unloaded from kernel on demand. Kernel modules offers an easy way to extend the functionality of the base kernel without having to rebuild or recompile the kernel again. Most of the drivers are implemented as a Linux kernel modules. When those drivers are not needed, we can unload only that specific driver, which will reduce the kernel image size. The kernel modules will have a .ko extension. On a normal linux system, the kernel modules will reside inside /lib/modules/<kernel_version>/kernel/ directory. I. Utilities to Manipulate Kernel Modules 1. lsmod – List Modules that Loaded Already lsmod command will list modules that are already loaded in the kernel as shown beblow. 2. insmod – Insert Module into Kernel insmod command will insert a new module into the kernel as shown below. # insmod /lib/modules/3.5.0-19-generic/kernel/fs/squashfs/ squashfs.ko # lsmod | grep "squash" squashfs 35834 0 3. modinfo – Display Module Info modinfo command will display information about a kernel module as shown below. # modinfo /lib/modules/3.5.0-19-generic/kernel/fs/squashfs/squashfs.ko 4. rmmod – Remove Module from Kernel rmmod command will remove a module from the kernel. You cannot remove a module which is already used by any program. # rmmod squashfs.ko 5. modprobe – Add or Remove modules from the kernel modprobe is an intelligent command which will load/unload modules based on the dependency between modules. Refer to modprobe commands for more detailed examples. II. Write a Simple Hello World Kernel Module 1. Installing the linux headers You need to install the linux-headers-.. first as shown below. Depending on your distro, use apt-get or
  • 2. yum. # apt-get install build-essential linux-headers-$(uname -r) 2. Hello World Module Source Code Next, create the following hello.c module in C programming language. #include <linux/module.h> // included for all kernel modules #include <linux/kernel.h> // included for KERN_INFO #include <linux/init.h> // included for __init and __exit macros MODULE_LICENSE("GPL"); MODULE_AUTHOR("Lakshmanan"); MODULE_DESCRIPTION("A Simple Hello World module"); static int __init hello_init(void) { printk(KERN_INFO "Hello world!n"); return 0; // Non-zero return means that the module couldn't be loaded. } static void __exit hello_cleanup(void) { printk(KERN_INFO "Cleaning up module.n"); } module_init(hello_init); module_exit(hello_cleanup); Warning: All kernel modules will operate on kernel space, a highly privileged mode. So be careful with what you write in a kernel module. 3. Create Makefile to Compile Kernel Module The following makefile can be used to compile the above basic hello world kernel module. obj-m += hello.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean Use the make command to compile hello world kernel module as shown below. # make make -C /lib/modules/3.5.0-19-generic/build M=/home/lakshmanan/a modules make[1]: Entering directory `/usr/src/linux-headers-3.5.0-19-generic' CC [M] /home/lakshmanan/a/hello.o
  • 3. Building modules, stage 2. MODPOST 1 modules CC /home/lakshmanan/a/hello.mod.o LD [M] /home/lakshmanan/a/hello.ko make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-19-generic' The above will create hello.ko file, which is our sample Kernel module. 4. Insert or Remove the Sample Kernel Module Now that we have our hello.ko file, we can insert this module to the kernel by using insmod command as shown below. # insmod hello.ko # dmesg | tail -1 [ 8394.731865] Hello world! # rmmod hello.ko # dmesg | tail -1 [ 8707.989819] Cleaning up module. When a module is inserted into the kernel, the module_init macro will be invoked, which will call the function hello_init. Similarly, when the module is removed with rmmod, module_exit macro will be invoked, which will call the hello_exit. Using dmesg command, we can see the output from the sample Kernel module. Please note that printk is a function which is defined in kernel, and it behaves similar to the printf in the IO library. Remember that you cannot use any of the library functions from the kernel module.
  • 4. Embedded Linux Embedded Linux is the usage of the Linux kernel and various open-source components in embedded systems. Advantages of Using Linux in embedded systems. Re-using components • The key advantage of Linux and open-source in embedded systems is the ability to re-use components • The open-source ecosystem already provides many components for standard features, from hardware support to network protocols, going through multimedia, graphic, cryptographic libraries, etc. • As soon as a hardware device, or a protocol, or a feature is wide-spread enough, high chance of having open-source components that support it. Low cost • Free software can be duplicated on as many devices as you want, free of charge. • If your embedded system uses only free software, you can reduce the cost of software licenses to zero. Even the development tools are free, unless you choose a commercial embedded Linux edition. Full control • With open-source, you have the source code for all components in your system • Allows unlimited modifications, changes, tuning, debugging, optimization, for an unlimited period of time • Allows to have full control over the software part of your system Quality • Many open-source components are widely used, on millions of systems • Usually higher quality than what an in-house development can produce, or even proprietary vendors • Allows to design your system with high-quality components at the foundations Eases testing of new features • Open-source being freely available, it is easy to get a piece of software and evaluate it • Allows to easily study several options while making a choice Community support • Open-source software components are developed by communities of developers and users • This community can provide a high-quality support: you can directly contact the main developers of the component you are using. • Taking part into the community Possibility of taking part into the development community of some of the components used in the
  • 5. embedded systems: bug reporting, test of new versions or features, patches that fix bugs or add new features, etc. Examples of Embedded Linux • Personal routers • Television • Point of sale terminal • Laser cutting machine • Viticulture machine Embedded hardware for Linux system • The Linux kernel and most other architecture-dependent component support a wide range of 32 and 64 bits architectures • x86 and x86-64, as found on PC platforms, but also embedded systems (multimedia, industrial) • ARM, with hundreds of different SoC (multimedia, industrial) • PowerPC (mainly real-time, industrial applications) • MIPS (mainly networking applications) • SuperH (mainly set top box and multimedia applications) • Blackfin (DSP architecture) • Microblaze (soft-core for Xilinx FPGA) • Coldfire, SCore, Tile, Xtensa, Cris, FRV, AVR32, M32R Embedded Linux system archirecture. Software components ● Cross-compilation toolchain
  • 6. ● Compiler that runs on the development machine, but generates code for the target ● Bootloader ● Started by the hardware, responsible for basic initialization, loading and executing the kernel ● Linux Kernel ● Contains the process and memory management, network stack, device drivers and provides services to user space applications ● C library ● The interface between the kernel and the user space applications ● Libraries and applications ● Third-party or in-house Embedded Linux work Several distinct tasks are needed when deploying embedded Linux in a product: • Board Support Package development • A BSP contains a bootloader and kernel with the suitable device drivers for the targeted hardware • Purpose of our Kernel Development training • System integration • Integrate all the components, bootloader, kernel, third-party libraries and applications and in- house applications into a working system • Purpose of this training • Development of applications • Normal Linux applications, but using specifically chosen libraries
  • 7. Application Specific Operating Systems Application specific customization became all the more important with the advent of application domains such as multimedia, database, parallel computing etc., which demand high performance and high functionality. Resource management and communication/sharing between applications is to be done by the operating system code running as library routines in each application. Since these library routines can be made application-specific, the programmer has the flexibility to easily modify them whenever that is necessary for performance. Need for customized operating systems Greater Performance One of the primary motivation for such a system is greater performance. Problems with traditional operating systems is that they hide information behind high-level abstractions like processes, page table structures, IPC etc. And hence they provide a virtual machine to the user. Thus they give a fixed implementation to all applications thereby making domain specific optimizations impossible. General purpose implementations do reduce performance to a great extent and that application specific virtual memory policies can increase application performance. More Functionality and flexibility Further move towards customization is motivated by a need for more functionality. New application domains like multimedia need different sets of services. Incorporating all the services is not a good idea, because one may not use number of those service but still have to pay for them in the form of OS overhead. Sophisticated Security Modern application technologies such as Java require sophisticated security in the form of access controls, that default operating systems may not provide. Simplicity Simple rather than a complex kernel is easy to implement and is efficient. One may draw an analogy to RISC systems for this aspect. Issues and Problems • Protection and Sharing • Too much of flexibility • Application programmers aren’t operating systems designers • Backward compatibility and Portability Extensible Application Specific Operating Systems SPIN SPIN investigates kernels that allow applications to make policy decisions. All management policies are defined by embedded implementations called spindles. These spindles are dynamically loaded into the kernel.
  • 8. Merits: Secure because of the use of type safe language and compiler checks Good amount of extensibility, relatively with less burden on user Demerits: High overhead due to cross domain calls Fair sharing across applications is not possible Not reflective i.e. it cannot monitor and modify its own behavior as it executes Aegis – an Exokernel Aegis uses the familiar “end-to-end” argument that applies to low-level communications protocols. Maximum opportunity for application-level resource management is assured by designing a thin exokernel. The job of exokernel is to a. track ownership of resources b. perform access control. Merits: Truly extensible and flexible as it exposes the hardware Very efficient Demerits: Too flexible and hence may lead to portability and compatibility problems Less secure – it expects a high degree of trust Highly Complex software support is needed SPACE SPACE uses processors, address spaces, and a generalized exception mechanism as the basic abstractions. The processor has more than one privilege mode and thus arbitrary number of domains can exist in an address space. Merits: Virtualized resources as the fundamental abstraction and hence more customizable . Demerits: Building applications in terms of spaces, domains, and portals is highly complex and lacks portability. Synthetix This work is a follow on from Synthesis project. It makes use of feedback from the system and use it to dynamically modify the code. The make use of the information from dynamically changing conditions. They use this technique not only for designing OS but also for seamless mobility and few others. Merits: Absolutely no burden on user There are no problems of portability, security etc.. in fact it is implemented on HP-UX Demerits: No full support for customization
  • 9. Kea In Kea kernel can be reconfigured through RPC mechanism. RPC in Kea is very general unlike others and eliminate unnecessary steps often made in a general RPC system (like in LRPC). Kea has domains, threads, inter-domain calls and portals as abstractions. Merits: Provides a neat interface through user : user can use usual semantics to configure kernel Demerits: Huge penalty is incurred because of number of cross domain calls Vino VINO is a downloadable system, that uses sand-boxing [] to enforce trust and security. Sandboxing is a technique developed to allow embedding of untrusted application code inside trusted programs. Extensions are written in c++ and are compiler by a trusted compiler. This trusted code is then downloaded into the kernel. Each extension in VINO is run in the context of a transaction. Merits: Performance is only slightly worse than unprotected c++ Extensions can be implemented in conventional languages Demerits: Security of the system is heavily dependent on compiler. There is no guard if a malicious user tricks the compiler Spring Spring is also another micro-kernel based operating system developed to build operating system out of replaceable parts.
  • 10. Nach OS Nach os is a new teaching operating system and simulation environment. It makes it possible to give assignments that require students to write significant portions of each of the major pieces of a modern operating system: thread management, file systems, multiprogramming, virtual memory, and networking. The concepts are necessary to understand the computer systems of today and of the future: concurrency and synchronization, caching and locality, the trade-off between simplicity and performance, building reliability from unreliable components, dynamic scheduling, the power of a level of translation, distributed computing, layering, and virtualization. Basic services of Nach OS 1. Thread Management Basic working thread system and an implementation of semaphores. The assignment is to implement Mesa-style locks and condition variables using semaphores, and then to implement solutions to a number of concurrency problems using these synchronization primitives. 2. File Systems Real file systems can be very complex artifacts. The UNIX file system, for example, has at least three levels of indirection – the per-process file descriptor table, the system-wide open file table, and the in-core inode table – before one even gets to disk blocks. 3. Multiprogramming The code to create a user address space, load a Nachos file containing an executable image into user memory, and then to run the program is provided. Initial code is restricted to running only a single user program at a time. 4. Virtual Memory It asks students to replace their simple memory management code from the previous assignment with a true virtual memory system, that is, one that presents to each user program the abstraction of an (almost) unlimited virtual memory size by using main memory as a cache for the disk. No new hardware or operating system components are provided. 5. Networking At the hardware level, we simulate the behavior a network of workstations, each running Nachos, by connecting the UNIX processes running Nachos via sockets. The Nachos operating system and user programs running on it can communicate with other machines" running Nachos simply by sending messages into the emulated network the transmission is actually accomplished by socket send and receive. Introduction to Service Oriented Operating System The S(o)OS project addressed future distributed systems on the level of a holistic operating system architecture by drawing from Service Oriented Architectures and the strength of Grids. This decouples the OS from the underlying resource infrastructure, thus making execution across an almost unlimited number of varying devices possible, independent from the actual hardware. S(o)OS investigated alternative Operating System Architectures that base on a modular principle, where not only the individual modules may be replaced according to the respective resource specifics, but, more importantly, where also the modules may be distributed according to the executing process’ requirements. The Operating System thus becomes a dynamic service oriented infrastructure in which each executing process may specify the required services which are detected, deployed and adapted on
  • 11. the fly. S(o)OS examined how code can be segmented in a fashion that allows for concurrent execution over a heterogeneous infrastructure by combining the two approaches above. This principle implicitly supports parallelisation of code in a fashion that reduces the communication overhead. With the information about the code behaviour and dependencies, further optimisation steps can be taken related to the infrastructure’s communication layout, cache and memory limitations, resource specific capabilities and restrictions etc. Depending on the size and complexity of the segments, on-the-fly adaptation steps may furthermore be taken to increase heterogeneity and in particular to improve performance by exploiting the resource features. Introduction to Ubuntu Edge OS (Ubuntu Touch) Ubuntu Touch (also known as Ubuntu Phone) is a mobile version of the Ubuntu operating system developed by Canonical UK Ltd and Ubuntu Community. It is designed primarily for touchscreen mobile devices such as smartphones and tablet computers. Canonical released Ubuntu Touch 1.0, the first developer/partner version on 17 October 2013, along with Ubuntu 13.10 that "primarily supports the Galaxy Nexus and Nexus 4 phones, though there are images available for other phones and tablets". Ubuntu Touch uses the Qt 5-based touch user interface and various software frameworks originally developed for Maemo and MeeGo such as oFono as telephony stack, accounts-sso for single sign-on, and Maliit for input. Utilizing libhybris the system can often be used with Linux kernels used in Android, which makes it easily ported to most recent Android smartphones. Ubuntu Touch utilizes the same core technologies as the Ubuntu Desktop, so applications designed for the latter platform run on the former and vice versa. Additionally, Ubuntu Desktop components come with the Ubuntu Touch system; allowing Ubuntu Touch devices to provide a full desktop experience when connected to an external monitor. Ubuntu Touch devices can be equipped with a full Ubuntu session and may change into a full desktop operating system when plugged into a docking station. If plugged the device can use all the features of Ubuntu and user can perform office work or even play ARM-ready games on such device. Architecture: