SlideShare une entreprise Scribd logo
1  sur  39
Kernel Mode Vs User Mode

01/08/14

Kernel Mode and User Mode

1
What is the Kernal?

01/08/14

2
What is the Kernal?
• The kernel is the "core" of any computer system.
• It is the "software" which allows users to share
computer resources.
• The kernel can be thought as the main software
of the OS (Operating System), which may also
include graphics management.

01/08/14

3
Contd.,
• For example, under Linux (like other Unix-like
OSs), the XWindow environment doesn't belong to
the Linux Kernel, because it manages only graphical
operations (it uses user mode I/O to access video
card devices).
• By contrast, Windows environments (Win9x,
WinME, WinNT, Win2K, WinXP, and so on) are a
mix between a graphical environment and kernel.
01/08/14

4
Contd.,
• Interacts with the hardware
• First program to get loaded when the system starts and runs till the
session gets terminated
• Different from BIOS which is hardware dependent.
• Kernel is software dependent
• LINUX: In hard disk, it is represented by the file /vmlinuz.

01/08/14

5
• Resource Management
• Xwindow- Graphical User Interface
• Sudo followed by command name – Super user do – file
extraction not allowed inside the file system.

01/08/14

6
01/08/14

7
01/08/14

8
Kernel types
• Monolithic
o All OS related code are stuffed in a single module
o Available as a single file
o Advantage : Faster functioning
• Micro
o OS components are isolated and run in their own address space
o Device drivers, programs and system services run outside kernel
memory space.Only a few functions such as process scheduling,
and interprocess communication are included into the
microkernel
o Supports modularity & Lesser in size
01/08/14

9
01/08/14

10
Kernel Mode(Privileged Mode)
• Kernel mode, also referred to as system mode.
• two distinct modes of operation of the CPU
(central processing unit) in Linux
o Kernal mode and user mode.
User mode -non-privileged mode for user

programs.
Kernel Mode - Mainly for Restriction/
Protection from unauthorized user application
01/08/14

11
• When the CPU is in kernel mode, it is assumed to be executing
trusted software, and thus it can execute any instructions and
reference any memory addresses (i.e., locations in memory).
• all other programs(user applications) are considered untrusted
software.
• Thus, all user mode software must request use of the kernel by
means of a system callin order to perform privileged
instructions, such as process creation or input/output
operations.

01/08/14

12
• A good example of this would be device drivers.
• A device driver must tell the kernel exactly how to
interact with a piece of hardware, so it must be run in
kernel mode.
• Because of this close interaction with the kernel, the
kernel is also a lot more vulnerable to programs
running in this mode, so it becomes highly crucial
that drivers are properly debugged before being
released to the public.
01/08/14

13
System Call
•

A system call is a request to the kernel in a Unix operating system by
an active process for a service performed by the kernel.

• A process is an executing instance of a program. An active process is
a process that is currently advancing in the CPU (while other
processes are waiting in memory for their turns to use the CPU).
• Input/output (I/O) is any program, operation or device that transfers
data to or from the CPU and to or from a peripheral device (such as
disk drives, keyboards, mice and printers).

01/08/14

14
USER MODE
•

It is a non-privileged mode in which each process (i.e., a running instance of
a program) starts out.

•

It is non-privileged in that it is forbidden for processes in this mode to access
those portions of memory (i.e., RAM) that have been allocated to the kernel
or to other programs.

•

When a user mode process (i.e., a process currently in user mode) wants to
use a service that is provided by the kernel (i.e., access system resources
other than the limited memory space that is allocated to the user program), it
must switch temporarily into kernel mode, which has root (i.e.,
administrative) privileges, including root access permissions (i.e.,
permission to access any memory space or other resources on the system).
When the kernel has satisfied the process's request, it restores the process to
user mode.

•

The standard procedure to switch from user mode to kernel mode is to call
01/08/14
15
the 0x80 software interrupt.
USER MODE(non –privileged Mode)
• User mode is the normal mode of operating for programs. Web
browsers, calculators, etc. will all be in user mode.
• They don't interact directly with the kernel, instead, they just give
instructions on what needs to be done, and the kernel takes care of the
rest.
• Code running in user mode must delegate to system APIs to access
hardware or memory.
• Due to the protection afforded by this sort of isolation, crashes in user
mode are always recoverable.
• Most of the code running on your computer will execute in user mode.
• When in User Mode, some parts of RAM cannot be addressed, some
instructions can’t be executed, and I/O ports can’t be accessed
01/08/14
01/08/14

UNIT-I

16

16
What is the difference between User Mode and
Kernel Mode
Overview
 when computers were as big as a room, users ran their
applications with much difficulty and, sometimes, their
applications crashed the computer.
Operative modes
To avoid having applications that constantly crashed, newer
OSs were designed with 2 different operative modes:
Kernel Mode: the machine operates with critical data
structure, direct hardware (IN/OUT or memory
mapped), direct memory, IRQ, DMA, and so on.
User Mode: users can run applications.

01/08/14

17
Switching from User Mode to Kernel Mode
When do we switch?
Once we understand that there are 2 different modes, we
have to know when we switch from one to the other.
Typically, there are 2 points of switching:
 When calling a System Call: after calling a System Call,
the task voluntary calls pieces of code living in Kernel
Mode
 When an IRQ (or exception) comes: after the IRQ an IRQ
handler (or exception handler) is called, then control
returns back to the task that was interrupted like nothing
was happened.
01/08/14

18
SWITCHING FROM USER MODE TO KERNEL MODE
•

The only way an user space application can explicitly initiate a switch to kernel
mode during normal operation is by making an system call such as open,
read, write etc.

•

Whenever a user application calls these system call APIs with appropriate
parameters, a software interrupt/exception(SWI) is triggered.

•

As a result of this SWI, the control of the code execution jumps from the
user application to a predefined location in the Interrupt Vector
Table [IVT] provided by the OS.

•

This IVT contains an address for the SWI exception handler routine,
which performs all the necessary steps required to switch the user application to
kernel mode and start executing kernel instructions on behalf of user process.

01/08/14
01/08/14

UNIT-I

19

19
Switch User Mode to Kernel Mode

Kernel Mode

01/08/14

IVT do the
necessary
steps

20
Interrupt
• An interrupt is a signal to the operating system that an
event has occurred, and it results in changes in the
sequence of instructions that is executed by the CPU. In
the case of a hardware interrupt, the signal originates
from a hardware device such as a keyboard (e.g., when a
user presses a key), mouse or system clock (a circuit that
generates pulses at precise intervals that are used to
coordinate

the

computer's

activities).

A

software

interrupt is an interrupt that originates in software,
usually by a program in user mode.
01/08/14

21
Contd.,

USER Mode

Implementation

Kernel Mode

Computer Hardware

01/08/14

22
Kernel Mode "prevents" User Mode applications from
damaging the system or its features.
Modern microprocessors implement in hardware at least 2
different states. For example under Intel, 4 states
determine the PL (Privilege Level). It is possible to use
0,1,2,3 states, with 0 used in Kernel Mode.
Unix OS requires only 2 privilege levels, and we will use
such a paradigm as point of reference.

01/08/14

23
System Calls
System calls are like special functions that manage OS
routines which live in Kernel Mode.
A system call can be called when we:
access an I/O device or a file (like read or write)
need to access privileged information (like pid(process
identifier, changing scheduling policy or other
information)
need to change execution context (like forking or executing
some other application)
need to execute a particular command (like ''chdir'', ''kill",
''brk'', or ''signal'')
01/08/14

24
Shell
Program that interacts with kernel
Bridge between kernel and the user
Command interpreter
User can type command and the command is conveyed
to the kernel and it will be executed

25 01/08/14
Types of Shell
Sh – simple shell
BASH – Bourne Again Shell
KSH – Korne Shell
CSH – C Shell
SSH – Secure Shell
To use a particular shell type the shell name at the command prompt.
Eg $csh – will switch the current shell to c shell
To view the current shell that is being used, type echo $SHELL at the command
prompt

26 01/08/14
01/08/14

27
01/08/14

28
01/08/14

29
01/08/14

30
01/08/14

31
01/08/14

32
01/08/14

33
01/08/14

34
01/08/14

35
01/08/14

36
01/08/14

37
01/08/14

38
01/08/14

39

Contenu connexe

Tendances

Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"Ra'Fat Al-Msie'deen
 
OS Components and Structure
OS Components and StructureOS Components and Structure
OS Components and Structuresathish sak
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structuresMukesh Chinta
 
Operating Systems
Operating SystemsOperating Systems
Operating Systemsvampugani
 
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESOPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESpriyasoundar
 
Presentation on Operating System & its Components
Presentation on Operating System & its ComponentsPresentation on Operating System & its Components
Presentation on Operating System & its ComponentsMahmuda Rahman
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory managementrprajat007
 
6 multiprogramming & time sharing
6 multiprogramming & time sharing6 multiprogramming & time sharing
6 multiprogramming & time sharingmyrajendra
 
Protection and Security in Operating Systems
Protection and Security in Operating SystemsProtection and Security in Operating Systems
Protection and Security in Operating Systemsvampugani
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9myrajendra
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating SystemsMukesh Chinta
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-SystemsVenkata Sreeram
 

Tendances (20)

Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
OS Components and Structure
OS Components and StructureOS Components and Structure
OS Components and Structure
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structures
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESOPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Presentation on Operating System & its Components
Presentation on Operating System & its ComponentsPresentation on Operating System & its Components
Presentation on Operating System & its Components
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
6 multiprogramming & time sharing
6 multiprogramming & time sharing6 multiprogramming & time sharing
6 multiprogramming & time sharing
 
Protection and Security in Operating Systems
Protection and Security in Operating SystemsProtection and Security in Operating Systems
Protection and Security in Operating Systems
 
kernels
 kernels kernels
kernels
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Memory management
Memory managementMemory management
Memory management
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Kernel (OS)
Kernel (OS)Kernel (OS)
Kernel (OS)
 

Similaire à Kernel Mode vs User Mode: Understanding Privileged vs Non-Privileged CPU Operation

lecture 1 (Part 2) kernal and its categories
lecture 1 (Part 2) kernal and its categorieslecture 1 (Part 2) kernal and its categories
lecture 1 (Part 2) kernal and its categoriesWajeehaBaig
 
Chapter 8. Kernel-Mode RootKitsIts now time to take the box
Chapter 8. Kernel-Mode RootKitsIts now time to take the boxChapter 8. Kernel-Mode RootKitsIts now time to take the box
Chapter 8. Kernel-Mode RootKitsIts now time to take the boxJinElias52
 
Lecture1,2,3 (1).pdf
Lecture1,2,3 (1).pdfLecture1,2,3 (1).pdf
Lecture1,2,3 (1).pdfTaufeeq8
 
chapter 1 introduction to operating system
chapter 1 introduction to operating systemchapter 1 introduction to operating system
chapter 1 introduction to operating systemAisyah Rafiuddin
 
OPERATING SYSTEM - SHORT NOTES
OPERATING SYSTEM - SHORT NOTESOPERATING SYSTEM - SHORT NOTES
OPERATING SYSTEM - SHORT NOTESsuthi
 
Module 1 Introduction.ppt
Module 1 Introduction.pptModule 1 Introduction.ppt
Module 1 Introduction.pptshreesha16
 
Operating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdfOperating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdfFahanaAbdulVahab
 
Course 101: Lecture 2: Introduction to Operating Systems
Course 101: Lecture 2: Introduction to Operating Systems Course 101: Lecture 2: Introduction to Operating Systems
Course 101: Lecture 2: Introduction to Operating Systems Ahmed El-Arabawy
 
Kernel | Operating System
Kernel | Operating SystemKernel | Operating System
Kernel | Operating SystemSumit Pandey
 
Operating system module
Operating system moduleOperating system module
Operating system modulekiamiel
 
Engg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfEngg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfnikhil287188
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecturejeetesh036
 
Real-Time Embedded System Design
Real-Time Embedded System DesignReal-Time Embedded System Design
Real-Time Embedded System DesignJuliaAndrews11
 
Operating System Concepts Presentation
Operating System Concepts PresentationOperating System Concepts Presentation
Operating System Concepts PresentationNitish Jadia
 
Embedded Operating System-Kernel Features.pptx
Embedded Operating System-Kernel Features.pptxEmbedded Operating System-Kernel Features.pptx
Embedded Operating System-Kernel Features.pptxssuseradc877
 
Operating System / System Operasi
Operating System / System Operasi                   Operating System / System Operasi
Operating System / System Operasi seolangit4
 

Similaire à Kernel Mode vs User Mode: Understanding Privileged vs Non-Privileged CPU Operation (20)

lecture 1 (Part 2) kernal and its categories
lecture 1 (Part 2) kernal and its categorieslecture 1 (Part 2) kernal and its categories
lecture 1 (Part 2) kernal and its categories
 
Operating System concepts
Operating System conceptsOperating System concepts
Operating System concepts
 
Chapter 8. Kernel-Mode RootKitsIts now time to take the box
Chapter 8. Kernel-Mode RootKitsIts now time to take the boxChapter 8. Kernel-Mode RootKitsIts now time to take the box
Chapter 8. Kernel-Mode RootKitsIts now time to take the box
 
1_to_10.pdf
1_to_10.pdf1_to_10.pdf
1_to_10.pdf
 
Lecture1,2,3 (1).pdf
Lecture1,2,3 (1).pdfLecture1,2,3 (1).pdf
Lecture1,2,3 (1).pdf
 
chapter 1 introduction to operating system
chapter 1 introduction to operating systemchapter 1 introduction to operating system
chapter 1 introduction to operating system
 
OPERATING SYSTEM - SHORT NOTES
OPERATING SYSTEM - SHORT NOTESOPERATING SYSTEM - SHORT NOTES
OPERATING SYSTEM - SHORT NOTES
 
OS Content.pdf
OS Content.pdfOS Content.pdf
OS Content.pdf
 
Device Drivers
Device DriversDevice Drivers
Device Drivers
 
Module 1 Introduction.ppt
Module 1 Introduction.pptModule 1 Introduction.ppt
Module 1 Introduction.ppt
 
Operating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdfOperating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdf
 
Course 101: Lecture 2: Introduction to Operating Systems
Course 101: Lecture 2: Introduction to Operating Systems Course 101: Lecture 2: Introduction to Operating Systems
Course 101: Lecture 2: Introduction to Operating Systems
 
Kernel | Operating System
Kernel | Operating SystemKernel | Operating System
Kernel | Operating System
 
Operating system module
Operating system moduleOperating system module
Operating system module
 
Engg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfEngg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdf
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecture
 
Real-Time Embedded System Design
Real-Time Embedded System DesignReal-Time Embedded System Design
Real-Time Embedded System Design
 
Operating System Concepts Presentation
Operating System Concepts PresentationOperating System Concepts Presentation
Operating System Concepts Presentation
 
Embedded Operating System-Kernel Features.pptx
Embedded Operating System-Kernel Features.pptxEmbedded Operating System-Kernel Features.pptx
Embedded Operating System-Kernel Features.pptx
 
Operating System / System Operasi
Operating System / System Operasi                   Operating System / System Operasi
Operating System / System Operasi
 

Plus de Siddique Ibrahim (20)

List in Python
List in PythonList in Python
List in Python
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
 
Python programming introduction
Python programming introductionPython programming introduction
Python programming introduction
 
Data mining basic fundamentals
Data mining basic fundamentalsData mining basic fundamentals
Data mining basic fundamentals
 
Basic networking
Basic networkingBasic networking
Basic networking
 
Virtualization Concepts
Virtualization ConceptsVirtualization Concepts
Virtualization Concepts
 
Networking devices(siddique)
Networking devices(siddique)Networking devices(siddique)
Networking devices(siddique)
 
Osi model 7 Layers
Osi model 7 LayersOsi model 7 Layers
Osi model 7 Layers
 
Mysql grand
Mysql grandMysql grand
Mysql grand
 
Getting started into mySQL
Getting started into mySQLGetting started into mySQL
Getting started into mySQL
 
pipelining
pipeliningpipelining
pipelining
 
Micro programmed control
Micro programmed controlMicro programmed control
Micro programmed control
 
Hardwired control
Hardwired controlHardwired control
Hardwired control
 
interface
interfaceinterface
interface
 
Interrupt
InterruptInterrupt
Interrupt
 
Interrupt
InterruptInterrupt
Interrupt
 
DMA
DMADMA
DMA
 
Io devies
Io deviesIo devies
Io devies
 
Stack & queue
Stack & queueStack & queue
Stack & queue
 
Metadata in data warehouse
Metadata in data warehouseMetadata in data warehouse
Metadata in data warehouse
 

Dernier

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Dernier (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Kernel Mode vs User Mode: Understanding Privileged vs Non-Privileged CPU Operation

  • 1. Kernel Mode Vs User Mode 01/08/14 Kernel Mode and User Mode 1
  • 2. What is the Kernal? 01/08/14 2
  • 3. What is the Kernal? • The kernel is the "core" of any computer system. • It is the "software" which allows users to share computer resources. • The kernel can be thought as the main software of the OS (Operating System), which may also include graphics management. 01/08/14 3
  • 4. Contd., • For example, under Linux (like other Unix-like OSs), the XWindow environment doesn't belong to the Linux Kernel, because it manages only graphical operations (it uses user mode I/O to access video card devices). • By contrast, Windows environments (Win9x, WinME, WinNT, Win2K, WinXP, and so on) are a mix between a graphical environment and kernel. 01/08/14 4
  • 5. Contd., • Interacts with the hardware • First program to get loaded when the system starts and runs till the session gets terminated • Different from BIOS which is hardware dependent. • Kernel is software dependent • LINUX: In hard disk, it is represented by the file /vmlinuz. 01/08/14 5
  • 6. • Resource Management • Xwindow- Graphical User Interface • Sudo followed by command name – Super user do – file extraction not allowed inside the file system. 01/08/14 6
  • 9. Kernel types • Monolithic o All OS related code are stuffed in a single module o Available as a single file o Advantage : Faster functioning • Micro o OS components are isolated and run in their own address space o Device drivers, programs and system services run outside kernel memory space.Only a few functions such as process scheduling, and interprocess communication are included into the microkernel o Supports modularity & Lesser in size 01/08/14 9
  • 11. Kernel Mode(Privileged Mode) • Kernel mode, also referred to as system mode. • two distinct modes of operation of the CPU (central processing unit) in Linux o Kernal mode and user mode. User mode -non-privileged mode for user programs. Kernel Mode - Mainly for Restriction/ Protection from unauthorized user application 01/08/14 11
  • 12. • When the CPU is in kernel mode, it is assumed to be executing trusted software, and thus it can execute any instructions and reference any memory addresses (i.e., locations in memory). • all other programs(user applications) are considered untrusted software. • Thus, all user mode software must request use of the kernel by means of a system callin order to perform privileged instructions, such as process creation or input/output operations. 01/08/14 12
  • 13. • A good example of this would be device drivers. • A device driver must tell the kernel exactly how to interact with a piece of hardware, so it must be run in kernel mode. • Because of this close interaction with the kernel, the kernel is also a lot more vulnerable to programs running in this mode, so it becomes highly crucial that drivers are properly debugged before being released to the public. 01/08/14 13
  • 14. System Call • A system call is a request to the kernel in a Unix operating system by an active process for a service performed by the kernel. • A process is an executing instance of a program. An active process is a process that is currently advancing in the CPU (while other processes are waiting in memory for their turns to use the CPU). • Input/output (I/O) is any program, operation or device that transfers data to or from the CPU and to or from a peripheral device (such as disk drives, keyboards, mice and printers). 01/08/14 14
  • 15. USER MODE • It is a non-privileged mode in which each process (i.e., a running instance of a program) starts out. • It is non-privileged in that it is forbidden for processes in this mode to access those portions of memory (i.e., RAM) that have been allocated to the kernel or to other programs. • When a user mode process (i.e., a process currently in user mode) wants to use a service that is provided by the kernel (i.e., access system resources other than the limited memory space that is allocated to the user program), it must switch temporarily into kernel mode, which has root (i.e., administrative) privileges, including root access permissions (i.e., permission to access any memory space or other resources on the system). When the kernel has satisfied the process's request, it restores the process to user mode. • The standard procedure to switch from user mode to kernel mode is to call 01/08/14 15 the 0x80 software interrupt.
  • 16. USER MODE(non –privileged Mode) • User mode is the normal mode of operating for programs. Web browsers, calculators, etc. will all be in user mode. • They don't interact directly with the kernel, instead, they just give instructions on what needs to be done, and the kernel takes care of the rest. • Code running in user mode must delegate to system APIs to access hardware or memory. • Due to the protection afforded by this sort of isolation, crashes in user mode are always recoverable. • Most of the code running on your computer will execute in user mode. • When in User Mode, some parts of RAM cannot be addressed, some instructions can’t be executed, and I/O ports can’t be accessed 01/08/14 01/08/14 UNIT-I 16 16
  • 17. What is the difference between User Mode and Kernel Mode Overview  when computers were as big as a room, users ran their applications with much difficulty and, sometimes, their applications crashed the computer. Operative modes To avoid having applications that constantly crashed, newer OSs were designed with 2 different operative modes: Kernel Mode: the machine operates with critical data structure, direct hardware (IN/OUT or memory mapped), direct memory, IRQ, DMA, and so on. User Mode: users can run applications. 01/08/14 17
  • 18. Switching from User Mode to Kernel Mode When do we switch? Once we understand that there are 2 different modes, we have to know when we switch from one to the other. Typically, there are 2 points of switching:  When calling a System Call: after calling a System Call, the task voluntary calls pieces of code living in Kernel Mode  When an IRQ (or exception) comes: after the IRQ an IRQ handler (or exception handler) is called, then control returns back to the task that was interrupted like nothing was happened. 01/08/14 18
  • 19. SWITCHING FROM USER MODE TO KERNEL MODE • The only way an user space application can explicitly initiate a switch to kernel mode during normal operation is by making an system call such as open, read, write etc. • Whenever a user application calls these system call APIs with appropriate parameters, a software interrupt/exception(SWI) is triggered. • As a result of this SWI, the control of the code execution jumps from the user application to a predefined location in the Interrupt Vector Table [IVT] provided by the OS. • This IVT contains an address for the SWI exception handler routine, which performs all the necessary steps required to switch the user application to kernel mode and start executing kernel instructions on behalf of user process. 01/08/14 01/08/14 UNIT-I 19 19
  • 20. Switch User Mode to Kernel Mode Kernel Mode 01/08/14 IVT do the necessary steps 20
  • 21. Interrupt • An interrupt is a signal to the operating system that an event has occurred, and it results in changes in the sequence of instructions that is executed by the CPU. In the case of a hardware interrupt, the signal originates from a hardware device such as a keyboard (e.g., when a user presses a key), mouse or system clock (a circuit that generates pulses at precise intervals that are used to coordinate the computer's activities). A software interrupt is an interrupt that originates in software, usually by a program in user mode. 01/08/14 21
  • 23. Kernel Mode "prevents" User Mode applications from damaging the system or its features. Modern microprocessors implement in hardware at least 2 different states. For example under Intel, 4 states determine the PL (Privilege Level). It is possible to use 0,1,2,3 states, with 0 used in Kernel Mode. Unix OS requires only 2 privilege levels, and we will use such a paradigm as point of reference. 01/08/14 23
  • 24. System Calls System calls are like special functions that manage OS routines which live in Kernel Mode. A system call can be called when we: access an I/O device or a file (like read or write) need to access privileged information (like pid(process identifier, changing scheduling policy or other information) need to change execution context (like forking or executing some other application) need to execute a particular command (like ''chdir'', ''kill", ''brk'', or ''signal'') 01/08/14 24
  • 25. Shell Program that interacts with kernel Bridge between kernel and the user Command interpreter User can type command and the command is conveyed to the kernel and it will be executed 25 01/08/14
  • 26. Types of Shell Sh – simple shell BASH – Bourne Again Shell KSH – Korne Shell CSH – C Shell SSH – Secure Shell To use a particular shell type the shell name at the command prompt. Eg $csh – will switch the current shell to c shell To view the current shell that is being used, type echo $SHELL at the command prompt 26 01/08/14

Notes de l'éditeur

  1. This template can be used as a starter file to give updates for project milestones. Sections Right-click on a slide to add sections. Sections can help to organize your slides or facilitate collaboration between multiple authors. Notes Use the Notes section for delivery notes or to provide additional details for the audience. View these notes in Presentation View during your presentation. Keep in mind the font size (important for accessibility, visibility, videotaping, and online production) Coordinated colors Pay particular attention to the graphs, charts, and text boxes. Consider that attendees will print in black and white or grayscale. Run a test print to make sure your colors work when printed in pure black and white and grayscale. Graphics, tables, and graphs Keep it simple: If possible, use consistent, non-distracting styles and colors. Label all graphs and tables.