Os PPT

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 30

LINUX

OPERATING
SYSTEM
Presented By –
Nidhi Madnani – A026
Netra Mahadik – A027
Krishna Palan – A040
INTRODUCTION
• Linux is a modern, free operating system
based on UNIX standards.
• It was first developed as a small but self-
contained kernel in 1991 by Linus Torvalds,
with the major design goal of UNIX
compatibility.
• The core Linux operating system kernel is
entirely original, but it can run much existing
free UNIX software.
• It has been designed to run efficiently and
reliably on common PC hardware, but also
runs on a variety of other platforms
• It can be used from wristwatches to
supercomputers. It is everywhere in our
phones, laptops, PCs, cars, and even in
refrigerators.
• The Linux kernel is distributed under the
GNU General Public License (GPL).
OVERVIEW OF
LINUX
ARCHITECTURE
THE SHELL

1. cp src dest Standard Input Standard Output


2. head -20 file
3. ls *.c
4. ls tb?.c
5. ls [apc]*
6. Sort <in
7. Sort >out
8. Sort <in >temp; head -30 <temp; rm temp;
Standard Error
9 . Sort <in | head -30
10. grep ter *.t | sort | head -20 | tail -5 >foo
BOOTING UP
• The Basic Input/Output System (BIOS) initializes the hardware,
including the screen and keyboard, and tests the main memory.
This process is also called POST (Power On Self Test).
• The BIOS boots up the hard drive, and it searches for the boot
block to figure out how to boot up the system. The MBR is located
in the first sector of the hard drive, the first 512 bytes. The MBR’s
main function is to provide the bootloader.
• The most common bootloader for Linux is GRUB (GRand Unified
Bootloader).
• The initramfs, is a temporary root filesystem that is built into the
kernel itself to load all the necessary drivers for the real root
filesystem
• The kernel runs /sbin/init. This then becomes the initial process,
which then starts other processes to get the system running. Most
other processes on the system trace their origin ultimately to init.
PROCESS struct task_struct {
volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped
MANAGEMENT */unsigned long flags; /* per process flags */
mm_segment_t addr_limit; /* thread address space:
0-0xBFFFFFFF for user-thead
0-0xFFFFFFFF for kernel-thread */
An instance of a program is called a struct exec_domain *exec_domain;
Process. In simple terms, any command long need_resched;
that you give to your Linux machine long counter;
long priority;
starts a new process. /* SMP and runqueue state
*/ struct task_struct *next_task, *prev_task;
Types of Processes: struct task_struct *next_run, *prev_run;
...
• Foreground Processes: They run on /* task state
the screen and need input from the *//* limits Contents of the process
user. For example Office Programs *//* file system info descriptor
/*
*/ ipc stuff
*//* tss for this task
• Background Processes: They run in *//* filesystem information
the background and usually do not *//* open file information
need user input. For example *//* memory management info
*//* signal handlers
Antivirus, daemons. */ ...
};
HOW DOES A
PROCESS EXECUTE?
The fork system call creates an exact
copy of the original process. The forking
process is called the parent process. The
new process is called the child process.

The parent and child each have their


own, private memory images. If the
parent subsequently changes any of its
variables, the changes are not visible to
the child, and vice versa.
SCHEDULING ALGORITHMS PROCESS MANAGEMENT COMMANDS

Linux distinguishes three classes of threads for scheduling


purposes:
1. Real-time FIFO – non-preemptive
2. Real-time Round Robin - preemptive by the clock
3. Timesharing
MEMORY
MANAGEMENT

Physical Memory Virtual Memory

• BUDDY ALGORITHM
• SLAB ALLOCATOR

 MEMORY MANAGEMENT UNDER LINUX HAS TWO COMPONENTS :


• The first deals with allocating and freeing physical memory – pages, group of pages, and small blocks of memory
• The second handles virtual memory, which is memory mapped into the address space of running processes
MANAGEMENT OF
PHYSICAL MEMORY
Linux separates physical memory into
three different zones or regions:
PAGE ALLOCATOR
AND BUDDY HEAP
• The page 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.
SPLITTING OF MEMORY IN BUDDY HEAP
DIFFERENT MEMORY ALLOCATORS

• Memory allocations in the Linux kernel occur dynamically (via


the page allocator)

• It even allocates statically (during system boot time, drivers


reserve a contiguous area of memory).

• Kernel memory uses slab allocator.

• Page cache stores entire pages of file contents for local and
network file I/O.
SLAB
ALLOCATION
STRATEGY
A slab is used for allocating memory for
kernel data structures and is made up of
one or more physically contiguous
pages.
A cache consists of one or more slabs.
There is a single cache for each unique
kernel data structure – a cache for the
data structure representing process
descriptors, a cache for file objects, a
cache for semaphores and so forth.
SLAB – ALLOCATION
ALGORITHM
• The slab allocation algorithm uses cache to store kernel
objects. When a cache is created, a number of objects are
allocated to the cache.
• The number of objects in the cache depends on the size of
the associated
• For example, a 12-KB slab (made up of three contiguous 4-KB
pages) could store six 2-KB objects.
• In LINUX, a slab may be in one of three possible states:
 Full
 Empty
 Partial
VIRTUAL
MEMORY

Logical View Physical View

 Virtual memory system maintains the address space visible to each process.
 It creates pages of virtual memory on demand, and manages the loading of these pages from disk;
 Or swapping back out to disk as required.
 The VM manager maintains two separate views of a process’s address space, logical view and physical view.
VM REGIONS
AND
LIFETIME Lifetime of a Virtual Address space :
• The kernel creates a new virtual
• Linux implements several types of address space
virtual memory. Most memory 1. When a process runs a new program
regions either by a file or by nothing. with the exec() system call.
2. Upon creation of a new process by
• A region backed by nothing is the the fork() system call.
simplest type of virtual memory
region. Such a region represents
demand-zero memory: when a
process tries to read a page in such a
region, it is simply given back a page
of memory filled with zeros.
LINUX FILE SYSTEM
• Structured collection of files on a disk drive or a partition.

• Manages the file name, file size, creation date, and much more
information about a file.

• Has a hierarchal file structure.

• Contains a root directory and its subdirectories.

• All other directories can be accessed from the root directory. 


LINUX FILE SYSTEM HIERARCHY
LINUX FILE SYSTEM HIERARCHY
/ (root) Root Directory
/bin User Binaries
/boot Boot Loader Files
/dev Device Files
/etc Configuration Files
/home User Home Directories
/lib System Libraries
/media Removable Media
/mnt Mounted Filesystem
/opt Add-on Application Software Packages
/sbin System Binaries
/srv Service Data
/tmp Temporary Files
/usr User Utilities and Applications
/proc Process Information
TYPES OF LINUX FILE SYSTEM
TYPES OF LINUX FILE SYSTEM

Ext
• Stands for Extended File System
• Developed for MINIX OS
• Older version, so no longer used

Ext2
• Maximum file size: 2TB
• Filename size: 255 characters
• Supports file compression
TYPES OF LINUX FILE SYSTEM

Ext3
• Maximum file size: 2TB
• Filename size: 255 characters
• Supports backward compatibility

Ext4
• Faster file system among all Ext file systems
• Compatible for SSD
• Default file system in Linux
TYPES OF LINUX FILE SYSTEM
JFS
• Stands for Journaled File System
• Developed by IBM
• Alternative to Ext4 file system
• Can be used when CPU power is limited

ReiserFS
• Alternative to Ext3 file system
• Dynamically supports file extension
• Has some drawbacks in performance
ACCESS RIGHTS

chmod Command
• Stands for change mode
• Used to change the access permissions of files and directories

Syntax: chmod <options> <permissions> <filename>


User Classes Types of
owner (u) Permissions
group (g) read (r)
others (o) write (w)
all (a) execute (x)
HOW TO READ PERMISSIONS ?
The first three characters (2-4) represent the permissions for the file's
owner.
Example: -rwxr-xr-- represents that the owner has read (r), write (w) and
execute (x) permission.

The second group of three characters (5-7) represents the permissions for
the group to which the file belongs.
Example: -rwxr-xr-- represents that the group has read (r) and execute (x)
permission, but no write permission.

The last group of three characters (8-10) represents the permissions for
everyone else.
Example: -rwxr-xr-- represents that there is read (r) only permission.
SYMBOLIC
MODE
Ways To Use
chmod
Command
ABSOLUTE
MODE
SYMBOLIC MODE

In symbolic mode, you can add, delete, or specify the permission set you
want by using the following operators.

Example: chmod o+wx test


ABSOLUTE MODE

In absolute mode, each permission is assigned a value as shown in the


following table.

Example: chmod 4 test

You might also like