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.
- 항공 소프트웨어 연구실 @ 한국항공대학교
본 슬라이드는 튜터링 강의자료로, 운영체제에 대한 개념이나 컴퓨터공학 기초지식이 부족한 학생들을 기준으로 작성하였습니다. 본 슬라이드에 일부 잘못된 개념이나 부적절한 예시가 포함되어 있을 수도 있습니다. 피드백 환영합니다.
2. Contents
What is operating system?
History of OS
Input / Output
Storage structure
Software polling
Interrupt
Memory mapped
Cache
Locality of reference
OS basics
Process structure
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
3. 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
MOV EAX, EBX
1101011010101
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
4. 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
A=B
MOV EAX, EBX
return
1101011010101
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
5. 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
UI
UI
UI
UI
Device IO
Device IO
Device IO
Device IO
Device IO
Graphic
Graphic
Graphic
Graphic
Graphic
Network
Network
Network
Network
Network
File IO
File IO
File IO
File IO
File IO
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
6. 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
UI
UI
UI
UI
Device IO
Device IO
Device IO
Device IO
Device IO
Graphic
Graphic
Graphic
Graphic
Graphic
Network
Network
Network
Network
Network
File IO
File IO
File IO
File IO
File IO
Aerosystem Software Lab. @ Korea Aerospace Univ
System Call
http://asl.kau.ac.kr
7. What is Operating System?
Magician
4GB
2GB
Government
x
Aerosystem Software Lab. @ Korea Aerospace Univ
x
http://asl.kau.ac.kr
8. The Goal of OS
Convenient
Software engineering problem
Efficient
System engineering problem
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
9. 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
Performance
Abstraction
Simplicity
OS
Hardware
Software
Functionality
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
10. History of OS (Phase 0)
HW is a very expensive experiment, No OS
One function at a time
Aerosystem Software Lab. @ Korea Aerospace Univ
Computation
I/O
User think/response
Program loaded via card deck
http://asl.kau.ac.kr
11. History of OS (Phase 1)
Hardware is expensive, Humans are cheap
Simple Batch processing
Load program
Run
Print result
Dump
Start
Wait for Jobs
Load New Job
Execute Job
Yes
Aerosystem Software Lab. @ Korea Aerospace Univ
Next Job?
No
http://asl.kau.ac.kr
12. 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
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
13. 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)
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
14. 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
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
15. History of OS (Phase 3)
Hardware is very cheap, Humans are expensive
Personal Computer (Macintosh)
Aerosystem Software Lab. @ Korea Aerospace Univ
Return to simplicity
No more supporting
Multiprogramming
Concurrency
Protection
http://asl.kau.ac.kr
16. History of OS (Phase 4)
Hardware are very cheap, but speed has limit
Parallel
Distributed
Multi-core processors
GPU
Cluster
Grid
Cloud
Shared Memory
Computer
Computer
CPU
CPU
CPU
Computer
Computer
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
17. 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
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
18. 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
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
19. 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
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
20. 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
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
21. 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.
2.
3.
It saves the CPU state and invokes the
appropriate interrupt handler using the
interrupt vector
Handler must save and restore
software state
CPU restores CPU state
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
22. I/O type (Interrupt)
Interrupt timeline
Trap (software generated interrupt)
Kernel mode
System call
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
23. 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
I/O Command
CPU
data
I/O device
data
Memory
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
24. 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
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
27. 3 main process in Kernel
Scheduler
Pager
Multi-Tasking
Memory Management
Cache
Swapper
Virtual Memory
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
28. User mode, Kernel mode
Kernel has core functions.
User applications has algorithm for jobs.
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr
29. Process structure
4 main area
Text
Data
Global variable
Static variable
BSS
Program Code
Heap
Stack
Function frame stack
Aerosystem Software Lab. @ Korea Aerospace Univ
http://asl.kau.ac.kr