SlideShare a Scribd company logo
1 of 35
Operating System Basics
CS 537 - Introduction to Operating Systems
Definition
• An operating system is an intermediary
between a computer user and the hardware.
• Make the hardware convenient to use.
• Manages system resources.
• Use the hardware in an efficient manner.
System Diagram
system and application programs
operating system
hardware
user
1
user
2
user
n
. . .
compiler text editor ls
Types of Systems
• Batch
– submit large number of jobs at one time
– system decides what to run and when
• Time Sharing
– multiple users connected to single machine
– few processors, many terminals
• Single User Interactive
– one user, one machine
– traditional personal computer
Types of Systems
• Parrallel
– traditional multiprocessor system
– higher throughput and better fault tolerance
• Distributed
– networked computers
• Real Time
– very strict response time requirements
– hardware or software
Single Tasking System
• Only one program can perform at a time
• Simple to implement
– only one process attempting to use resources
• Few security risks
• Poor utilization of the CPU and other
resources
• Example: MS-DOS
Multitasking System
• Very complex
• Serious security issues
– how to protect one program from another
sharing the same memory
• Much higher utilization of system resources
• Example: Unix, Windows NT
Hardware Basics
• OS and hardware closely tied together
• Many useful hardware features have been
invented to compliment the OS
• Basic hardware resources
– CPU
– Memory
– Disk
– I/O
CPU
• CPU controls everything in the system
– if work needs to be done, CPU gets involved
• Most precious resource
– this is what your paying for
– want to get high utilization (from useful work)
• Only one process on a CPU at a time
• Hundreds of millions of instructions / sec
– and getting faster all the time
Memory
• Limitted in capacity
– never enough memory
• Temporary (volatile) storage
• Electronic storage
– fast, random access
• Any program to run on the CPU must be in
memory
Disk
• Virtually infinite capacity
• Permanent storage
• Orders of magnitude slower than memory
– mechanical device
– millions of CPU instructions can execute in the
time it takes to access a single piece of data on
disk
• All data is accessed in blocks
– usually 512 bytes
I/O
• Disk is actually part of the I/O subsystem
– they are of special interest to the OS
• Many other I/O devices
– printers, monitor, keyboard, etc.
• Most I/O devices are painfully slow
• Need to find ways to hide I/O latency
– like multiprogramming
Protection and Security
• OS must protect itself from users
– reserved memory only accessible by OS
– hardware enforced
• OS may protect users from one another
– not all systems do this
– hardware enforced again
Protection and Security
• Dual -Mode Operation
– user mode
• limited set of hardware instr and memory available
• mode all user programs run in
– supervisory mode
• all hardware instr and memory are available
• mode the OS runs in
• Never let user run in supervisory mode
Interrupts
• Modern OS’s are event driven
• Event is signaled by special hardware signal sent
to the CPU
• Two types of events
– interrupts
• caused by external devices or timers
• can occur at any moment in time
– exceptions (traps)
• caused by software
– the generic term for both is Interrupt
• sorry for the confusion
Interrupt Philosophy
• One way to handle interrupts is with one
standard program
– big case-switch statement that gets executed on
any interrupt
– inefficient
• Second alternative is to use an interrupt
table and special hardware
– this is the way modern systems operate
Interrupt Table
• Large array indicating what code to run for
a given interrupt
• Each interrupt has a corresponding number
associated with it
– on Intel processors this is from 0 to 255
– this gives fixed size interrupt table
• Use the interrupt number to index into the
array to find out what code to run
Interrupt Hardware
• Programmable Interrupt Controller (PIC)
– connected to I/O devices via interrupt request lines
(IRQ)
• ideally, one IRQ for each I/O device - doesn’t work this way
in reality
• PIC connected to CPU by a special signal
• PIC also connected to CPU via I/O bus
• Besides the PIC, interrupts can also be generated
by software instructions or errors
– again, these are usually referred to as exceptions
Interrupt Hardware
I/O Bus
CPU
P
I
C
I/O
I/O
INTR
The above is a conceptual view of the hardware - not the
exact way things are really connected
Hardware Handling of Interrupts
• After each instruction executes, CPU checks to see if
interrupt pin has been raised
• If so, the following occurs:
1) sets the system into kernel mode (if not already there)
2) determine interrupt number (from PIC or instruction)
3) read appropriate interrupt table entry
- special register contains base address of interrupt table
- each entry in table is fixed size so easy to calculate where
to look in memory ( memLoc = idtr + 8 * intNum )
4) saves the program counter to the stack (with a couple of others)
5) saves error code to stack (if it exists)
6) loads the program counter with the value stored in the interrupt
table
- this starts the CPU executing the interrupt routine
Hardware Handling of Interrupts
• After the interrupt code finishes:
1) interrupt handler issues an iret instruction
2) reload the program counter from the stack
3) reload stack pointer with old process
4) set the system back to user mode
• Steps 3 & 4 may not be executed if the
system was running in kernel mode when
the interrupt occurred
– nested exceptions
Software Handling of Interrupts
• The following 6 steps are common to all interrupt
handlers:
1) save IRQ to kernel mode stack
2) save registers to kernel mode stack
3) send acknowledgement to PIC
- this allows PIC to then handle other interrupts on IRQ line
4) execute the appropriate handler code
5) restore registers
6) issue an iret instruction
• The steps for exception handlers are almost identical
– simply remove steps 1 & 3 above
More on Exceptions
• As indicated earlier, exceptions are caused by software
– divide by zero error
– page fault
– int instruction
– etc
• Some of these cause the program to stop executing
• Some of them invoke special operating system code that is
invisible to the user
• Some of them invoke operating system code at the user’s
request
– system calls
Single IRQ for Multiple Devices
• The number of IRQ lines is usually limited
• May have more I/O devices than IRQ’s
• Solution: let multiple devices share an IRQ
• Interrupt table contains a pointer to a linked list of
interrupt handlers
– instead of the address of the interrupt handler
• On interrupt, execute all of the handlers associated
with an IRQ
– requires handlers to recognize if interrupt is
really for them
Example
Interrupt Table
0
1
2
3
4
5
6
7
8
9
floppy disk
printer scanner camera
hard disk
Example
• Assume an interrupt from the scanner arrives at the PIC
1) PIC raises INTR signal on CPU
2) CPU reads PIC over I/O bus to determine IRQ
3) CPU then accesses array in memory to get the first interrupt
handler
- printer
4) CPU executes printer handler code
5) printer handler queries printer and notices there is no interrupt
pending
- handler returns immediately
6) next the scanner handler gets executed
7) scanner handler queries scanner and notices there is an interrupt
pending
- proceeds to handle the interrupt
- then returns
System Calls
• An OS’s system calls are called the
Application Programmers Interface (API)
• System calls are routines run by the OS on
behalf of the user
• They are run in supervisory mode
• Allow user to access I/O, create processes,
get system information, etc.
• How many system calls an OS has varies
– Unix: around a hundred
– Windows: around a thousand
System Startup
• On power up
– everything in system is in random, unpredictable state
– special hardware circuit raises RESET pin of CPU
• sets the program counter to 0xfffffff0
– this address is mapped to ROM (Read-Only Memory)
• BIOS (Basic Input/Output Stream)
– set of programs stored in ROM
– some OS’s use only these programs
• MS DOS
– many modern systems use these programs to load other system
programs
• Windows, Unix, Linux
BIOS
• General operations performed by BIOS
1) find and test hardware devices
- POST (Power-On Self-Test)
2) initialize hardware devices
- creates a table of installed devices
3) find boot sector
- may be on floppy, hard drive, or CD-ROM
4) load boot sector into memory location 0x00007c00
5) sets the program counter to 0x00007c00
- starts executing code at that address
Boot Loader
• Small program stored in boot sector
• Loaded by BIOS at location 0x00007c0
• Configure a basic file system to allow
system to read from disk
• Loads kernel into memory
• Also loads another program that will begin
kernel initialization
Initial Kernel Program
• Determines amount of RAM in system
– uses a BIOS function to do this
• Configures hardware devices
– video card, mouse, disks, etc.
– BIOS may have done this but usually redo it
• portability
• Switches the CPU from real to protected mode
– real mode: fixed segment sizes, 1 MB memory addressing, and no
segment protection
– protected mode: variable segment sizes, 4 GB memory
addressing, and provides segment protection
• Initializes paging (virtual memory)
Final Kernel Initialization
• Sets up page tables and segment descriptor tables
– these are used by virtual memory and segmentation
hardware (more on this later)
• Sets up interrupt vector and enables interrupts
• Initializes all other kernel data structures
• Creates initial process and starts it running
– init in Linux
– smss (Session Manager SubSystem) in NT
OS Philosophy
• Microkernel versus Macrokernel
– few services versus lots of services
• Hard to agree on what should go in OS
• More functionality, less generality
• More services, more complexity, more bugs
– longer time to market, too
• But macrokernels dominate the market
– Unix, Linux, Windows, Mac
OS Philosophy
few services many services
mach Windows
Mac
Unix
System Programs
• Application programs included with the OS
• Highly trusted programs
• Perform useful work that most users need
– listing and deleting files, configuring system
– ls, rm, Windows Explorer and Control Panel
– may include compilers and text editors
• Not part of the OS
– run in user space
• Very useful

More Related Content

What's hot

Operating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputOperating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputPeter Tröger
 
computer system structure
computer system structurecomputer system structure
computer system structureHAMZA AHMED
 
operating system structure
operating system structureoperating system structure
operating system structureHAMZA AHMED
 
The central processing unit by group 5 2015
The central processing unit by group 5 2015The central processing unit by group 5 2015
The central processing unit by group 5 2015Tendai Karuma
 
Ch2 OS
Ch2 OSCh2 OS
Ch2 OSC.U
 
Computer architecture presentation
Computer architecture presentationComputer architecture presentation
Computer architecture presentationMuhammad Hamza
 
Three Central Processing Unit
Three   Central Processing UnitThree   Central Processing Unit
Three Central Processing UnitMISY
 
ICTCoreCh11
ICTCoreCh11ICTCoreCh11
ICTCoreCh11garcons0
 
AN INTRODUCTION TO OPERATING SYSTEMS : CONCEPTS AND PRACTICE - PHI Learning
AN INTRODUCTION TO OPERATING SYSTEMS : CONCEPTS AND PRACTICE - PHI LearningAN INTRODUCTION TO OPERATING SYSTEMS : CONCEPTS AND PRACTICE - PHI Learning
AN INTRODUCTION TO OPERATING SYSTEMS : CONCEPTS AND PRACTICE - PHI LearningPHI Learning Pvt. Ltd.
 
Unit 2 ca- control unit
Unit 2 ca- control unitUnit 2 ca- control unit
Unit 2 ca- control unitBBDITM LUCKNOW
 

What's hot (20)

E.s unit 4 and 5
E.s unit 4 and 5E.s unit 4 and 5
E.s unit 4 and 5
 
Operating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / OutputOperating Systems 1 (11/12) - Input / Output
Operating Systems 1 (11/12) - Input / Output
 
Interrupts
InterruptsInterrupts
Interrupts
 
computer system structure
computer system structurecomputer system structure
computer system structure
 
Embedded System-design technology
Embedded System-design technologyEmbedded System-design technology
Embedded System-design technology
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Ch2
Ch2Ch2
Ch2
 
The central processing unit by group 5 2015
The central processing unit by group 5 2015The central processing unit by group 5 2015
The central processing unit by group 5 2015
 
OS_Ch2
OS_Ch2OS_Ch2
OS_Ch2
 
Ch2 OS
Ch2 OSCh2 OS
Ch2 OS
 
Computer architecture presentation
Computer architecture presentationComputer architecture presentation
Computer architecture presentation
 
Day1
Day1Day1
Day1
 
Three Central Processing Unit
Three   Central Processing UnitThree   Central Processing Unit
Three Central Processing Unit
 
Slides of cpu
Slides of cpuSlides of cpu
Slides of cpu
 
Process management1
Process management1Process management1
Process management1
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded Systems
 
ICTCoreCh11
ICTCoreCh11ICTCoreCh11
ICTCoreCh11
 
AN INTRODUCTION TO OPERATING SYSTEMS : CONCEPTS AND PRACTICE - PHI Learning
AN INTRODUCTION TO OPERATING SYSTEMS : CONCEPTS AND PRACTICE - PHI LearningAN INTRODUCTION TO OPERATING SYSTEMS : CONCEPTS AND PRACTICE - PHI Learning
AN INTRODUCTION TO OPERATING SYSTEMS : CONCEPTS AND PRACTICE - PHI Learning
 
Cpu
CpuCpu
Cpu
 
Unit 2 ca- control unit
Unit 2 ca- control unitUnit 2 ca- control unit
Unit 2 ca- control unit
 

Similar to Os introduction

MK Sistem Operasi.pdf
MK Sistem Operasi.pdfMK Sistem Operasi.pdf
MK Sistem Operasi.pdfwisard1
 
Operating System BCA 301
Operating System BCA 301Operating System BCA 301
Operating System BCA 301cpjcollege
 
Computer Architecture & Organization.ppt
Computer Architecture & Organization.pptComputer Architecture & Organization.ppt
Computer Architecture & Organization.pptFarhanaMariyam1
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecturejeetesh036
 
Kernel security Concepts
Kernel security ConceptsKernel security Concepts
Kernel security ConceptsMohit Saxena
 
Introduction to Operating Systems.pdf
Introduction to Operating Systems.pdfIntroduction to Operating Systems.pdf
Introduction to Operating Systems.pdfHarika Pudugosula
 
Module 1 Introduction.ppt
Module 1 Introduction.pptModule 1 Introduction.ppt
Module 1 Introduction.pptshreesha16
 
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
 
CSE3120- Module1 part 1 v1.pptx
CSE3120- Module1 part 1 v1.pptxCSE3120- Module1 part 1 v1.pptx
CSE3120- Module1 part 1 v1.pptxakhilagajjala
 

Similar to Os introduction (20)

Ch1 introduction
Ch1   introductionCh1   introduction
Ch1 introduction
 
MK Sistem Operasi.pdf
MK Sistem Operasi.pdfMK Sistem Operasi.pdf
MK Sistem Operasi.pdf
 
5120224.ppt
5120224.ppt5120224.ppt
5120224.ppt
 
Operating System BCA 301
Operating System BCA 301Operating System BCA 301
Operating System BCA 301
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
ch1.ppt
ch1.pptch1.ppt
ch1.ppt
 
Computer Architecture & Organization.ppt
Computer Architecture & Organization.pptComputer Architecture & Organization.ppt
Computer Architecture & Organization.ppt
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecture
 
Operating System Overview.pdf
Operating System Overview.pdfOperating System Overview.pdf
Operating System Overview.pdf
 
OS Content.pdf
OS Content.pdfOS Content.pdf
OS Content.pdf
 
OS-Part-01.pdf
OS-Part-01.pdfOS-Part-01.pdf
OS-Part-01.pdf
 
Kernel security Concepts
Kernel security ConceptsKernel security Concepts
Kernel security Concepts
 
Introduction to Operating Systems.pdf
Introduction to Operating Systems.pdfIntroduction to Operating Systems.pdf
Introduction to Operating Systems.pdf
 
Module 1 Introduction.ppt
Module 1 Introduction.pptModule 1 Introduction.ppt
Module 1 Introduction.ppt
 
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
 
Roll of os
Roll of osRoll of os
Roll of os
 
Roll of os
Roll of osRoll of os
Roll of os
 
unit1 part1.ppt
unit1 part1.pptunit1 part1.ppt
unit1 part1.ppt
 
CSE3120- Module1 part 1 v1.pptx
CSE3120- Module1 part 1 v1.pptxCSE3120- Module1 part 1 v1.pptx
CSE3120- Module1 part 1 v1.pptx
 
Lec 3
Lec 3 Lec 3
Lec 3
 

Recently uploaded

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

Os introduction

  • 1. Operating System Basics CS 537 - Introduction to Operating Systems
  • 2. Definition • An operating system is an intermediary between a computer user and the hardware. • Make the hardware convenient to use. • Manages system resources. • Use the hardware in an efficient manner.
  • 3. System Diagram system and application programs operating system hardware user 1 user 2 user n . . . compiler text editor ls
  • 4. Types of Systems • Batch – submit large number of jobs at one time – system decides what to run and when • Time Sharing – multiple users connected to single machine – few processors, many terminals • Single User Interactive – one user, one machine – traditional personal computer
  • 5. Types of Systems • Parrallel – traditional multiprocessor system – higher throughput and better fault tolerance • Distributed – networked computers • Real Time – very strict response time requirements – hardware or software
  • 6. Single Tasking System • Only one program can perform at a time • Simple to implement – only one process attempting to use resources • Few security risks • Poor utilization of the CPU and other resources • Example: MS-DOS
  • 7. Multitasking System • Very complex • Serious security issues – how to protect one program from another sharing the same memory • Much higher utilization of system resources • Example: Unix, Windows NT
  • 8. Hardware Basics • OS and hardware closely tied together • Many useful hardware features have been invented to compliment the OS • Basic hardware resources – CPU – Memory – Disk – I/O
  • 9. CPU • CPU controls everything in the system – if work needs to be done, CPU gets involved • Most precious resource – this is what your paying for – want to get high utilization (from useful work) • Only one process on a CPU at a time • Hundreds of millions of instructions / sec – and getting faster all the time
  • 10. Memory • Limitted in capacity – never enough memory • Temporary (volatile) storage • Electronic storage – fast, random access • Any program to run on the CPU must be in memory
  • 11. Disk • Virtually infinite capacity • Permanent storage • Orders of magnitude slower than memory – mechanical device – millions of CPU instructions can execute in the time it takes to access a single piece of data on disk • All data is accessed in blocks – usually 512 bytes
  • 12. I/O • Disk is actually part of the I/O subsystem – they are of special interest to the OS • Many other I/O devices – printers, monitor, keyboard, etc. • Most I/O devices are painfully slow • Need to find ways to hide I/O latency – like multiprogramming
  • 13. Protection and Security • OS must protect itself from users – reserved memory only accessible by OS – hardware enforced • OS may protect users from one another – not all systems do this – hardware enforced again
  • 14. Protection and Security • Dual -Mode Operation – user mode • limited set of hardware instr and memory available • mode all user programs run in – supervisory mode • all hardware instr and memory are available • mode the OS runs in • Never let user run in supervisory mode
  • 15. Interrupts • Modern OS’s are event driven • Event is signaled by special hardware signal sent to the CPU • Two types of events – interrupts • caused by external devices or timers • can occur at any moment in time – exceptions (traps) • caused by software – the generic term for both is Interrupt • sorry for the confusion
  • 16. Interrupt Philosophy • One way to handle interrupts is with one standard program – big case-switch statement that gets executed on any interrupt – inefficient • Second alternative is to use an interrupt table and special hardware – this is the way modern systems operate
  • 17. Interrupt Table • Large array indicating what code to run for a given interrupt • Each interrupt has a corresponding number associated with it – on Intel processors this is from 0 to 255 – this gives fixed size interrupt table • Use the interrupt number to index into the array to find out what code to run
  • 18. Interrupt Hardware • Programmable Interrupt Controller (PIC) – connected to I/O devices via interrupt request lines (IRQ) • ideally, one IRQ for each I/O device - doesn’t work this way in reality • PIC connected to CPU by a special signal • PIC also connected to CPU via I/O bus • Besides the PIC, interrupts can also be generated by software instructions or errors – again, these are usually referred to as exceptions
  • 19. Interrupt Hardware I/O Bus CPU P I C I/O I/O INTR The above is a conceptual view of the hardware - not the exact way things are really connected
  • 20. Hardware Handling of Interrupts • After each instruction executes, CPU checks to see if interrupt pin has been raised • If so, the following occurs: 1) sets the system into kernel mode (if not already there) 2) determine interrupt number (from PIC or instruction) 3) read appropriate interrupt table entry - special register contains base address of interrupt table - each entry in table is fixed size so easy to calculate where to look in memory ( memLoc = idtr + 8 * intNum ) 4) saves the program counter to the stack (with a couple of others) 5) saves error code to stack (if it exists) 6) loads the program counter with the value stored in the interrupt table - this starts the CPU executing the interrupt routine
  • 21. Hardware Handling of Interrupts • After the interrupt code finishes: 1) interrupt handler issues an iret instruction 2) reload the program counter from the stack 3) reload stack pointer with old process 4) set the system back to user mode • Steps 3 & 4 may not be executed if the system was running in kernel mode when the interrupt occurred – nested exceptions
  • 22. Software Handling of Interrupts • The following 6 steps are common to all interrupt handlers: 1) save IRQ to kernel mode stack 2) save registers to kernel mode stack 3) send acknowledgement to PIC - this allows PIC to then handle other interrupts on IRQ line 4) execute the appropriate handler code 5) restore registers 6) issue an iret instruction • The steps for exception handlers are almost identical – simply remove steps 1 & 3 above
  • 23. More on Exceptions • As indicated earlier, exceptions are caused by software – divide by zero error – page fault – int instruction – etc • Some of these cause the program to stop executing • Some of them invoke special operating system code that is invisible to the user • Some of them invoke operating system code at the user’s request – system calls
  • 24. Single IRQ for Multiple Devices • The number of IRQ lines is usually limited • May have more I/O devices than IRQ’s • Solution: let multiple devices share an IRQ • Interrupt table contains a pointer to a linked list of interrupt handlers – instead of the address of the interrupt handler • On interrupt, execute all of the handlers associated with an IRQ – requires handlers to recognize if interrupt is really for them
  • 26. Example • Assume an interrupt from the scanner arrives at the PIC 1) PIC raises INTR signal on CPU 2) CPU reads PIC over I/O bus to determine IRQ 3) CPU then accesses array in memory to get the first interrupt handler - printer 4) CPU executes printer handler code 5) printer handler queries printer and notices there is no interrupt pending - handler returns immediately 6) next the scanner handler gets executed 7) scanner handler queries scanner and notices there is an interrupt pending - proceeds to handle the interrupt - then returns
  • 27. System Calls • An OS’s system calls are called the Application Programmers Interface (API) • System calls are routines run by the OS on behalf of the user • They are run in supervisory mode • Allow user to access I/O, create processes, get system information, etc. • How many system calls an OS has varies – Unix: around a hundred – Windows: around a thousand
  • 28. System Startup • On power up – everything in system is in random, unpredictable state – special hardware circuit raises RESET pin of CPU • sets the program counter to 0xfffffff0 – this address is mapped to ROM (Read-Only Memory) • BIOS (Basic Input/Output Stream) – set of programs stored in ROM – some OS’s use only these programs • MS DOS – many modern systems use these programs to load other system programs • Windows, Unix, Linux
  • 29. BIOS • General operations performed by BIOS 1) find and test hardware devices - POST (Power-On Self-Test) 2) initialize hardware devices - creates a table of installed devices 3) find boot sector - may be on floppy, hard drive, or CD-ROM 4) load boot sector into memory location 0x00007c00 5) sets the program counter to 0x00007c00 - starts executing code at that address
  • 30. Boot Loader • Small program stored in boot sector • Loaded by BIOS at location 0x00007c0 • Configure a basic file system to allow system to read from disk • Loads kernel into memory • Also loads another program that will begin kernel initialization
  • 31. Initial Kernel Program • Determines amount of RAM in system – uses a BIOS function to do this • Configures hardware devices – video card, mouse, disks, etc. – BIOS may have done this but usually redo it • portability • Switches the CPU from real to protected mode – real mode: fixed segment sizes, 1 MB memory addressing, and no segment protection – protected mode: variable segment sizes, 4 GB memory addressing, and provides segment protection • Initializes paging (virtual memory)
  • 32. Final Kernel Initialization • Sets up page tables and segment descriptor tables – these are used by virtual memory and segmentation hardware (more on this later) • Sets up interrupt vector and enables interrupts • Initializes all other kernel data structures • Creates initial process and starts it running – init in Linux – smss (Session Manager SubSystem) in NT
  • 33. OS Philosophy • Microkernel versus Macrokernel – few services versus lots of services • Hard to agree on what should go in OS • More functionality, less generality • More services, more complexity, more bugs – longer time to market, too • But macrokernels dominate the market – Unix, Linux, Windows, Mac
  • 34. OS Philosophy few services many services mach Windows Mac Unix
  • 35. System Programs • Application programs included with the OS • Highly trusted programs • Perform useful work that most users need – listing and deleting files, configuring system – ls, rm, Windows Explorer and Control Panel – may include compilers and text editors • Not part of the OS – run in user space • Very useful