Architectural
(hardware) Support for
Operating Systems
• Review of introduction
• Hardware overview
• A peek at Unix
• Hardware (architecture) support
• Summary
Review
• What are the two main responsibilities of OS?
• Manage hardware resources
• Provide a clean set of interface to programs
• Managing resources:
• Allocation
• Protection
• Reclamation
• Virtualization
• Questions?
Why Start With Hardware?
• Operating system functionality fundamentally depends
upon hardware
• Key goal of an OS is to manage hardware
• If done well, applications can be oblivious to HW details
• Hardware support can greatly simplify – or complicate –
OS tasks
• Early PC operating systems (DOS, MacOS) lacked virtual
memory in part because the hardware did not support it
So what is inside a computer
Why hardware has to support
User/Kernel mode?
17 CS317 Operating System
• Give the CPU to the user application
• Why: Performance and efficiency
• OS will not be executing
• Without hardware’s help, OS loses control of the machine!
• Analogy: give the car key to someone, how do you know if he will
return the car?
• This is the one of the most fundamental reasons why OS will
need hardware support --- not only for user/kernel mode
Hardware Features for OS
• Features that directly support the OS include
• Protection (kernel/user mode)
• Protected instructions
• Memory protection
• System calls
• Interrupts and exceptions
• Timer (clock)
• I/O control and operation
• Synchronization
Types of Hardware Support
• Manipulating privileged machine state
• Protected instructions
• Manipulate device registers, TLB entries, etc.
• Generating and handling “events”
• Interrupts, exceptions, system calls, etc.
• Respond to external events
• CPU requires software intervention to handle fault or trap
• Mechanisms to handle concurrency
• Interrupts, atomic instructions
Protected Instructions
• A subset of instructions of every CPU is restricted to use
only by the OS
• Known as protected (privileged) instructions
• Only the operating system can
• Directly access I/O devices (disks, printers, etc.)
• Security, fairness (why?)
• Manipulate memory management state
• Page table pointers, page protection, TLB management, etc.
• Manipulate protected control registers
• Kernel mode, interrupt level
• Halt instruction (why?)
OS Protection
• Hardware must support (at least) two modes of operation:
kernel mode and user mode
• Mode is indicated by a status bit in a protected control register
• User programs execute in user mode
• OS executes in kernel mode (OS == “kernel”)
• Protected instructions only execute in kernel mode
• CPU checks mode bit when protected instruction executes
• Setting mode bit must be a protected instruction
• Attempts to execute in user mode are detected and prevented
• x86: General Protection Fault
Memory Protection
• OS must be able to protect programs from each other
• OS must protect itself from user programs
• We need hardware support
• Again: once OS gives the CPU to the user programs, OS loses
control
• Memory management hardware provides memory
protection mechanisms
• Base and limit registers
• Page table pointers, page protection, TLB
• Virtual memory
• Segmentation
• Manipulating memory management hardware uses
protected (privileged) operations
Hardware Features for OS
• Features that directly support the OS include
• Protection (kernel/user mode)
• Protected instructions
• Memory protection
• System calls
• Interrupts and exceptions
• Timer (clock)
• I/O control and operation
• Synchronization
Events
• After the OS has booted, all entry to the kernel happens as the result
of an event
• event immediately stops current execution
• changes mode to kernel mode, event handler is called
• An event is an “unnatural” change in control flow
• Events immediately stop current execution
• Changes mode, context (machine state), or both
• The kernel defines a handler for each event type
• Event handlers always execute in kernel mode
• The specific types of events are defined by the machine
• In effect, the operating system is one big event handler
OS Control Flow
• When the processor receives an event of a given type, it
• transfers control to handler within the OS
• handler saves program state (PC, registers, etc.)
• handler functionality is invoked
• handler restores program state, returns to program
สถาปัตยกรรม(ฮาร์ดแวร์) สนับสนุนระบบปฏิบัติการ•ตรวจสอบแนะนำ•ภาพรวมฮาร์ดแวร์•มองที่ Unix•สนับสนุนฮาร์ดแวร์ (สถาปัตยกรรม)•สรุปตรวจทาน•รับผิดชอบหลักสองของ OS คืออะไร•จัดการทรัพยากรฮาร์ดแวร์•แสดงชุดการอินเทอร์เฟซการโปรแกรมดี•การจัดการทรัพยากร:•การปันส่วน•การป้องกัน•ถม•จำลองเสมือน•คำถามทำไมไม่เริ่มทำงานกับฮาร์ดแวร์•ระบบปฏิบัติการฟังก์ชันพื้นฐานขึ้นอยู่กับเมื่อฮาร์ดแวร์•เป้าหมายคีย์ของระบบปฏิบัติการจะจัดการฮาร์ดแวร์•ถ้าทำดี โปรแกรมประยุกต์อาจลบเลือนไปรายละเอียด HW•สนับสนุนฮาร์ดแวร์สามารถอย่าง ง่าย – หรือ complicate –ระบบปฏิบัติงาน•ช่วงพีซีระบบปฏิบัติการ (DOS, MacOS) ขาดเสมือนหน่วยความจำบางส่วนเนื่องจากฮาร์ดแวร์ไม่สนับสนุนดังนั้น ที่อยู่ภายในเครื่องทำไมฮาร์ดแวร์ได้รับการสนับสนุนผู้ใช้/เคอร์เนลโหมดระบบปฏิบัติการ 17 CS317•ให้ CPU ไปยังโปรแกรมประยุกต์ของผู้ใช้•สาเหตุ: ประสิทธิภาพและประสิทธิผล•ระบบปฏิบัติจะไม่สามารถดำเนินการ•ไม่ มีความช่วยเหลือของฮาร์ดแวร์ ระบบปฏิบัติการสูญเสียการควบคุมเครื่องจักร•คำว่า: รถสำคัญกับบุคคล คุณทราบได้อย่างไรถ้าเขาจะให้กลับรถหรือไม่•นี่คือหนึ่งเหตุผลพื้นฐานที่สุดทำไม OS จะต้องการฮาร์ดแวร์สนับสนุนไม่เฉพาะสำหรับผู้ใช้/เคอร์เนลโหมด คุณลักษณะของฮาร์ดแวร์สำหรับระบบปฏิบัติการ•คุณลักษณะที่สนับสนุนระบบปฏิบัติการโดยตรงรวมถึง•ป้องกัน (โหมดเคอร์เนล/ผู้ใช้)คำแนะนำ•ป้องกัน•การป้องกันหน่วยความจำ•ระบบโทรศัพท์•ขัดจังหวะและข้อยกเว้น•จับเวลา (นาฬิกา)• I/O ควบคุมและดำเนินการ•ซิงโครไนส์ชนิดของการสนับสนุนฮาร์ดแวร์•จัดการเครื่องอภิสิทธิ์รัฐคำแนะนำ•ป้องกัน•จัดการลงทะเบียนอุปกรณ์ TLB รายการ เป็นต้น•การสร้าง และการจัดการ "เหตุการณ์"•ขัดจังหวะ ยกเว้น ระบบโทรศัพท์ ฯลฯ•ตอบสนองต่อเหตุการณ์ภายนอก• CPU ต้องการแทรกแซงของซอฟต์แวร์การจัดการข้อบกพร่องหรือกับดัก•กลไกการจัดการพร้อมกัน•ขัดจังหวะ คำแนะนำอะตอมคำแนะนำป้องกัน•ชุดย่อยของคำสั่งของ CPU ทุกถูกจำกัดการใช้โดยระบบปฏิบัติการเท่านั้น•เป็นคำแนะนำ (อภิสิทธิ์) ได้รับการป้องกัน•เฉพาะระบบปฏิบัติการสามารถ•อุปกรณ์ I/O (ดิสก์ เครื่องพิมพ์ ฯลฯ) ที่เข้าถึงโดยตรง•ความปลอดภัย ยุติธรรม (ทำไม)•จัดการสถานะการจัดการหน่วยความจำ•หน้าตารางตัวชี้ ป้องกันหน้า TLB จัดการ ฯลฯ•จัดการทะเบียนควบคุมป้องกัน•โหมดเคอร์เนล ขัดจังหวะระดับ•คำสั่งหยุด (ทำไม)ป้องกันระบบปฏิบัติการ•ฮาร์ดแวร์ต้องสนับสนุน (น้อย) สองโหมดของการดำเนินงาน:ผู้ใช้และโหมดเคอร์เนล•โหมดตามบิตสถานะในทะเบียนควบคุมป้องกัน•ผู้ใช้โปรแกรมที่เรียกใช้ในโหมดผู้ใช้•ระบบปฏิบัติดำเนินการในโหมดเคอร์เนล (OS == "เมล็ด")คำแนะนำ•ป้องกันเฉพาะดำเนินการในโหมดเคอร์เนล• CPU ตรวจสอบบิตโหมดเมื่อดำเนินการคำสั่งที่ได้รับการป้องกัน•ตั้งค่าโหมดบิตต้องเป็นคำสั่งที่ได้รับการป้องกัน•พยายามดำเนินการในโหมดผู้ใช้ตรวจพบ และป้องกัน• x86: General Protection FaultMemory Protection• OS must be able to protect programs from each other• OS must protect itself from user programs• We need hardware support• Again: once OS gives the CPU to the user programs, OS losescontrol• Memory management hardware provides memoryprotection mechanisms• Base and limit registers• Page table pointers, page protection, TLB• Virtual memory• Segmentation• Manipulating memory management hardware usesprotected (privileged) operationsHardware Features for OS• Features that directly support the OS include• Protection (kernel/user mode)• Protected instructions• Memory protection• System calls• Interrupts and exceptions• Timer (clock)• I/O control and operation• SynchronizationEvents• After the OS has booted, all entry to the kernel happens as the resultof an event• event immediately stops current execution• changes mode to kernel mode, event handler is called• An event is an “unnatural” change in control flow• Events immediately stop current execution• Changes mode, context (machine state), or both• The kernel defines a handler for each event type• Event handlers always execute in kernel mode• The specific types of events are defined by the machine• In effect, the operating system is one big event handlerOS Control Flow• When the processor receives an event of a given type, it• transfers control to handler within the OS
• handler saves program state (PC, registers, etc.)
• handler functionality is invoked
• handler restores program state, returns to program
การแปล กรุณารอสักครู่..
สถาปัตยกรรม
( ฮาร์ดแวร์ ) การสนับสนุนระบบปฏิบัติการ
-
- รีวิวแนะนำฮาร์ดแวร์ภาพรวม
-
- แอบดูฮาร์ดแวร์ยูนิกซ์ ( สถาปัตยกรรม ) สนับสนุน
- - สรุปทบทวนสิ่งที่มี 2 หน้าที่หลักของระบบปฏิบัติการ ?
-
- จัดการทรัพยากรฮาร์ดแวร์ให้ทำความสะอาดชุดของอินเตอร์เฟซโปรแกรมการจัดการทรัพยากร :
-
-
-
- ป้องกันการเวนคืน
-
- ) คำถาม ?
ทำไมต้องเริ่มด้วยฮาร์ดแวร์ ? ฟังก์ชันการทำงานระบบปฏิบัติการ
-
- บนฮาร์ดแวร์พื้นฐานขึ้นอยู่กับเป้าหมายหลักของ OS คือการจัดการบริการฮาร์ดแวร์
ถ้าทำได้ดี การใช้งานที่สามารถลบเลือนไป HW รายละเอียด
- สนับสนุนฮาร์ดแวร์สามารถง่ายหรือซับซ้อน––งาน
-
OS ระบบปฏิบัติการคอมพิวเตอร์ก่อน ( DOS , MacOS ) ขาดเสมือน
หน่วยความจำใน ส่วนหนึ่งเพราะอุปกรณ์ไม่สนับสนุนมัน
ดังนั้น สิ่งที่อยู่ภายในคอมพิวเตอร์ฮาร์ดแวร์เพื่อสนับสนุน
ทำไมมีโหมด / โปรแกรมผู้ใช้
-
17 cs317 ระบบปฏิบัติการให้ CPU ผู้ใช้โปรแกรม
-
ทำไม : สมรรถนะและประสิทธิภาพของแต่ละ OS จะไม่ถูกรัน
- โดยไม่ต้องฮาร์ดแวร์ช่วยให้ OS สูญเสียการควบคุมของเครื่องจักร
- คล้ายคลึงให้กุญแจรถกับใคร คุณจะรู้ได้อย่างไรว่าเขาจะ
กลับรถ
- นี้เป็นหนึ่งในเหตุผลพื้นฐานที่สุดทำไม OS จะต้องสนับสนุนฮาร์ดแวร์ ---
ไม่เพียง แต่สำหรับผู้ใช้ / คุณสมบัติของฮาร์ดแวร์สำหรับระบบปฏิบัติการเคอร์เนลโหมด
แต่ละคุณลักษณะที่สนับสนุนโดยตรง OS รวมถึงการป้องกัน -
( kernel / ผู้ใช้โหมด )
-
- ใช้หน่วยความจำการคุ้มครองป้องกัน - และ - ระบบโทรศัพท์
ขัดจังหวะตัวตั้งเวลา ( นาฬิกา ) ข้อยกเว้น
-
- I / O
-
และประสานงานควบคุมประเภทของฮาร์ดแวร์สนับสนุน
สิทธิพิเศษ - สภาพเครื่อง - จัดการป้องกันคำแนะนำ
- จัดการลงทะเบียนอุปกรณ์ TLB รายการ ฯลฯ
- การสร้างและการจัดการ " เหตุการณ์ "
- ขัดจังหวะ , ยกเว้น สาย ระบบ ฯลฯ
-
- ตอบสนองต่อเหตุการณ์ภายนอกซีพียูจำเป็นต้องใช้ซอฟต์แวร์เพื่อจัดการกับความผิดหรือการแทรกแซงกลไกกับดัก
- จัดการ การรักษาคำแนะนำ
- อะตอมป้องกันคำแนะนำ
- บางส่วนของคำแนะนำของทุก CPU ต้องใช้ OS
-
โดยเฉพาะ เรียกว่าป้องกัน ( อภิสิทธิ์ ) คําแนะนํา
-
- แต่ระบบปฏิบัติการสามารถเข้าถึงโดยตรงอุปกรณ์ I / O ( ดิสก์ , เครื่องพิมพ์ฯลฯ )
- ความปลอดภัย ความยุติธรรม ( ทำไม ? )
-
- รัฐจัดการการจัดการหน่วยความจำหน้าโต๊ะตัวชี้ , ป้องกัน , การจัดการ TLB
หน้า ฯลฯ- จัดการป้องกันควบคุมทะเบียน
-
- ) เคอร์เนลโหมด ขัดจังหวะ หยุดการเรียนการสอน ( ทำไม ? )
-
OS ป้องกันฮาร์ดแวร์ต้องรองรับ ( อย่างน้อย ) สองโหมดของการดำเนินงาน :
โหมดเคอร์เนลและโหมดโหมดผู้ใช้
- จะแสดงสถานะบิตในการป้องกันควบคุมการลงทะเบียนผู้ใช้โปรแกรมรันในโหมด
-
ผู้ใช้ OS - รันในโหมดเคอร์เนล ( OS = =
" เมล็ด " )- ป้องกันการตรวจสอบ CPU ของคำแนะนำในแต่ละโหมดโหมดบิตเมื่อป้องกันการรัน
- โหมดการตั้งค่าบิตต้องป้องกัน - การสอน
พยายามที่จะรันในโหมดผู้ใช้ตรวจพบและป้องกัน
- x86 : การป้องกันทั่วไปผิด
ความคุ้มครองแต่ละ OS จะต้องสามารถป้องกันโปรแกรม
- จากแต่ละอื่น ๆ OS จะต้องปกป้องตัวเองจากโปรแกรมของผู้ใช้
- เราต้องการการสนับสนุนฮาร์ดแวร์อีก -
เมื่อ OS ให้ CPU ที่จะใช้โปรแกรม OS แพ้
ฮาร์ดแวร์การจัดการหน่วยความจำควบคุมหน่วยความจำ
-
มีกลไกป้องกันฐานและขีด จำกัด นี้
-
- หน้าโต๊ะตัวชี้ , หน้าป้องกัน TLB
-
-
- ) หน่วยความจำเสมือนการจัดการการจัดการหน่วยความจำฮาร์ดแวร์ใช้
ป้องกัน ( อภิสิทธิ์ )
งานคุณสมบัติของฮาร์ดแวร์สำหรับระบบปฏิบัติการแต่ละคุณลักษณะที่สนับสนุนโดยตรง OS รวมถึงการป้องกัน -
( kernel / ผู้ใช้โหมด )
-
- ใช้หน่วยความจำการคุ้มครองป้องกัน - ระบบโทรศัพท์ - ขัดจังหวะและข้อยกเว้น
-
เวลา ( นาฬิกา )
- I / O ควบคุมและปฏิบัติการ
-
- ประสานเหตุการณ์หลังจากที่ OS มี booted ทั้งหมดเข้ามา เคอร์เนลเกิดขึ้นเป็นผลของเหตุการณ์แต่ละเหตุการณ์
ปัจจุบันการหยุดทันที- เปลี่ยนโหมดเป็นโหมดเคอร์เนล , สถานที่เกิดเรียกว่า
- เหตุการณ์ที่เป็น " ธรรมชาติ " การเปลี่ยนแปลงในการควบคุมแต่ละเหตุการณ์การหยุดทันที
-
ปัจจุบันการเปลี่ยนแปลงโหมด บริบท ( สภาพเครื่อง ) หรือทั้งสอง
- เคอร์เนลกำหนดผู้ดูแลแต่ละเหตุการณ์แต่ละเหตุการณ์มักจะดำเนินการจัดการประเภท
โหมดใน เมล็ดแต่ละชนิดที่เฉพาะเจาะจงของเหตุการณ์ถูกกำหนดโดยเครื่อง
- ผลระบบปฏิบัติการเป็นหนึ่งใหญ่จัดการเหตุการณ์สำหรับการควบคุมการไหล
-
เมื่อประมวลผลได้รับงานให้พิมพ์ มัน
- ควบคุมการรับส่งกับผู้ดูแลภายใน OS
- ผู้ดูแลจะบันทึกสถานะรายการ ( PC , ทะเบียน , ฯลฯ )
-
- ฟังก์ชั่นจัดการเรียกผู้ดูแลคืนสภาพกลับโปรแกรมโปรแกรม
การแปล กรุณารอสักครู่..