OS tutoring #1
-
Upload
jaesang-yoo -
Category
Technology
-
view
226 -
download
0
description
Transcript of OS tutoring #1
![Page 1: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/1.jpg)
2013.04.03ASL @ KAU
![Page 2: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/2.jpg)
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
![Page 3: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/3.jpg)
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
![Page 4: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/4.jpg)
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
![Page 5: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/5.jpg)
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
![Page 6: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/6.jpg)
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
![Page 7: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/7.jpg)
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
What is Operating System?
Magician
Government4GB 2GB
xx
![Page 8: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/8.jpg)
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
The Goal of OS
Convenient
Software engineering problem
Efficient
System engineering problem
![Page 9: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/9.jpg)
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
![Page 10: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/10.jpg)
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
![Page 11: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/11.jpg)
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
![Page 12: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/12.jpg)
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
![Page 13: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/13.jpg)
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)
![Page 14: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/14.jpg)
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
![Page 15: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/15.jpg)
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
![Page 16: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/16.jpg)
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
![Page 17: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/17.jpg)
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
![Page 18: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/18.jpg)
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
![Page 19: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/19.jpg)
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
![Page 20: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/20.jpg)
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
![Page 21: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/21.jpg)
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
![Page 22: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/22.jpg)
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
I/O type (Interrupt)
Interrupt timeline
Trap (software generated interrupt)
Kernel mode
System call
![Page 23: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/23.jpg)
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
![Page 24: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/24.jpg)
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
![Page 25: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/25.jpg)
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Locality of Reference
![Page 26: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/26.jpg)
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
Hardware, Software, Middleware
![Page 27: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/27.jpg)
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
![Page 28: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/28.jpg)
http://asl.kau.ac.krAerosystem Software Lab. @ Korea Aerospace Univ
User mode, Kernel mode
Kernel has core functions.
User applications has algorithm for jobs.
![Page 29: OS tutoring #1](https://reader033.fdocuments.in/reader033/viewer/2022052623/559cec9d1a28ab1e708b47f8/html5/thumbnails/29.jpg)
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