Linux architecture

Post on 06-May-2015

2322 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

Transcript

Centre for Development of Advanced

ComputingChennai

18/6/08

Linux Architecture

By:-

Verule Amol R.

BOSS Team Member

CDAC-chennai

veruler@cdac.in

Centre for Development of Advanced

ComputingChennai

28/6/08

Linux Internal

Introduction

Kernel

Process Management

Memory Management

File System

Device Driver

Network Stack

Architecture-dependent code

Centre for Development of Advanced

ComputingChennai

38/6/08

Introduction

Operating System is a software designed to control the hardware of a system in order to allow users and application programs to make use of it.

Linux is a free operating system based on UNIX standards.

LINUX® is a registered trademark of Linus Torvalds.

Features of Linux.

Multiprogramming

Multi-user

Secure

Fast

Centre for Development of Advanced

ComputingChennai

48/6/08

Components of Linux System

Architecture of the GNU/Linux operating system

Centre for Development of Advanced

ComputingChennai

58/6/08

Components of a Linux System (Cont.)

When Linux is running in main memory,the it is divided in to two parts 1) User space. 2) Kernel space.

User's applications are running in user space.

Kernel is running in kernel space.

The system libraries (e.g. glibc) define a standard set of functions through which applications interact with the kernel, and which implement much of the operating-system functionality that does not need the full privileges of kernel code.

Centre for Development of Advanced

ComputingChennai

68/6/08

The Linux Kernel

Kernel is a resource manager whether resource being managed is a process,memory,hardware device.

Short history of Linux kernel development.

Centre for Development of Advanced

ComputingChennai

78/6/08

Linux Kernel

Types of Kernel

Monolithic Kernel.

(e.g. Linux kernel)

Micro kernel

(e.g. Windows NT kernel,Mach kernel etc.)

Centre for Development of Advanced

ComputingChennai

88/6/08

Structure of monolithic and micro-kernel-based operating systems

Monolithic kernel Micro Kernel

Centre for Development of Advanced

ComputingChennai

98/6/08

Linux Kernel 2.6.x

Characteristics that differ between the Linux kernel and other Unix variants:

Dynamic loading of kernel module

Preemptive

Symmetric multiprocessor (SMP) support.

Linux does not differentiate between threads and normal processes.

Linux provides an object-oriented device model with device

classes,hotpluggable events and user-space device file

system(sysfs).

Centre for Development of Advanced

ComputingChennai

108/6/08

Linux Kernel

Kernel version naming convention: Linux kernel currently consists of four numbers A.B.C[.D]

The A number denotes the kernel version. It is changed least

frequently, and only when major changes in the code and the concept

of the kernel occur.

The B number denotes the major revision of the kernel.

If B is even then kernel is stable else it is unstable.

The C number indicates the minor revision of the kernel is only

changed when new drivers or features are introduced.

minor fixes are handled by the D number.

Centre for Development of Advanced

ComputingChennai

118/6/08

Linux kernel

Block diagram of Linux Kernel.

Centre for Development of Advanced

ComputingChennai

128/6/08

Linux Kernel- System Call Interface

System call is the mechanism used by an application program to request service from the operating system.

API is a function definition that specifies how to obtain a given

service(ex.calloc,malloc ,free etc.), while System call is an explicit

request to the kernel made via a software interrupt (ex.brk)

Invoking a system call by user mode process.

Centre for Development of Advanced

ComputingChennai

138/6/08

Linux Kernel-Process Management

Process is a program in execution.

Process is represented in OS by

Process Control Block.

Centre for Development of Advanced

ComputingChennai

148/6/08

Linux Kernel-Process Management

Linux kernel stores the list of process in a circular doubly linked list called task_list.

Each element in task list is a process descriptor of the type

task_struct .

task_struct structure is allocated via slab/slub allocator.

Centre for Development of Advanced

ComputingChennai

158/6/08

Linux Kernel-Process Management Thread is a unit of execution or objects of activity within process.

Thread is simply a new process that happens to share the same

address space as its parent

Process creation:

fork () creates a child process that is a copy of current

process. it differs in PID,PPID. exec() loads new executable in to

address space. clone() creates a new

process(LWP) with its own identity, but that is allowed to share the data

structures of its parent.

Process Termination:

when process calls system call exit().

Process can also terminate involuntarily by

signals or exceptions it can not handle or ignore.

Centre for Development of Advanced

ComputingChennai

168/6/08

Linux Kernel-Process Management

Process state is defined in part of current activity of that process

The kernel implements a O(1) scheduler algorithm that operates in

constant time, regardless of the number of threads vying for the CPU.

It supports SMP.

Centre for Development of Advanced

ComputingChennai

178/6/08

Linux Kernel-Memory Management

Computer memory layout:

Centre for Development of Advanced

ComputingChennai

188/6/08

Linux Kernel-Memory Management

Linux’s physical memory-management system deals with allocating and freeing pages, groups of pages, and small blocks of memory.

It has additional mechanisms for handling virtual memory, memory

mapped into the address space of running processes.

Centre for Development of Advanced

ComputingChennai

198/6/08

Splitting of Memory in a Buddy Heap

Centre for Development of Advanced

ComputingChennai

208/6/08

Managing Physical Memory

The page allocator allocates and frees all physical pages; it can allocate ranges of physically-contiguous pages on request.

The allocator uses a buddy-heap algorithm to keep track of available physical pages.

Each allocatable memory region is paired with an adjacent partner.

Whenever two allocated partner regions are both freed up they are combined to form a larger region.

If a small memory request cannot be satisfied by allocating an existing small free region, then a larger free region will be subdivided into two partners to satisfy the request.

Memory allocations in the Linux kernel occur either statically (drivers reserve a contiguous area of memory during system boot time) or dynamically (via the page allocator).

Centre for Development of Advanced

ComputingChennai

218/6/08

Virtual Memory

The VM system maintains the address space visible to each process: It creates pages of virtual memory on demand, and manages the loading of those pages from disk or their swapping back out to disk as required.

The VM manager maintains two separate views of a process’s address space:A logical view describing instructions concerning the layout of the address space.The address space consists of a set of non overlapping regions, each representing a continuous, page-aligned subset of the address space.

A physical view of each address space which is stored in the hardware page tables for the process.

mkswap /dev/sdax

swapon /dev/sdax

swapoff /dev/sdax

Centre for Development of Advanced

ComputingChennai

228/6/08

File System

A file system is the methods and data structures that an operating system uses to keep track of files on a disk or partition; that is, the way the files are organized on the disk.

A file is an ordered string of bytes

Files are organized in directory.

File information like size,owner,access permission etc.

are stored in a separate data structure called inode.

Superblock is a data structure containing information

about file system

Centre for Development of Advanced

ComputingChennai

238/6/08

Filesystem

The Virtual Filesystem (also known as Virtual Filesystem Switch or VFS) is a kernel software layer that handles all system calls related to a standard Unix filesystem. Its main strength is providing a common interface to several kinds of filesystems.

ex. copy a file from MS-dos filesystem to Linux

Centre for Development of Advanced

ComputingChennai

248/6/08

Filesystem

file object stores information about the interaction between an open file and a process. This information exists only in kernel memory during the period when a process has the file open.

Centre for Development of Advanced

ComputingChennai

258/6/08

Filesystem maintenance

Filesystems checked at boot up

Maintaining consistency with fsck,e2fsck

lost+found

command line utility for Filesystem maintenance

tune2fs

dump2fs

debugfs

Centre for Development of Advanced

ComputingChennai

268/6/08

Device Driver

Device drivers take on a special role in the Linux kernel. They are distinct “black boxes” that make a particular piece of hardware respond to a well-defined internal programming interface; they hide completely the details of how the device works.

Linux Device Driver are categorised in three types such as

Character Device Driver

Block Device Driver

Network Device Driver.

Centre for Development of Advanced

ComputingChennai

278/6/08

Network stack

The network stack, by design, follows a layered architecture modeled after the protocols themselves. Recall that the Internet Protocol is the core network layer protocol that sits below the transport protocol . Above TCP is the sockets layer, which is invoked through the SCI.

The sockets layer is the standard API to the networking subsystem

and provides a user interface to a variety of networking protocols.

From raw frame access to IP protocol data units and up to TCP and

the User Datagram Protocol (UDP), the sockets layer provides a

standardized way to manage connections and move data between

endpoints.

Centre for Development of Advanced

ComputingChennai

288/6/08

Architecture-dependent code

While much of Linux is independent of the architecture on which it runs, there are elements that must consider the architecture for normal operation and for efficiency. The ./linux/arch subdirectory defines the architecture-dependent portion of the kernel source contained in a number of subdirectories that are specific to the architecture . For a typical desktop, the i386 directory is used. Each architecture subdirectory contains a number of other subdirectories that focus on a particular aspect of the kernel, such as boot, kernel, memory management, and others.

Centre for Development of Advanced

ComputingChennai

298/6/08

Thank You

top related