os tutoring #1
DESCRIPTION
Operating System Tutoring #1. by Aerosystem Software Lab. @ Korea Aerospace Univ. This is tutoring slide for the students who were not understood well about operating system or fundamentals of computer engineering. This slide may has some misconceptions or inappropriate examples. Any feedback is welcomed. 운영체제 튜터링 #1. - 항공 소프트웨어 연구실 @ 한국항공대학교 본 슬라이드는 튜터링 강의자료로, 운영체제에 대한 개념이나 컴퓨터공학 기초지식이 부족한 학생들을 기준으로 작성하였습니다. 본 슬라이드에 일부 잘못된 개념이나 부적절한 예시가 포함되어 있을 수도 있습니다. 피드백 환영합니다.TRANSCRIPT
2013.04.03ASL @ KAU
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Contents
What is operating system?
History of OS
Input / Output
Software polling
Interrupt
Memory mapped
Storage structure
Cache
Locality of reference
OS basics
Process structure
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
What is Operating System?
An Operating System is the interface between
the users and the hardware.
It implements a virtual machine that is easier to program
than bare hardware
1101011010101
MOV EAX, EBX
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
What is Operating System?
An Operating System is the interface between
the users and the hardware.
It implements a virtual machine that is easier to program
than bare hardware
1101011010101
MOV EAX, EBXA = B
return
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
What is Operating System?
An OS provides standard services (an interface)
which are implemented on the hardware.
Including Processes, CPU Scheduling, Memory managem
ent, File system, Networking…
UI
Device IO
Graphic
Network
File IO
UI
Device IO
Graphic
Network
File IO
UI
Device IO
Graphic
Network
File IO
UI
Device IO
Graphic
Network
File IO
UI
Device IO
Graphic
Network
File IO
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
What is Operating System?
An OS provides standard services (an interface)
which are implemented on the hardware.
Including Processes, CPU Scheduling, Memory managem
ent, File system, Networking…
UI
Device IO
Graphic
Network
File IO
UI
Device IO
Graphic
Network
File IO
UI
Device IO
Graphic
Network
File IO
UI
Device IO
Graphic
Network
File IO
UI
Device IO
Graphic
Network
File IO
System Call
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
What is Operating System?
Magician
Government4GB 2GB
xx
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
The Goal of OS
Convenient
Software engineering problem
Efficient
System engineering problem
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Why study Operating System?
Abstraction
How do we give the users the illusion of infinity resource?
(CPU time, Memory, File space)
System Design
Tradeoff
Performance Convenience
Abstraction
Performance Simplicity
OS
Hardware Software
Functionality
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
History of OS (Phase 0)
HW is a very expensive experiment, No OS
One function at a time
Computation
I/O
User think/response
Program loaded via card deck
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
History of OS (Phase 1)
Hardware is expensive, Humans are cheap
Simple Batch processing
Load program
Run
Print result
Dump
Start
Load New Job
Execute Job
Next Job?
Wait for Jobs
Yes No
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
History of OS (Phase 1)
Overlapped CPU & I/O operations
CPU Don’t need to wait till I/O Finishes
More effective usage of Hardware
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
History of OS (Phase 1)
Multi-programmed batch system
Looks like programs are running simultaneously
Pick some jobs to run (scheduling)
Put jobs in memory (memory management)
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
History of OS (Phase 2)
Hardware is less expensive than before,
Humans are becoming expensive
Interactive Timesharing
Preemptive scheduling to maintain adequate response time
Avoid Thrashing (program swap in, out)
UNIX developed at Bell Lab
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
History of OS (Phase 3)
Hardware is very cheap, Humans are expensive
Personal Computer (Macintosh)
Return to simplicity
No more supporting
Multiprogramming
Concurrency
Protection
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
History of OS (Phase 4)
Hardware are very cheap, but speed has limit
Parallel
Multi-core processors
GPU
Distributed
Cluster
Grid
Cloud
Shared Memory
CPU CPU CPU
Computer
Computer
Computer
Computer
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Other OS
Real-time Operating System
Often used as a control device in a dedicated application
Controlling scientific experiments
Medical imaging systems
Industrial control systems
And some display systems.
Well-defined fixed-time constraints.
Real-Time systems may be either hard or soft real-time
Hard real-time
Failure cause injury or loss of money
Soft real-time
Failure is not much critical than hard real-time
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Input / Output
CPU and device controllers all use a common
bus for communication Data bus
Address bus
Control bus
Ex. Put your hands up!
Put : Control
Your hands : Address
Up : Data
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
I/O
Synchronous I/O
CPU execution waits while
I/O proceeds
Easy to implement
Ex. Software polling
Asynchronous I/O
I/O proceeds concurrently
with CPU execution
More effective I/O
Ex. Interrupt
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
I/O type (Software polling)
Software polling synchronous I/O
CPU starts an I/O operation, and continuously polls
(checks) that device until the I/O operation finishes
Device controller contains registers for communication
Input, Output Register
for data
Control Register
to tell it what to do
Status Register
to see what it’s done
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
I/O type (Interrupt)
Device controller has its own processor,
and executes asynchronously with CPU
Device controller puts an interrupt signal on the bus
when it needs CPU’s attention
When CPU receive an interrupt
1. It saves the CPU state and invokes the
appropriate interrupt handler using the
interrupt vector
2. Handler must save and restore
software state
3. CPU restores CPU state
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
I/O type (Interrupt)
Interrupt timeline
Trap (software generated interrupt)
Kernel mode
System call
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
I/O Type (Memory mapped I/O)
Direct Memory Access
I/O device can transfer block of data to / from memory
without going through CPU
CPU
Memory
I/O device
data data
I/O Command
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Storage Structure
Memory is not much fast
as what we think
Tradeoff between
size and speed
So we use caching
Where to cache?
Cache up block requires a lot of time
than accessing memory
If cache miss ratio is high, no need to
use cache system
Locality of reference
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Locality of Reference
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Hardware, Software, Middleware
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
3 main process in Kernel
Scheduler
Multi-Tasking
Pager
Memory Management
Cache
Swapper
Virtual Memory
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
User mode, Kernel mode
Kernel has core functions.
User applications has algorithm for jobs.
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Process structure
4 main area
Text
Program Code
Data
Global variable
Static variable
BSS
Heap
Stack
Function frame stack