unit 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 109

Definition

An Operating System, or OS, is low-level software that enables


a user and higher-level application software to interact with a
computer’s hardware and the data and other programs stored
on the computer.
CH. 1: Operating System Overview
COMPUTER SYSTEM OVERVIEW

The OS manages secondary memory and I/O (input/output)


devices on behalf of its users.

BASIC ELEMENTS
 At a top level, a computer consists of processor, memory,
and I/O components, with one or more modules of each type.
 These components are interconnected in some fashion to
achieve the main function of the computer, which is to
execute programs.
COMPUTER SYSTEM OVERVIEW

There are four main structural elements:


Processor:
 Controls the operation of the computer and performs its
data processing functions.
 When there is only one processor, it is often referred to as
the central processing unit (CPU).
Main memory (real memory or primary memory):
 Stores data and programs. This memory is typically volatile;
that is, when the computer is shut down, the contents of the
memory are lost.
 In contrast, the contents of disk memory are retained even
when the computer system is shut down.
COMPUTER SYSTEM OVERVIEW

 I/O modules:
Move data between the computer and its external
environment. The external environment consists of a variety of
devices, including secondary memory devices (e.g., disks),
communications equipment, and terminals.

 System bus:
Provides for communication among processors, main
memory, and I/O modules.
OPERATING SYSTEM OBJECTIVES AND FUNCTIONS

 An OS is a program that controls the execution of application


programs and acts as an interface between applications and the
computer hardware. It has three objectives:
 Convenience:
An OS makes a computer more convenient to use.
 Efficiency:
An OS allows the computer system resources to be used in an
efficient manner.
 Ability to evolve:
An OS should be constructed in such a way as to permit the
effective development, testing, and introduction of new system
functions with-out interfering with service.
The OS as a User/Computer Interface

The most important collection of system programs comprises


the OS.

 The OS masks the details of the hardware from the programmer


and provides the programmer with a convenient interface for
using the system.
 It acts as mediator, making it easier for the programmer and for
application programs to access and use those facilities and
services.
Functions of Operating-System

The OS performs the following functions.

1. It provides a convenient and an efficient environment for


users to execute programs.
2. It is a software which manages hardware.
3. An operating system controls the allocation of resources like
memory, processors, devices, and information.
4. It makes sure that different programs and multi-users do not
interfere with each other.
Functions of Operating-System
• The operating system manages computer resources, especially
the allocation or assignment of the resources among other
programs.
• Management tasks include scheduling the resources to avoid
conflicts and interference between programs.
Functions of Operating-System

1. Process Management
• A program is a set of logical instructions given to the
computer.
• A program that is in an execution state is called a process.
• A process needs certain resources-such as CPU time,
memory, files and I/O devices to accomplish its tasks. These
resources are allocated to the process either when they are
created or while they are executing.
• The operating system helps in the allocation of resources to
each process.
• Each process is allowed to use the CPU for a limited time. It
must then give up control and thus becomes suspended until
its next turn.
Functions of Operating-System
• To maximize CPU utilization and allow multiple processes to
run, process scheduling is performed by the OS.
• The operating system is responsible for creation, deletion,
and scheduling of various processes that are being executed
at any point of time.
2. Memory Management
• A computer program remains in main (RAM) memory during its
execution.
• To improve CPU usage several processes are being executed
simultaneously in the memory.
• The OS keeps track of every memory location, that is either
assigned to some process or is free.
• It also checks how much memory should be assigned to each
process.
Functions of Operating-System

3. Input / Output Management


• A few examples of the variety of input/output devices on a
modern computer are- mouse, keyboards, disk drives, USB
devices, I/O, printers, special devices for the physically
challenged, etc.
• Operating system provides a generic, consistent, convenient
and reliable way to access I/O devices.
• OS responds to the user keystrokes, mouse clicks and other
input formats.
• It then interprets the I/O requests so that requested
input/output functions can be performed.
• For this the operating system requires device driver software
to interact with a particular hardware device.
Functions of Operating-System

4. File and Disk Management

• Computer systems have secondary storage devices like


magnetic disk, magnetic tape, optical media, flash drives, etc.
for permanent storage of programs and data.
• The programs and the user data are stored in files.
• A file is a sequence of bits, bytes, lines or records.
• The operating system is responsible for allocating space for
files on secondary storage media.
• A file, especially a large file, may or may not be stored in a
contiguous location on a physical disk drive. If the file is of
large size, it is fragmented into smaller pieces.
Functions of Operating-System

• The OS then keeps track of the memory location allocated


to each piece of the file on the storage disk.
• The operating system is thus responsible for the
organisation of the file system.
• It guarantees that the read and write operations performed
on the secondary storage device are secure and reliable.
• The operating system must be able to read, write and search
each file whenever it is required, keeping the access time to
the minimum.
Functions of Operating-System

5. User Interface

• A User Interface (UI) is the part of an operating system,


program or device that the user uses to input and receive
data.
• A Text User Interface (TUI) or Command Line Interface (CLI)
allows users to interact with an operating system by typing
commands in a terminal or console window.
• The users type a command or series of commands for each
task they want to perform on a visual prompt.
• Examples of command line based operating systems are DOS
(Disk Operating System), and UNIX etc
Functions of Operating-System

Graphical User Interface (GUI) is an easy to use interface.


• It uses graphics, along with a keyboard and a mouse, to
provide an easy-to-use interface to a program.
• A GUI makes interaction for the user easy with the
operating system or applications because it provides you
with features like pull-down menus, buttons, scrollbars,
iconic images, wizards and other icons.
• Examples of GUI operating systems are Windows, Linux, and
Solaris.
Functions of Operating-System

6. Network Management
• An Operating System is responsible for the computer
system networking via a distributed environment.
• A distributed system is a collection of processors, which do
not share memory, clock pulse or any peripheral devices.
• Each processor is having its own clock pulse, and RAM and
they communicate through network.
• Access to shared resource permits increased speed,
increased functionality and enhanced reliability.
• Various networking protocols are TCP/IP(Transmission
Control Protocol/ Internet Protocol), UDP (User Datagram
Protocol), FTP (File Transfer Protocol), HTTP (Hyper Text
Transfer protocol), NFS (Network File System) etc.
Operating-System Services

OS provides certain services to programs and to users of those


programs.

Program development:

• The OS provides a variety of facilities and services, such as


editors and debuggers, to assist the programmer in creating
programs.
• These services are in the form of utility programs that, while
not strictly part of the core of the OS, are supplied with the
OS and are referred to as application program development
tools.
Operating-System Services
Operating-System Services

• A number of steps need to be performed to execute a program.


• Instructions and data must be loaded into main memory, I/O
devices and files must be initialized, and other resources must be
prepared.
• The OS handles these scheduling duties for the user.
Operating-System Services

• Each program requires input and produces output.


• The OS hides some of the details of the underlying hardware for
such I/O.
• All the user sees that the I/O has been performed, without those
details.
Operating-System Services
File-System management

• File-System management
– Files usually organized into directories
– Access control on most systems to determine who can
access what?
– OS activities include
• Creating and deleting files and directories
• Primitives to manipulate files and dirs
• Mapping files onto secondary storage
• Backup files onto stable (non-volatile) storage media
Operating-System Services
Communications

 There are instances where processes need to communicate


with each other to exchange information.

 It may be between processes running on the same


computer or running on different computers.

 The OS provides these services to application programs,


making inter-process communication possible, and relieving
the user of having to worry about how this is accomplished.
Operating-System Services
Error Detection and Response

 There are internal and external hardware errors, such as


a memory error, or a device failure or malfunction; and
various software errors, such as attempt to access
forbidden memory location, and inability of the OS to
grant the request of an application.
 The OS must provide a response that clears the error
condition with the least impact on running applications
by either:
 ending the program that caused the error,
 to retrying the operation,
 to simply reporting the error to the application.
Operating-System Services
The OS as Resource Manager
A computer is a set of resources for the movement, storage, and
processing of data and for the control of these functions. The OS
is responsible for managing these resources.

OS as a control mechanism is unusual in two respects:

•The OS functions in the same way as ordinary computer


software; that is, it is a program or suite of programs executed by
the processor.
•The OS frequently relinquishes control and must depend on the
processor to allow it to regain control.
• The OS provides instructions for the processor. The OS directs
the processor in the use of the other system resources and in
the timing of its execution of other programs.
The OS as Resource Manager

• A portion of the OS is in main memory.


• This includes the Kernel , or nucleus, which contains the most
frequently used functions in the OS and, at a given time, other
portions of the OS currently in use.
The OS as Resource Manager

• The remainder of main memory contains user programs and


data. The memory management hardware in the processor
and the OS jointly control the allocation of main memory.

• The OS decides when an I/O device can be used by a program


in execution and controls access to and use of files.

• The processor itself is a resource, and the OS must


determine how much processor time is to be devoted to the
execution of a particular user program.
Operating-System Services

• A good OS will collect usage statistics for various resources and


monitor performance parameters such as response time.
• On any system, this information is useful in anticipating the need
for future enhancements and in tuning the system to improve
performance.
• On a multiuser system, the information can be used for billing
purposes.
Operating-System Services
Protection and Security
• Protection – any mechanism for controlling access of processes
or users to resources defined by the OS
• Security – defense of the system against internal and external
attacks
– Huge range, including denial-of-service, worms, viruses, identity
theft, theft of service
• Systems generally first distinguish among users, to determine
who can do what
– User identities (user IDs, security IDs) include name and associated
number, one per user
– User ID then associated with all files, processes of that user to
determine access control
– Group identifier (group ID) allows set of users to be defined and
controls managed, then also associated with each process, file
– Privilege escalation allows user to change to effective ID with more
rights
The Evolution of OS
1. Serial Processing

1. Serial Processing
• From the late 1940s to the mid-1950s, the programmer
interacted directly with the computer hardware; there was
no OS.
• These computers were run from a console consisting of
display lights, toggle switches, some form of input device,
and a printer.
• Programs in machine code were loaded via the input device
(e.g. a card reader).
• If an error halted the program, the error condition was
indicated by the lights.
• If the program proceeded to a normal completion, the out-
put appeared on the printer.
The Evolution of OS
1. Serial Processing

These early systems presented two main problems:

Scheduling:
• Most installations used a hardcopy sign-up sheet to reserve
computer time.
• A user could sign up for a block of time in multiples of a half
hour or so.
• A user might sign up for an hour and finish in 45 minutes;
this would result in wasted computer processing time.
• Or the user might run into problems, not finish in the allotted
time, and be forced to stop before resolving the problem.
The Evolution of OS
1. Serial Processing

Setup time:
• A single program, called a job , could involve loading the
compiler plus the high-level language program (source
program) into memory, saving the compiled program (object
program) and then loading and linking together the object
program and common functions.
• Each of these steps could involve mounting or dismounting
tapes or setting up card decks.
• If an error occurred, the hapless user typically had to go back
to the beginning of the setup sequence. Thus, a considerable
amount of time was spent just in setting up the program to
run.
The Evolution of OS
2. Simple Batch Systems

2. Simple Batch Systems


• Early computers were very expensive, and wasted time due to
scheduling and setup time.
• To improve utilization, the concept of a batch OS was
developed.
o The first batch OS (and the first OS of any kind) was
developed in the mid-1950s by General Motors for use on
an IBM 701 [WEIZ81]. The concept was subsequently
refined and implemented on the IBM 704 by a number of
IBM customers.
o By the early 1960s, a number of vendors had developed
batch operating systems for their computer systems.
The Evolution of OS
2. Simple Batch Systems

• The simple batch-processing scheme used a piece of software


known as the monitor.
• The user did not have direct access to the processor.
• The user submitted the job on cards or tape to a computer
operator, who batched the jobs together sequentially and
placed the entire batch on an input device, for use by the
monitor.
• Each program was constructed to branch back to the monitor
when it completed processing, at which point the monitor
automatically begin loading the next program.
Two points of view:
that of the monitor,
and that of the processor.
Memory Layout for a Resident
Monitor

Two points of view:


1. that of the monitor
2. that of the processor.
The Evolution of OS
2. Simple Batch Systems
Monitor point of view
• The monitor controls the sequence of events and hence much of
the monitor must always be in main memory and available for
execution (resident monitor).
• The rest of the monitor consists of utilities and common functions
that are loaded as subroutines to the user program at the beginning
of any job that requires them.
• The monitor reads in jobs one at a time from the input device
(cards/tapes).
• After reading, the current job is placed in the user program area,
and control is passed to this job.
• When the job is completed, it returns control to the monitor,
which immediately reads in the next job.
• The results of each job are sent to an output device, such as a
printer, for delivery to the user.
The Evolution of OS
2. Simple Batch Systems

Processor point of view


• The processor is executing instructions from the portion of
main memory containing the monitor.
• These instructions cause the next job to be read into another
portion of main memory.
• Once a job has been read in, the processor will encounter a
branch instruction in the monitor that instructs the
processor to continue execution at the start of the user
program.
• The processor will then execute the instructions in the user
program until it encounters an ending or error condition.
• Either event causes the processor to fetch its next instruction
from the monitor program.
The Evolution of OS
2. Simple Batch Systems

The monitor, or batch OS, is a computer program that relies on the


ability of the processor to fetch instructions from various portions of
main memory.

Other hardware features are as below:

•Memory protection:
 While the user program is executing, it must not alter the
memory area containing the monitor.
 If such an attempt is made, the processor hardware should
detect an error and transfer control to the monitor.
 The monitor would then abort the job, print out an error
message, and load in the next job.
The Evolution of OS
2. Simple Batch Systems
• Timer:
• A timer is used to prevent a single job from monopolizing
the system. The timer is set at the beginning of each job.
• If the timer expires, the user program is stopped, and
control returns to the monitor.
Privileged instructions:
• Privileged instructions are machine level instructions and can
be executed only by the monitor.
• If the processor encounters such an instruction while
executing a user program, an error occurs causing control to
be transferred to the monitor.
Interrupts:
• This feature gives the OS more flexibility in relinquishing
control to, and regaining control from, user programs.
The Evolution of OS
2. Simple Batch Systems

Modes of operation
A user program executes in a user mode, in which certain areas of
memory are protected from the user’s use, and in which certain
instructions may not be executed.
The monitor executes in a system mode (kernel mode) in which
privileged instructions may be executed, and in which protected areas
of memory may be accessed.
With a batch OS, processor time alternates between execution of
user programs and execution of the monitor. There have been two
sacrifices:
 Some main memory is now given over to the monitors and
 some processor time is consumed by the monitor.
Both of these are forms of overhead still the simple batch system
improves utilization of the computer.
The Evolution of OS
2. Simple Batch Systems
The Evolution of OS
3. Multiprogrammed Systems
The Evolution of OS
3. Multiprogrammed Systems
Multiprogrammed Batch Systems
Even with the automatic job sequencing provided by a simple batch OS,
the processor is often idle. The problem is I/O devices are slow
compared to the processor.
System Utilization Example

The computer spends over 96% of its time waiting for I/O devices to
finish transferring data to and from the file.
The Evolution of OS
3. Multiprogrammed Systems

Figure (a) shows a single program, referred to as


uniprogramming.
• The processor spends a certain amount of time executing,
until it reaches an I/O instruction.
• It must then wait until that I/O instruction concludes before
proceeding.
The Evolution of OS
3. Multiprogrammed Systems

There must be enough memory to hold the OS (resident


monitor) and one user program.
Suppose there is room for the OS and two user programs. When
one job needs to wait for I/O, the processor can switch to the
other job, which is likely not waiting for I/O.
The Evolution of OS
3. Multiprogrammed Systems
The Evolution of OS
4. Time-Sharing Systems
The Evolution of OS
4. Time-Sharing Systems

Time-Sharing Systems
With the use of multiprogramming, batch processing is quite efficient
but for many jobs, it is desirable to provide a mode in which the user
interacts directly with the computer. Hence an interactive mode is
essential.
Multiprogramming allows the processor to handle multiple batch jobs
at a time, multiprogramming can also be used to handle multiple
interactive jobs, this technique is referred to as time sharing, because
processor time is shared among multiple users.
• In a time-sharing system, multiple users simultaneously access the
system through terminals, with the OS interleaving the execution of
each user program in a short burst or quantum of computation.
• If there are n users actively requesting service at one time, each
user will only see on the average 1/n of the effective computer
capacity, not counting OS overhead.
The Evolution of OS

Both batch processing and time sharing use multiprogramming. The


key differences are listed in following table.
Operating system structures:
Layered, Monolithic and Microkernel

• A structure of an Operating System determines how it has


been designed and how it functions.

• Few structures of an Operating system are:


 Simple structure,
 monolithic systems,
 layered systems,
 microkernels,
 client-server models,
 virtual machines, and
 exokernals.
Operating system structures:
Layered, Monolithic and Microkernel

1. Simple Structure

• Such operating systems do not have well defined structure


and are small, simple and limited systems.
• The interfaces and levels of functionality are not well
separated.
• MS-DOS is an example of such operating system.
• In MS-DOS application programs are able to access the basic
I/O routines.
• These types of operating system cause the entire system to
crash if one of the user programs fails.
Operating system structures:
Layered, Monolithic and Microkernel
Operating system structures:
Layered, Monolithic and Microkernel

Important:
What is a kernel ?
• When our computer is running in kernel mode, all the
permissions are available.
• We can think of it as an administrator. In macOS, this is known
as giving ‘root’ access.
• In Windows, you invoke this by running applications as
‘administrator.’

• If not the kernel mode, the computer normally runs in user


mode, where a lot of permissions are not given to the user
that may damage the system files.
2. Monolithic System structure in an OS

• The monolithic operating system is a operating system in


which file management, memory management, device
management, and process management are directly
controlled within the kernel.
• The kernel can access all the resources present in the system.
• In monolithic systems, each component of the operating
system is contained within the kernel.
• Operating systems that use monolithic architecture were first
time used in the 1970s.
• The monolithic operating system is also known as the
monolithic kernel.
2. Monolithic System structure in an OS

• A monolithic kernel is an operating system architecture where


the entire operating system is working in kernel space.
• This is operating system is used to perform small tasks like
batch processing and time-sharing tasks in banks.
• The monolithic kernel acts as a virtual machine that controls all
hardware parts.
• A set of primitives or system calls implement all operating
system services such as process management, concurrency,
and memory management.
• Device drivers can be added to the kernel as modules.
2. Monolithic System structure in an OS
2. Monolithic System structure in an OS
Advantages of Monolithic Kernel
• The execution of the monolithic kernel is quite fast as the
services such as memory management, file management,
process scheduling, etc., are implemented under the same
address space.
• A process runs completely in single address space in the
monolithic kernel.
• The monolithic kernel is a static single binary file (These files
store multiple types of data like image, video, and audio in the
same file).
Disadvantages of Monolithic Kernel
• If any service fails in the monolithic kernel, it leads to the
failure of the entire system.
• The entire operating system needs to be modified by the user
to add any new service.
3. Layered Systems Structure in
Operating Systems

• This system works in layers.

• It was designed by E.W. Dijkstra in 1968.

Working

• There are six layers in the system, each with different


purposes.
3. Layered Systems Structure in
Operating Systems

Layer Function
5 The operator
4 User Programs
3 Input / Output Management
2 Operator-process communication
1 Memory and drum management
0 Processor allocation and multiprogramming
3. Layered Systems Structure in
Operating Systems

Layer 0 – Processor Allocation and Multiprogramming

• This layer deals with the allocation of processor, switching


between the processes when interrupts occur or when the
timers expire.

• The sequential processes can be programmed individually


without having to worry about other processes running on the
processor.

• Layer 0 provides that basic multiprogramming of the CPU


3. Layered Systems Structure in
Operating Systems
Layer 1 – Memory and Drum Management
• This layer deals with allocating memory to the processes in
the main memory.
• The drum is used to hold parts of the processes (pages) for
which space couldn’t be provided in the main memory.
• The processes don’t have to worry if there is available
memory or not as layer 1 software takes care of adding
pages wherever necessary.
Layer 2 – Operator-Process communication
• In this layer, each process communicates with the operator
(user) through the console.
• Each process has its own operator console and can directly
communicate with the operator.
3. Layered Systems Structure in
Operating Systems
Layer 3 – Input / Output Management
• This layer handles and manages all the I/O devices, and it
buffers the information streams that are made available to
it.
• Each process can communicate directly with the abstract
I/O devices with all of its properties.
Layer 4 – User Programs
• The programs used by the user are operated in this layer, and
they don’t have to worry about I/O management,
operator/processes communication, memory management, or
the processor allocation.
Layer 5 – The Operator
• The system operator process is located in the outer most layer.
4. Microkernels system in an OS

• All the layers of the OS in a layered system went into the


kernel. So they all had root access to the OS, and any small
bug in any layer could be fatal to the OS.

• Famous examples of a microkernel system include Integrity,


K42, PikeOS, Symbian, and MINIX 3.

• The primary purpose of this system is to provide high


reliability.
4. Microkernels system in an OS
4. Microkernels system in an OS

Working

• The operating system is split into small, well-defined


modules, of which only one, the microkernel, runs in kernel
mode.
• The rest of the modules run as powerless ordinary user
processes.
• Running each device driver and file system as separate user
processes is a fail-safe method as a bug in one of the drivers,
will fail only that component.
• A bug easily references an invalid memory address and brings
the system to a grinding halt instantly.
4. Microkernels system in an OS

Advantages of Micro-kernel structure:

• It makes the operating system portable to various platforms.


• As microkernels are small so these can be tested effectively.

Disadvantages of Micro-kernel structure:

• Increased level of inter module communication degrades


system performance.
Differences between Microkernel and
Monolithic kernel
Differences between Microkernel and
Monolithic kernel
Terms Monolithic Kernel microkernel
Definition A monolithic kernel is a type of A microkernel is a kernel type
kernel in operating systems that provides low-level address
where the entire operating space management, thread
system works in the kernel management, and interprocess
space. communication to implement an
operating system.
Address space In a monolithic kernel, both user In microkernel user services and
services and kernel services are kernel, services are kept in
kept in the same address separate address spaces.
space.
Size The monolithic kernel is larger The microkernel is smaller in
than the microkernel. size.
Execution It has fast execution. It has slow execution.
OS services In a monolithic kernel system, In a microkernel-based system,
the kernel contains the OS the OS services and kernel are
services. separated.
Differences between Microkernel and
Monolithic kernel
Terms Monolithic Kernel microkernel
Extendible The monolithic kernel is quite The microkernel is easily
complicated to extend. extendible.
Security If a service crashes, then the If a service crashed, it does not
whole system crashes in a affect the working of the
monolithic kernel. microkernel.
Customization It is difficult to add new It is easier to add new
functionalities to the functionalities to the
monolithic kernel. Therefore, microkernel. Therefore, it is
it is not customizable. more customizable
Code Less coding is required to A microkernel is required more
write a monolithic kernel. coding.
Example Linux, FreeBSD, OpenBSD, QNX, Symbian, L4L.inux,
NetBSD, Microsoft Windows Singularity, K42, Mac OS X,
(95, 98, Me), Solaries, HP- Integrity, PikeOS, HURD, Minix,
UX, DOS, OpenVMS, XTS- and Coyotos.
400, etc.
LINUX

• Linux started out as a UNIX variant for the IBM PC (Intel


80386) architecture.

• Linux is free and the source code is available, it is a full-


featured UNIX system that runs on virtually all platforms.

• With the source code available, vendors can tweak


applications and utilities to meet specific requirements.

• Commercial companies such as Red Hat and Canonical provide


highly professional and reliable support for their Linux-based
distributions for long periods of time.
LINUX

Modular Structure
• Most UNIX kernels are monolithic i.e. it includes virtually all
of the OS functionality in one large block of code that runs as
a single process with a single address space.
• All the functional components of the kernel have access to all
of its internal data structures and routines.
• If changes are made to any portion of a typical monolithic OS,
all the modules and routines must be relinked and reinstalled,
and the system rebooted, before the changes can take effect.
• Hence, any modification, such as adding a new device driver
or file system function, is difficult.
• Linux is structured as a collection of modules, a number of
which can be automatically loaded and unloaded on demand
referred to as loadable modules.
LINUX

The Linux loadable modules have two important characteristics:

1. Dynamic linking:
• A kernel module can be loaded and linked into the kernel
while the kernel is already in memory and executing.
• A module can also be unlinked and removed from memory at
any time.

Dynamic linking facilitates configuration and saves kernel


memory.
LINUX

2. Stackable modules:
• The modules are arranged in a hierarchy.
• Individual modules serve as libraries when they are referenced
by client modules higher up in the hierarchy, and as clients
when they reference modules further down.
With stackable modules, dependencies between modules can
be defined. This has two benefits:
1. Code common to a set of similar modules (e.g., drivers for
similar hardware) can be moved into a single module,
reducing replication.
2. The kernel can make sure that needed modules are present,
refraining from unloading a module on which other running
modules depend, and loading any additional required modules
when a new module is loaded.
LAYERS IN LINUX SYSTEM
LAYERS IN LINUX SYSTEM

Linux machine as having 3 layers:

1. The hardware: The physical machine—the bottom or base of


the system, made up of memory (RAM) and the processor or
central processing unit (CPU), as well as input/output (I/O)
devices such as storage, networking, and graphics. The CPU
performs computations and reads from, and writes to, memory.

2. The Linux kernel: The core of the OS. It’s software residing in
memory that tells the CPU what to do. The kernel is responsible
for maintaining all the important abstractions of the operating
system, including such things as virtual memory and processes.
LAYERS IN LINUX SYSTEM

3. Users: All the users interacting with system.


4. System libraries: The system libraries define a standard set of
functions through which applications can interact with the
kernel. These functions implement much of the operating-
system functionality that does not need the full privileges of
kernel code.
5. System utilities. The system utilities are programs that
perform individual, specialized management tasks. Some system
utilities may be invoked just once to initialize and configure some
aspect of the system; others known as daemons in UNIX
terminology -may run permanently, handling such tasks as
responding to incoming network connections, accepting logon
requests from terminals, and updating log files.
Linux Kernel Structure
• The kernel directly interact with H/W and facilitates interactions
with I/O devices and the memory management unit and controls
access to them.
• Interrupt handlers are at lowest level and are the main means of
interacting with devices.
• At lowest level Low level dispatching mechanism is present. This
Dispatching takes Place on the occurrence of Interrupt.
• The running process is halted by low level code and saves process
state in the kernel process structures. It then starts the appropriate
driver.
• The dispatching of the process is also carried out after the Colonel
finishes some operations and it is turn to start up a user process
again.
• The code for dispatching is integrated in assembler and is rather
different from scheduling.
Linux Kernel Structure
Linux Kernel Structure

The kernel subsystem is divided into three main components,


I/O component, Memory management component and process
management component.

The I/O component:


• The IO component includes all kernel components which help
to interact with devices and carry out network and storage IO
operations.
• All the IO operations are integrated under a VFS (virtual file
system) layers as shown at highest level in figure. At the
lowest level, all IO operations pass through some device
driver.
Linux Kernel Structure

• Linux drivers are either character device drivers or block


device drivers.
• The seeks and random assets are permissible on block devices
but not on character devices. Network devices are in fact
character devices, but they are managed somewhat in a
different way.
• Above the device driver level, the kernel code is different
from each device type.
• The networking software is modular and have support for
different devices and protocols.
• The layer above the Network drivers handle the kind of
routing function, ensuring the right packet is delivered to the
right device or protocol handler.
Linux Kernel Structure
• I/O scheduler, which is situated on the top of the desk drivers
is order and a issue the desk -operation requests in a manner
that tries to preserve wasteful disk head movement or to
meet some other system Policy.
• File system is present on the top of lock devices column. Linux
can have multiple file systems coexisting concurrently.

Memory management component:


• This component carries out memory management tasks.
• Memory management tasks include maintaining the virtual to
physical memory mappings, maintaining a catch of recently
accessed pages, and implementing a good page- replacement
policy , and on demand, bringing in new pages of needed
code and data into memory.
Linux Kernel Structure

Process management component:

• Process management component carry out creation and


termination of processes.
• The procedures are present in this component chooses a
thread to be executed next.
• The processes and threads are treated as simply as executor
entities by Linux and global surgery link policy is used for
scheduling purpose.
• Finally code for single handling is also belongs to this
component.
SHELL

• A user interface is provided by program called Shell.


• Shell accept human readable commands from user and
convert them into something which kernel can understand.
• It is a command language interpreter that execute commands
read from input devices such as keyboards or from files.
• The shell gets started when the user logs in or start the
terminal.

Shell is broadly classified into two categories –


• Command Line Shell
• Graphical shell
SHELL
SHELL

Command Line Shell

• Shell can be accessed by user using a command line interface.


• A special program called Terminal in linux/macOS or
Command Prompt in Windows OS is provided to type in the
human readable commands such as “cat”, “ls” etc. and then it
is being execute.
• Shell read in from the terminal the typed command by user,
run these command, display the output of the commands.
• User can write programs using C shell, such programs are
called shell scripts.
• A shell script can be written by using any shell.
SHELL
SHELL

• In above screenshot “ls” command with “-l” option is


executed.
• It will list all the files in current working directory in long
listing format.
• Working with command line shell is bit difficult for the
beginners because it’s hard to memorize so many commands.
• It is very powerful, it allows user to store commands in a file
and execute them together.
• This way any repetitive task can be easily automated.
• These files are usually called batch files in Windows and Shell
Scripts in Linux/macOS systems.
SHELL

Graphical Shells

• Graphical shells provide means for manipulating programs


based on graphical user interface (GUI), by allowing for
operations such as opening, closing, moving and resizing
windows, as well as switching focus between windows.
• Window OS or Ubuntu OS can be considered as good example
which provide GUI to user for interacting with program.
• User do not need to type in command for every actions. A
typical GUI in Ubuntu system –
SHELL
SHELL

There are several shells are available for Linux systems like –

• BASH (Bourne Again SHell) – It is most widely used shell in


Linux systems. It is used as default login shell in Linux systems
and in macOS. It can also be installed on Windows OS.
• CSH (C SHell) – The C shell’s syntax and usage are very similar
to the C programming language.
• KSH (Korn SHell) – The Korn Shell also was the base for the
POSIX Shell standard specifications etc.
Each shell does the same job but understand different
commands and provide different built in functions.
SHELL

Shell Scripting
• Shells are interactive that mean, they accept command as
input from users and execute them.
• However some time we want to execute a bunch of
commands routinely, so we have type in all commands each
time in terminal.
• As shell can also take commands as input from file we can
write these commands in a file and can execute them in shell
to avoid this repetitive work.
• These files are called Shell Scripts or Shell Programs. Shell
scripts are similar to the batch file in MS-DOS.
• Each shell script is saved with .sh file extension eg.
myscript.sh
SHELL

Shell Scripting

A shell script comprises following elements –

• Shell Keywords – if, else, break etc.


• Shell commands – cd, ls, echo, pwd, touch etc.
• Functions
• Control flow – if..then..else, case and shell loops etc.
System Calls

• The mechanism used by an application program to request


service from the operating system.
System Calls
System Calls
System Calls
System Calls
Types of System Calls
Types of System Calls
Types of System Calls
Types of System Calls
Types of System Calls
Types of System Calls
Some Linux System Calls

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy