linux kernel overview 2013

28

Click here to load reader

Upload: rohit-pratap-singh

Post on 16-Apr-2017

1.641 views

Category:

Education


0 download

TRANSCRIPT

Page 1: linux kernel overview 2013

LINUX KERNEL

Presented by:Rohit Pratap SinghCS- 05/09Jorhat Engineering College

Page 2: linux kernel overview 2013

Background on Linux

Linus Torvalds – Creator of LinuxOpen Source Operating SystemFree SoftwareSource Code Available

Page 3: linux kernel overview 2013

WHAT IS A KERNEL?

CORE OF THE

OPERATING SYSTEM

Page 4: linux kernel overview 2013

KERNELArchitecture

Monolithic

Contains all the OS related stuff

1. Microkernel

Contains only the OS core

2.Hybrid

Combination of Monolithic & Microkernel

3.

Linux Kernel is implemented using Monolithic Architecture

Page 5: linux kernel overview 2013

Difference

Page 6: linux kernel overview 2013

KERNEL MODULE Sections of kernel code that can be compiled, loaded,

and unloaded independent of the rest of the kernel. A kernel module may typically implement a device

driver, a file system, or a networking protocol. The module interface allows third parties to write and

distribute, on their own terms, device drivers or file systems that could not be distributed under the GPL.

Kernel modules allow a Linux system to be set up with a standard, minimal kernel, without any extra device drivers built in.

Three components to Linux module support:◦ module management ◦ driver registration◦ conflict resolution

Page 7: linux kernel overview 2013

Module ManagementSupports loading modules into memory and

letting them talk to the rest of the kernel.Module loading is split into two separate

sections:◦ Managing sections of module code in

kernel memory◦ Handling symbols that modules are

allowed to referenceThe module requestor manages loading

requested, but currently unloaded, modules; it also regularly queries the kernel to see whether a dynamically loaded module is still in use, and will unload it when it is no longer actively needed.

Page 8: linux kernel overview 2013

Driver RegistrationAllows modules to tell the rest of the kernel

that a new driver has become available.The kernel maintains dynamic tables of all

known drivers, and provides a set of routines to allow drivers to be added to or removed from these tables at any time.

Registration tables include the following items: ◦ Device drivers◦ File systems ◦ Network protocols◦ Binary format

Page 9: linux kernel overview 2013

Conflict ResolutionA mechanism that allows different device

drivers to reserve hardware resources and to protect those resources from accidental use by another driver

The conflict resolution module aims to:◦ Prevent modules from clashing over access

to hardware resources◦ Prevent auto probes from interfering with

existing device drivers◦ Resolve conflicts with multiple drivers

trying to access the same hardware

Page 10: linux kernel overview 2013

Linux Kernel Functional Overview

Process ManagementMemory ManagementKernel SynchronizationFile System ManagementInter-process communicationDevice and I/O ManagementNetwork ManagementSecurity

Page 11: linux kernel overview 2013

Process ManagementLinux implements the fork() and exec() process model.

Process identity consists of-•Process ID (PID): unique identifier, used to specify the process to the kernel when an application makes a system call to signal, modify, or wait for another process.

•Credentials: Each process must have an associated user ID and one or more group IDs that determine the process’s rights to access system resources and files.

•Personality: Not traditionally found on UNIX systems, but under Linux each process has an associated personality identifier that can slightly modify the semantics of certain system calls.Used primarily by emulation libraries to request that system calls be compatible with certain specific flavors of UNIX.

The process’s environment is inherited from its parent, and is composed of two

null-terminated vectors:The argument vector lists the command-

line arguments used to invoke the running program; conventionally starts with the

name of the program itselfThe environment vector is a list of

“NAME=VALUE” pairs that associates named environment variables with

arbitrary textual values.

Process context: state of the running program; includes scheduling context,

accounting information, file table, file-system context, signal-handler table, and virtual memory context

Page 12: linux kernel overview 2013

Memory ManagementThe Linux kernel allocates memory to itself using the buddy system as

well as slab allocation.

Virtual memory paging system

allocates memory to processes.

The pageout-policy algorithm decides

which pages to write out to disk.

Uses a modified version of the second-chance

(clock) algorithm.

Each page has an age that is adjusted on each pass of

the clock.

The age value allows the

algorithm to select pages on

a LRU policy.

The paging mechanism actually

carries out the transfer, and pages

data back into physical memory as

needed:

Supports paging both to dedicated swap partitions and to normal files.

Uses a next-fit algorithm to

write pages to contiguous disk

blocks.

Page 13: linux kernel overview 2013

Splitting of Memory in a Buddy Heap

Page 14: linux kernel overview 2013

Kernel Synchronization

A request for kernel-mode

execution can occur in two

waysA running program

may request an operating system

service, either explicitly via a system call, or implicitly, for

example, when a page fault occurs.

A device driver may deliver a hardware

interrupt that causes the CPU to start

executing a kernel-defined handler for

that interrupt.

Kernel synchronizatio

n requires a framework

that will allow the kernel’s

critical sections to run

without interruption by

another critical section.

Linux introduced a preemptive

kernel in Version 2.6

Linux provides semaphores for

locking in the kernel.

Multiprocessor machines use

spinlocks for short durations; single

processor machines disable preemption

instead.

Page 15: linux kernel overview 2013

File System To the user, Linux’s file system appears as a

hierarchical directory tree obeying UNIX semantics. Internally, the kernel hides implementation details

and manages the multiple different file systems via an abstraction layer, that is, the virtual file system (VFS).

The Linux VFS is designed around object-oriented principles and is composed of two components:◦ A set of definitions that define what a file object is

allowed to look like The inode-object and the file-object structures

represent individual files the file system object represents an entire file

system◦ A layer of software to manipulate those objects.

Page 16: linux kernel overview 2013

The Linux Ext2fs File System Ext2fs uses a mechanism similar to that of BSD Fast

File System (ffs) for locating data blocks belonging to a specific file.

The main differences between ext2fs and ffs concern their disk allocation policies.◦ In ffs, the disk is allocated to files in blocks of 8Kb,

with blocks being subdivided into fragments of 1Kb to store small files or partially filled blocks at the end of a file.

◦ Ext2fs does not use fragments; it performs its allocations in smaller units. The default block size on ext2fs is 1Kb, although 2Kb and 4Kb blocks are also supported.

◦ Ext2fs uses allocation policies designed to place logically adjacent blocks of a file into physically adjacent blocks on disk, so that it can submit an I/O request for several disk blocks as a single operation.

Page 17: linux kernel overview 2013

Ext2fs Block-Allocation Policies

Page 18: linux kernel overview 2013

More ext standards (the extended file

system)• Journaling file system: keeps

track of changes to be made in a journal, which makes the system easier to restore after a crash

ext3:• Can pre-allocate on-disk space

for a file• Provides timestamps measured

in nanosecondsext4:

Page 19: linux kernel overview 2013

Input and Output Device drivers appear as normal files.• Users open an access channel to a

device in the same way they open any other file.

• Devices are protected by the same permission system as files.Linux recognizes three classes of

devices:• Block devices: allow random access to independent, fixed-

size blocks of data (e.g. disks, CD-ROMs, flash memory)• Character devices: sequential access, data not

necessarily in blocks• Network devices: users communicate with network

devices through the kernel’s network subsystem

Page 20: linux kernel overview 2013

Interprocess Communication

Linux informs processes that an event has occurred via signals.• There is a limited number

of signals, and they cannot carry information.

• Communication within the kernel is accomplished via scheduling states and wait queue structures.

Mechanisms for passing data between processes:• The pipe mechanism

allows a child process to inherit a communication channel to its parent, data written to one end of the pipe can be read a the other.

• Shared memory: any data written by one process to a shared memory region can be read immediately by any other process that has mapped that region into its address space.

Page 21: linux kernel overview 2013

Network ManagementNetworking is a key

area of functionality for Linux.

• It supports the standard Internet protocols for UNIX-to-UNIX communications.

• It also implements protocols native to non-UNIX operating systems, e.g., Appletalk and IPX.

Networking in the Linux kernel is implemented

by three software layers:

• Socket interface: works with network addresses for a variety of network protocols

• Protocol drivers: implements creation and reassembly of packets, routing between hosts, etc.

• Network device drivers: interface with specific devices

Page 22: linux kernel overview 2013

Security

Authentication: no one can access system without entry rights

• Uses a password file to store encrypted passwords.• Pluggable authentication modules (PAM): allows on-

demand loading of authentication modules that improve securityAccess control: no one can access objects within the system without access rights

• Files, devices, and other objects share the same access-control system.

• Implemented through numeric identifiers for users (UID) and groups (GID)

• Objects have a protection mask that specifies which access modes (read, write, or execute) are granted to owner, group, and world.

Page 23: linux kernel overview 2013

Linux Source Tree Layout/usr/src/linuxDocumentation

archfs

init kernel

include

ipc

drivers

net

mmlib

scripts

alphaarmi386ia64m68kmipsmips64ppcs390shsparcsparc64

acornatmblockcdromchardiofc4i2ci2oideieee1394isdnmacintoshmiscnet…

adfsaffsautofsautofs4bfscodecramfsdevfsdevptsefsext2fathfshpfs…

asm-alphaasm-armasm-genericasm-i386asm-ia64asm-m68kasm-mipsasm-mips64linuxmath-emunetpcmciascsivideo …

adfsaffsautofsautofs4bfscodecramfsdevfsdevptsefsext2fathfshpfs …

802appletalkatmax25bridgecoredecneteconetethernetipv4ipv6ipxirdakhttpdlapb…

Page 24: linux kernel overview 2013

Linux kernel development cycle

Page 25: linux kernel overview 2013

Linux kernel development cycle Version 0.01 (May 1991) had no networking, ran only

on 80386-compatible Intel processors and on PC hardware, had extremely limited device-drive support, and supported only the Minix file system.

Linux 1.0 (March 1994) included these new features:◦ Support for UNIX’s standard TCP/IP networking

protocols◦ BSD-compatible socket interface for networking

programming◦ Device-driver support for running IP over an

Ethernet◦ Enhanced file system◦ Support for a range of SCSI controllers for

high-performance disk access◦ Extra hardware support

Version 1.2 (March 1995) was the final PC-only Linux kernel.

Page 26: linux kernel overview 2013

Linux 2.0 Released in June 1996, 2.0 added two major new

capabilities:◦ Support for multiple architectures, including a fully

64-bit native Alpha port.◦ Support for multiprocessor architectures

Other new features included:◦ Improved memory-management code◦ Improved TCP/IP performance◦ Support for internal kernel threads, for handling

dependencies between loadable modules, and for automatic loading of modules on demand.

◦ Standardized configuration interface

Page 27: linux kernel overview 2013

Conclusion

StabilityRuns on

old hardwar

e

Free and opensou

rceSecurity

Page 28: linux kernel overview 2013

THANK YOUContact info – [email protected]

www.facebook.com/rohitkako