1 / 91

บทที่ 7

Intro. to. Operating Systems. บทที่ 7. Operating Systems. Intro. to Computer Organization & Architecture. 322 162. หัวข้อเรื่อง. I/O Programming Memory Management Processor Management Device Management Information Management Microprogramming. วัตถุประสงค์การเรียน.

herbertjean
Download Presentation

บทที่ 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intro.to Operating Systems บทที่ 7 Operating Systems Intro. to Computer Organization & Architecture 322 162

  2. หัวข้อเรื่อง • I/O Programming • Memory Management • Processor Management • Device Management • Information Management • Microprogramming

  3. วัตถุประสงค์การเรียน • อธิบายส่วนประกอบหลักและหลักการทำงานของระบบปฏิบัติการได้ถูกต้องครบถ้วน • ยกตัวอย่างระบบปฏิบัติการที่นิยมใช้กันอยู่ในปัจจุบันได้ไม่น้อยกว่า 3 ระบบ • อธิบายความสำคัญของไมโครโปรแกรมได้

  4. หนังสืออ้างอิง • อภิศักดิ์ พัฒนจักร โปรแกรมระบบงานเอกสารประกอบคำสอนวิชา 320 315คณะวิทยาศาสตร์ มหาวิทยาลัยขอนแก่น2547. • Donovan, John J. System Programming McGraw-Hill 1982. • Stallings, William Computer Organization and Architecture : designing for performance 7th ed. NewJersey : Prentice-Hall, 2006.

  5. View of O.S • Users view as utility functions set and control languages used or various facilities provided • System Programmersview as resource management 4 major resources which controlled by O.S. Memory Devices Processor Information

  6. Resource Example Sample Software Memory RAMPaging, Segment-paged Processor CPUs,Traffic Controller,I/O ChannelsScheduler Devices Disks, Printers,Spooling,Tapes Buffering Information SegmentsFile System, (System,Users, Library, Library Segments) Segment Manager

  7. Layers and Views of a Computer System

  8. Operating System Services • การสร้างโปรแกรม • การประมวลผลโปรแกรม • การเข้าถึงข้อมูลบนอุปกรณ์ต่างๆ • การควบคุมการเข้าถึงข้อมูลในไฟล์ • การเข้าถึงระบบ • การติดตามและตอบสนองข้อผิดพลาด • บัญชีการทำงานต่างๆ ฯลฯ

  9. O/S as a Resource Manager

  10. Kernel the central component of most computer operating systems (OS). Its responsibilities include managing the system's resources (the communication between hardware and software components).A kernel provides the lowest-level abstraction layer for the resources (especially memory, processors and I/O devices) that application software must control to perform its function. It typically makes these facilities available to applicationprocesses through inter-process communication mechanisms and system calls

  11. Shell • A piece of software that provides an interface for users. Typically, the term refers to an operating system shell which provides access to the services of a kernel. However, the term is also applied very loosely to applications and may include any software that is "built around" a particular component, such as web browsers and email clients that are "shells" for HTML rendering engines. • The name 'shell' originates from shells being an outer layer of interface between the user and the kernel.

  12. Shell • two categories of OS shells : command line and graphical. Command line shells provide a command line interface (CLI) to the OS, while graphical shells provide a graphical user interface (GUI).

  13. CMD.EXE the command line interpreter on OS/2, Windows CE and on Windows NT-based operating systems (including Windows 2000, XP, Vista, and Server 2003). It is the analog of COMMAND.COM in MS-DOS and Windows 9x systems, or of the Unix shells used on Unix-like systems. Command Prompt on Window Vista

  14. I/O Programming I/O Processor Structure Interruption Masking

  15. Early Computer System โปรแกรมติดต่อโดยตรงกับฮาร์ดแวร์ ปัญหาScheduling Setup time Memory MIPS MFLOPS Disks Printer CPU minute ms. Tape1 Tape2

  16. Disks#2 Disks#1 CPU I/O Channel#1 I/O Channel#2 Memory I/O Channel#4 I/O Channel#3 Tape Control Lines Printer Data Lines

  17. I/O Channel Architecture

  18. I/O Processor • Memoryใช้ Main Memory ร่วมกับ CPUใช้การอ้างอิงด้วย 24 Bits โดยตรง • Registersไม่มี Register โดยเฉพาะแต่มี Program Counter และ Data Counter ทำงาน • Dataใช้ Logical Data แต่บาง I/O Devices อาจมีเปลี่ยนแปลงรูปแบบข้อมูล (Conversion)ด้วย

  19. I/O Processor • Instruction แบ่งคำสั่ง 3 กลุ่ม • Data Transfers • Device Control • Branching CCW : Channel Command Words Op-Code Data Address Flag F Count 0 8 32 37 48 63 Unuse

  20. Communication Master-slave Relationship CPU จะเริ่ม startและ stopหรือ change การทำงานของ Channel ส่วน Channel จะติดต่อกลับมาที่ CPU โดยวิธี Interrupt START I/O Fig. 9.8 TEST I/O HALT I/O TEST CHANNEL

  21. Memory Layout for Resident Monitor

  22. Masking System Mask, Program Mask, Machine Check Mask ขณะที่ยังจัดการกับ Interrupt#1 ยังไม่เสร็จ อาจเกิด Interrupt#2 ขึ้นได้ ก็จะมีการเรียก Interrupt Queue Routine มาทำงานในการจัดคิวลำดับ ซึ่งขณะนั้นก็อาจเกิด Interrupt#3 ขึ้นอีกได้ในขณะที่จัดคิวของ Interrupt#2 ยังไม่เสร็จซึ่งอาจทำให้ .#2 สูญหายได้ จึงใช้การ MASKเพื่อหยุด .#3 ไว้ก่อน (รวมทั้ง .#4, .#5, .#6 อื่นๆ ด้วย)

  23. หัวข้อเรื่อง • I/O Programming • Memory Management • Processor Management • Device Management • Information Management Memory Management

  24. Memory Management Single Contiguous Partitioned Paging Segmentation Segment-Paged

  25. Single Contiguous Main Memory วิธีการ Monitor User’s Program to Execute บรรจุ User’s Program ลงได้ทีละโปรแกรมเท่านั้น โปรแกรมจะมีขนาดใหญ่เกินขนาดหน่วยความจำหลักไม่ได้ Waste Area

  26. Single Contiguous ปัญหา Main Memory Monitor จัดการอย่างไม่มีประสิทธิภาพ User’s Program to Execute Waste Time (no multiprograming) Waste Memory Waste Area โปรแกรมจะมีขนาดใหญ่เกินขนาดหน่วยความจำหลักไม่ได้

  27. Partition Allocation • Fixed Partition or Static Partition • Dynamic Partition • Variable Partition • Relocatable Partition IBM 360 MFT : Multiprograming with Fixed No. of Tasks MVT : Multiprog. with Variable No. of Tasks

  28. Partition Allocation • ขนาดคงที่เท่ากัน (Fixed Partition) แบ่งพื้นที่เป็นส่วนๆ เท่ากันตายตัว SUPERVISOR Partition 1 ProcessQueue Partition 2 Partition 3

  29. Partition Allocation • ขนาดไม่เท่ากัน (Variable Partition) แบ่งพื้นที่เป็นส่วนๆ ไม่เท่ากัน-ตายตัว SUPERVISOR Queue 1 Partition 1 Partition 2 Queue 2 Queue 3 Partition 3

  30. Partition Allocation ปัญหา ขนาดของโปรแกรมไม่พอดีกับขนาดของ Partition ทำให้เกิดที่ว่างในแต่ละ Partition หากมีจำนวนที่ว่างนี้หลายๆ แห่ง อาจทำให้มีขนาดที่ใหญ่เพียงพอสามารถบรรจุโปรแกรมอื่นๆ ลงไปได้ เรียกว่า Fragmentation

  31. Partition Allocation • ขยับพื้นที่ได้ (Relocatable Partition) แบ่งพื้นที่เป็นส่วนๆ แต่สามารถขยับชิดกันได้ (Compact) SUPERVISOR JOB 1 พื้นที่ว่าง Process Queue JOB 3 พื้นที่ว่าง JOB 6

  32. Partition Allocation ปัญหา ค่าตำแหน่งที่มีการอ้างอิงเดิม จะเปลี่ยนเป็นค่าตำแหน่งใหม่อย่างไร? ใช้ Relocation Register Overhead of Relocation Fragmentation

  33. Paged Allocation จัดแบ่ง Program Address Space ออกเป็นส่วนๆ เท่าๆ กัน เรียกว่า Page จัดแบ่ง Memory Address Space ออกเป็นส่วนๆ เท่าๆ กัน เรียกว่า Block สร้าง Page Table ขึ้นทำหน้าที่ Mapping ระหว่าง Page กับBlock ต้องบรรจุทุก Page ลงใน Memory จึงจะ Execute ได้

  34. Paged Allocation • เพจ (Paging) แบ่งโปรแกรมและ Memory เป็นส่วนๆที่เท่ากัน Program Address Space ไม่ต้องอยู่ติดกันได้ SUPERVISOR Page 1 Page 1 PageTable Page 2 Page 2 Page 3 Page 3 Used by Other Page 4 Page 4

  35. Logical and Physical Addresses - Paging

  36. Paged Allocation ปัญหา Page Size ที่เหมาะสมเพื่อลด Ext. Fragmentation เสียเวลาทำ Address Transformation Internal Fragmentation (Page-Breakage)

  37. Page Table Structure

  38. Translation Lookaside Buffer • Every virtual memory reference causes two physical memory access • Fetch page table entry • Fetch data • Use special cache for page table • TLB

  39. TLB Operation

  40. TLB and Cache Operation

  41. Segment Allocation จัดแบ่ง Program Address Space ออกเป็นส่วนๆ ที่สมบูรณ์ เรียกว่า Segment จัดแบ่ง Memory Address Space ออกเป็นส่วนๆ ตามขนาด Segment เรียกว่า Block สร้าง Segment Table ขึ้นทำหน้าที่ Mapping ระหว่าง Segment กับBlock ต้องมีครบทุก Segment อยู่ใน Memory

  42. Segment Allocation • เซกเมนต์(Segment) แบ่ง Memory เป็นส่วนๆ ขนาดชุดคำสั่ง Program Address Space SUPERVISOR Main Main Segment Table Used by Other Sub 1 Sub 1 Sub 2 Sub 2 Data Data

  43. Segment Allocation การอ้างอิง Address แบ่งออกเป็น 2 ส่วน ชื่อของ Segmentและ Offset BETA Attributes 1 2 3 4 5 6

  44. Segment Allocation ปัญหา Schedule of Decision (Paging Algorithm Page Interrupt into Thrashing Internal Fragmentation (Page-Breakage)

  45. Virtual Memory • ความจำเสมือน(Virtual Memory) แบ่งเป็น Pages หรือ Segments โปรแกรมมีขนาดใหญ่กว่า Memory จริงได้ SUPERVISOR Segment 1 Segment 4 Program Address Space Segment 3 Segment 2 Segment Table or PageTable Segment 5

  46. Demand Paged ไม่จำเป็นต้องบรรจุทุก Page ลงใน Memory ก็สามารถExecute ได้ ดังนั้นจึงบรรจุเฉพาะ Page แรกลงใน Memory ก่อน เมื่อมีการเรียกใช้ Page อื่น จึงค่อยเรียกมาบรรจุลงใน Memory ต่อไป (Page Fault) โดยมี Paging Algorithm และ Page Table เป็นกลไกสำหรับการทำงาน

  47. Demand Paged Page Map Table Page No. Status . . . . . . Judgment Block No. 0 OK. 50 Times 3 1 - - - 2 OK. 4 Times 2 3 - - - 4 - - -

  48. Demand Paged ปัญหา Schedule of Decision (Paging Algorithm Page Interrupt into Thrashing Internal Fragmentation (Page-Breakage)

  49. Segment-paged จัดแบ่ง Program Address Space ออกเป็นส่วนๆ ที่สมบูรณ์ เรียกว่า Segment จัดแบ่งแต่ละ Segmentออกเป็นส่วนๆ เท่าๆ กัน เรียกว่า Page สร้าง Segment Table ขึ้นทำหน้าที่ Mapping ระหว่าง Segment กับBlock Memory

  50. Pentium II Address Translation Mechanism

More Related