Interrupts
• Interrupts signal asynchronous events
• I/O hardware interrupts
• Hardware timers
• Two flavors of interrupts
• Precise: CPU transfers control only on instruction boundaries
• Imprecise: CPU transfers control in the middle of instruction
execution
• What the heck does that mean?
• OS designers like precise interrupts, CPU designers like
imprecise interrupts
How to find interrupt handler?
• Hardware maps interrupt type to interrupt number
• OS sets up Interrupt Descriptor Table (IDT) at boot
• Also called interrupt vector
• IDT is in memory
• Each entry is an interrupt handler
• OS lets hardware know IDT base
• Hardware finds handler using interrupt number as
index into IDT
• handler = IDT[intr_number]
Timer
• The timer is critical for an operating system
• It is the fallback mechanism by which the OS reclaims control
over the machine
• Timer is set to generate an interrupt after a period of time
• Setting timer is a privileged instruction
• When timer expires, generates an interrupt
• Handled by kernel, which controls resumption context
• Basis for OS scheduler (more later…)
• Prevents infinite loops
• OS can always regain control from erroneous or malicious
programs that try to hog CPU
• Also used for time-based functions (e.g., sleep())
I/O Control
• I/O issues
• Initiating an I/O
• Completing an I/O
• Initiating an I/O
• Special instructions
• Memory-mapped I/O
• Device registers mapped into address space
• Writing to address sends data to I/O device
I/O Completion
• Interrupts are the basis for asynchronous I/O
• OS initiates I/O
• Device operates independently of rest of machine
• Device sends an interrupt signal to CPU when done
• OS maintains a vector table containing a list of
addresses of kernel routines to handle various events
• CPU looks up kernel address indexed by interrupt
number, context switches to routine
I/O Example
1. Ethernet receives packet, writes packet into memory
2. Ethernet signals an interrupt
3. CPU stops current operation, switches to kernel mode, saves
machine state (PC, mode, etc.) on kernel stack
4. CPU reads address from vector table indexed by interrupt
number, branches to address (Ethernet device driver)
5. Ethernet device driver processes packet (reads device registers
to find packet in memory)
6. Upon completion, restores saved state from stack
Interrupt Questions
• Interrupts halt the execution of a process and
transfer control (execution) to the operating system
• Can the OS be interrupted? (Consider why there might
be different IRQ levels)
• Interrupts are used by devices to have the OS do
stuff
• What is an alternative approach to using interrupts?
• What are the drawbacks of that approach?
Architecture Trends Impact
OS Design
• Processor
• Single core to multi-core
• OS must better handle concurrency
• Network
• Isolation to dial-up to LAN to WAN
• OS must devote more efforts to communications
• Disconnected to wired to wireless
• OS must manage connectivity more
• Isolated to shared to attacked
• OS must provide more security/protection
• Mobile/battery-operated
• OS must pay attention to energy consumption
May you live in Interesting
Times
• Multicores
• Smart phones
• Tapes
disks
flash memory
..
• 3G, 4G..
53 CS317 Operating System
• Cloud
• Wearable computers
• Virtual reality
• Motion capturing device
ขัดจังหวะ
-
- อะซิงโครนัสสัญญาณขัดจังหวะกิจกรรม I / O
-
ตัวขัดจังหวะฮาร์ดแวร์ฮาร์ดแวร์ - สองรสชาติของการขัดจังหวะ
- แม่นยำ : ถ่ายโอน CPU ควบคุมเฉพาะในขอบเขตการเรียนการสอน
- คลุมเครือ : ซีพียูโอนการควบคุมในช่วงกลางของการสอน
- มันหมายความว่ายังไง ?
- OS ออกแบบเช่นแม่นยำขัดจังหวะ CPU , นักออกแบบเช่น
มันคลุมเครือขัดจังหวะวิธีการค้นหารบกวนผู้ดูแล ? แผนที่
- ฮาร์ดแวร์ประเภทขัดจังหวะรบกวนหมายเลข
- OS ชุดขึ้นขัดจังหวะตารางหัวเรื่อง ( ไอดีที ) ที่บูต
- เรียกว่าขัดจังหวะเวกเตอร์
-
- ไอดีทีอยู่ในหน่วยความจำแต่ละรายการเป็นรบกวนผู้ดูแล
- OS ช่วยให้ฮาร์ดแวร์รู้ไอดีทีฐาน
- ฮาร์ดแวร์พบผู้ดูแลการขัดจังหวะเบอร์เป็นดัชนีลงในไอดีที
- ผู้ดูแล = ไอดีที [ ]
intr_number จับเวลา- เวลาเป็นสิ่งสำคัญสำหรับระบบปฏิบัติการ
- มันเป็นกลไก fallback ที่ OS ค้า
- การควบคุมมากกว่าเครื่องจับเวลาตั้งเพื่อสร้างขัดหลังจากระยะเวลา
- ตั้งค่าเวลาเป็นบริการการเรียนการสอน
สิทธิพิเศษเมื่อเวลาหมดอายุ , สร้างการขัดจังหวะ
- จัดการโดย kernel ซึ่ง การควบคุมพื้นฐานแต่ละบริบท
( OS ตารางเวลา ( เพิ่มเติมในภายหลัง . . . . . . . )
- ป้องกันอนันต์ห่วง
- OS สามารถฟื้นการควบคุมจากข้อผิดพลาดที่เป็นอันตรายหรือโปรแกรมที่พยายามที่จะแย่ง
- CPU ยังใช้สำหรับฟังก์ชั่นส่วนตัว ( เช่น sleep() )
I / O ควบคุม I / O
-
- มีปัญหาการทำ I / O
-
- I / O แบบ เป็น I / O
-
- หน่วยความจำที่แมปพิเศษใช้ I / O
- อุปกรณ์ทะเบียนในพื้นที่แมปที่อยู่
- เขียนที่อยู่จะส่งข้อมูลไปยังอุปกรณ์ I / O
I / O -
ขัดจังหวะความเป็นพื้นฐานสำหรับอุปกรณ์ I / O
- OS เริ่มต้น I / O
- อุปกรณ์ทำงานเป็นอิสระจากส่วนที่เหลือของอุปกรณ์แต่ละเครื่องรบกวนสัญญาณ
ส่ง CPU เมื่อเสร็จแล้ว
- OS รักษาตารางเวกเตอร์ที่มีรายชื่อที่อยู่ของเคอร์เนลตามปกติจัดการ
เหตุการณ์ต่างๆ - CPU ดูเมล็ดที่อยู่โดยดัชนีขัดจังหวะ
เลขที่บริบทสวิตช์รูทีน
I / O ตัวอย่าง1 . อีเธอร์เน็ตได้รับแพ็กเก็ต ที่เขียนลงในหน่วยความจำ
2 Ethernet สัญญาณขัดจังหวะ
3 CPU จะหยุดการทำงานปัจจุบัน สลับโหมดเคอร์เนล ประหยัด
สภาพเครื่อง ( PC , โหมด ฯลฯ ) ใน kernel stack
4 ซีพียูอ่านที่อยู่จากเวกเตอร์ตารางดัชนีโดยขัดจังหวะ
เลขที่ , สาขาที่อยู่ ( โปรแกรมควบคุมอุปกรณ์ Ethernet )
5 ไดรเวอร์อุปกรณ์แพ็คเก็ต Ethernet กระบวนการลงทะเบียน
( อ่านอุปกรณ์การค้นหาข้อมูลในหน่วยความจำ )
6 เมื่อเสร็จสมบูรณ์บันทึกสถานะจากกอง
รบกวนถาม
- ขัดจังหวะหยุดการดำเนินการของกระบวนการและการถ่ายโอนการควบคุม ( ปฏิบัติการ )
สามารถให้บริการระบบปฏิบัติการ OS ถูกขัดจังหวะ ? ( พิจารณาว่าทำไมมันอาจเป็นระดับที่แตกต่างกัน
I , Robot ) - ขัดจังหวะจะถูกใช้โดยอุปกรณ์ต้องมี OS ทำเรื่อง
-
อะไรคือทางเลือกที่จะใช้ขัดจังหวะ ?
- อะไรคือข้อเสียของวิธีการที่ ?
OS ออกแบบสถาปัตยกรรมแนวโน้มผลกระทบที่แต่ละหน่วยประมวลผลแกนเดียวแบบ
- จะ - OS ที่ดีต้องจัดการพร้อมกัน
-
- การแยกเพื่อให้การเชื่อมต่อเครือข่าย LAN กับ WAN
- OS ต้องทุ่มเทความพยายามมากขึ้นเพื่อการสื่อสารเชื่อมต่อแบบไร้สายมีสาย
-
- OS ต้องจัดการการเชื่อมต่อมากขึ้น
- แยกที่ใช้ร่วมกันเพื่อโจมตี
- OS ต้องให้การรักษาความปลอดภัย / ป้องกัน
-
/ มือถือถ่านไฟฉายแต่ละ OS จะต้องให้ความสนใจกับการใช้พลังงาน
คุณอาจจะอยู่ในช่วงเวลาที่น่าสนใจ
-
- multicores โทรศัพท์สมาร์ท - เทป
ดิสก์หน่วยความจำแฟลช . . . . . . .
-
3G , 4G . . . . . . .
cs317 ดำเนินงาน 53 ระบบ
-
-
- คอมพิวเตอร์เมฆได้เสมือนจริง
- อุปกรณ์จับภาพเคลื่อนไหว
การแปล กรุณารอสักครู่..
