Ch10th

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Ch10th - Presentation Transcript

    1. Chapter 9: หน่วยความจำเสมือน Virtual Memory
      • Background
      • Demand Paging
      • Process Creation
      • Page Replacement
      • Allocation of Frames
      • Thrashing
      • Demand Segmentation
      • Operating System Examples
      • พื้นฐาน
      • การจัดเพจตามต้องความต้องการ
      • การสร้างโปรเซส
      • การแทนที่เพจ
      • การจัดสรรพื้นที่สำหรับเฟรม
      • การทำแธรช
      • การทำเซ็กเม้นท์ตามความต้องการ
      • ตัวอย่างระบบปฏิบัติการ
    2. Background
      • พื้นฐาน
      • หน่วยความจำเสมือน เป็นการแบ่งหน่วยความจำเชิงตรรกของผู้ใช้ออกจาก หน่วยความจำทางกายภาพ
      • เป็นส่วนเดียวของโปรแกรมที่ต้องการเข้าไปอยู่ในหน่วยความจำ เพื่อการเอ็กซ์ซีคิวท์หรือการประมวลผล
      • พื้นที่แอดเดรสเชิงตรรก สามารถที่จะมีขนาดที่ใหญ่กว่าพื้นที่แอดเดรสทางกายภาพ
      • ยอมให้พื้นที่แอดเดรสถูกแบ่งปันการใช้งานจากหลายๆ โปรเซส
      • ยอมให้เกิดหรือสร้างโปรเซสหลายโปรเซสขึ้นได้อย่างมีประสิทธิภาพ
      • หน่วยความจำเสมือน สามารถถูกใช้ผ่าน
      • การจัดเพจตามความต้องการ
      • การทำเซ็กเม้นท์ตามความต้องการ
    3. Virtual Memory That is Larger Than Physical Memory หน่วยความจำเสมือนที่มีขนาดใหญ่กว่าหน่วยความจำทางกายภาพ
    4. Demand Paging
      • การจัดเพจแบบตามความต้องการ
      • นำเพจไปไว้ในหน่วยความจำ เมื่อมีความต้องการ ต่างๆ ดังนี้
      • มีความต้องใช้อินพุทเอ้าท์พุทน้อย
      • มีความต้องการใช้หน่วยความจำน้อย
      • มีการตอบสนองที่รวดเร็ว
      • มีผู้ใช้งานจำนวนมาก
      • มีความต้องการเพจ  โดยการอ้างอิงถึง
      • การอ้างอิงไม่ถูกต้อง  ปฏิเสธ
      • ไม่อยู่ในหน่วยความจำ  นำไปไว้ในหน่วยความจำ
    5. Transfer of a Paged Memory to Contiguous Disk Space การโอนย้ายหน่วยความจำที่ถูกจัดเพจ ไปไว้ยังพื้นที่ต่อเนื่องบนดิสก์
    6. Valid-Invalid Bit
      • บิทบ่งชี้ความถูกต้องและไม่ถูกต้อง
      • ด้วยการเข้าถึงแต่ละตารางเพจ สัมพันธ์อยู่กับบิทบ่งชี้ความถูกต้องและไม่ถูกต้อง
      • ( 1  อยู่ในหน่วยความจำ , 0  ไม่อยู่ในหน่วยความจำ )
      • ในเวลาเริ่มต้นบิทบ่งชี้ความถูกต้องและไม่ถูกต้องถูกกำหนดให้เป็น 0 สำหรับทุกๆ การเข้าถึง
      • ตัวอย่างของตารางเพจ
      • ในขณะทำการแปลงค่าแอดเดรส หากบิทบ่งชี้ฯ ในการเข้าถึงตารางเพจ มีค่าเป็น 0  ไม่สามารถเข้าถึงเพจได้ หรือเกิดการผิดพลาด
      1 1 1 1 0 0 0  Frame # valid-invalid bit page table
    7. Page Table When Some Pages Are Not in Main Memory ตารางเพจ ในขณะที่บางเพจไม่อยู่ในหน่วยความจำหลัก
    8. เพจผิดพลาด Page Fault
      • หากเกิดการอ้างอิงไปยังเพจใดๆ การอ้างอิงครั้งแรก จะแทรปไปยังระบบปฏิบัติการ  เพจผิดพลาด
      • ระบบปฏิบัติการจะพิจารณาไปยังตารางอื่นๆ เพื่อการตัดสินใจ
      • การอ้างอิงไม่ถูกต้อง  ปฏิเสธ
      • ยังไม่อยู่ในหน่วยความจำ
      • รับเฟรมว่าง
      • สลับเพจไปไว้ในเฟรม
      • กำหนดค่าตารางใหม่ บิทบ่งชี้ฯ = 1
      • ทำคำสั่งอีกครั้ง
      • auto increment/decrement location
    9. ขั้นตอนในการจัดการเพจผิด Steps in Handling a Page Fault
    10. ขั้นตอนในการจัดการเพจผิด Steps in Handling a Page Fault 1. ตรวจดูตารางข้อมูลการควบคุมโปรเซส ( PCB) ที่อ้างอิงถึงเพจที่ต้องการถูกต้องหรือไม่ 2. หากการอ้างอิงผิดพลาดให้ยกเลิก โปรเซส หากการอ้างอิงถูกต้อง แต่เพจที่ต้องการไม่มีอยู่ในหน่วยความจำหลัก ให้ไปดำเนินการขั้นต่อไป 3. หาพื้นที่ว่างในเฟรม 1 เพจ โดยอาจเลือกจากรายการแสดงแฟรมว่าง 4. ส่งรีเควสต์ไปยังฮาร์ดดิสก์ เพื่อให้ฮาร์ดดิสก์ทำการอ่านเพจที่ต้องการส่งมาไว้ยังพื้นที่ว่างในเฟรมที่เลือกไว้ก่อนหน้า 5. เมื่อดิสก์โหลดเพจเสร็จสิ้นแล้ว ระบบจะทำการแก้ไขบิตสถานะในตารางเพจ เป็น “สามารถใช้งานได้” 6. ให้โปรเซสทำงานต่อจากจุดที่เกิด “การอ้างอิงถึงเพจผิดพลาด หรือ Page Fault ” โปรเซสก็จะสามารถทำงานต่อไปเสมือนหนึ่งว่า เพจที่ต้องการใช้งานมีอยู่ในหน่วยความจำตลอดเวลา
    11. กรณีไม่มีเฟรมว่างจะเกิดอะไรขึ้น What happens if there is no free frame?
      • การจัดสรรพื้นที่ให้เพจใหม่ โดยหาเพจใดๆ ในหน่วยความจำ แต่ไม่ได้ถูกใช้งานจริง และทำการสลับมันออกไป
        • อัลกอริธึม
        • ประสิทธิภาพ ต้องการอัลกอริธึมเพื่อจัดการให้ได้ผลลัพท์ ที่มีจำนวนเพจผิดพลาดน้อยที่สุด
      • โดยเพจเดียวกันอาจถูกนำไปไว้ยังหน่วยความจำเวลาต่างๆ กัน
    12. ประสิทธิภาพของการจัดเพจตามความต้องการที่เกิดขึ้น Performance of Demand Paging
      • อัตราการเกิดเพจผิดพลาด
      • ให้ P เป็นโอกาสการเกิดความผิดพลาดการจัดเพจผิดพลาด เพื่อประสิทธิภาพที่ดีจึงต้องการให้ P มีค่าเข้าใกล้ 0 มากที่สุด ซึ่งหมายถึงเกิดความผิดพลาดน้อยที่สุด
      • ระยะเวลาการเข้าถึงหน่วยความจำ Effective Access Time (EAT)
      • EAT = (1 – p ) x memory access
      • + p (page fault overhead
      • + [swap page out ]
      • + swap page in
      • + restart overhead)
    13. ตัวอย่างการจัดเพจตามความต้องการ Demand Paging Example
      • Swap Page Time = 10 msec = 10,000 msec
      • EAT = (1 – p) x 1 + p (15000)
      • 1 + 15000P (in msec)
      • ระยะเวลาในการเข้าถึงหน่วยความจำ 1 ไมโครวินาที
      • 50 % ของระยะเวลาของเพจที่ถูกใช้ไปในการสลับเข้าออกจากพื้นที่หน่วยความจำ
      • ระยะเวลาในการสลับการทำงาน
    14. การสร้างโปรเซส Process Creation
      • Virtual memory allows other benefits during process creation:
      • - Copy-on-Write
      • - Memory-Mapped Files
      • หน่วยความจำเสมือนยอมให้เกิดการทำงานอื่นๆ ขึ้นได้ระหว่างการสร้างโปรเซส
      • ก๊อปปี้ ขณะ เขียน
      • ไฟล์ที่แมพค่าเข้ากับหน่วยความจำ
    15. COW ยอมให้ทั้งโปรเซสต้นกำเนิดและโปรเซสลูก สามารถใช้เพจร่วมกันในหน่วยความจำ หาก ทั้งสองโปรเซสเปลี่ยนแปลงเพจที่ใช้งานร่วมกัน ก็เพียงทำการสำเนาเพจนั้นไว้ก่อน COW ยอมให้การสร้างโปรเซสหลายโปรเซสได้อย่างมีประสิทธิภาพ โดยเพียงแต่แก้ไขเพจที่ถูกสำเนา เพจว่างถูกจัดสรรให้จาก พูลของเพจที่ไม่ได้ถูกใช้งาน Copy-on-Write
    16. Memory-Mapped Files
      • Memory-mapped file I/O allows file I/O to be treated as routine memory access by mapping a disk block to a page in memory.
      • A file is initially read using demand paging. A page-sized portion of the file is read from the file system into a physical page. Subsequent reads/writes to/from the file are treated as ordinary memory accesses.
      • Simplifies file access by treating file I/O through memory rather than read() write() system calls.
      • Also allows several processes to map the same file allowing the pages in memory to be shared.
    17. Memory Mapped Files
    18. Page Replacement
      • การสลับแทนที่เพจ
      • การเกิดการอ้างอิงถึงเพจที่ไม่มีอยู่ในหน่วยความจำหลัก ทำให้เกิดปัญหาการผิดพลาดการจัดเพจ โดยฮาร์ดแวร์จะทำการแจ้งไปยังระบบปฏิบัติการ โดยตรวจสอบความผิดพลาดที่เกิดขึ้นจากตารางการขัดจังหวะ จากนั้นระบบจะดำเนินการโหลดเพจที่ต้องการกลับมาไว้ยังพื้นที่ในเฟรมว่างที่จัดสรรไว้ก่อนแล้ว เพื่อการทำงานของโปรเซสที่ต้องการใช้หรือเกิดการอ้างอิงถึงเพจดังกล่าวสามารถทำงานต่อไปได้
    19. Page Replacement
      • แต่หากการโหลดเพจที่ต้องการนั้นกลับเข้ามา ระบบไม่สามารถจัดหาเฟรมว่างเพื่อรองรับเพจนั้นได้ ระบบสามารถดำเนินการด้วยวิธีต่อไปนี้
      • ให้โปรเซสที่อ้างอิงถึงเพจนั้นหยุดการทำงาน ชั่วคราวจนกว่าจะเกิดเฟรมว่างจากการคืนทรัพยากรของโปรเซสอื่นๆ แต่ด้วยวิธีนี้จะส่งผลต่อผู้ใช้งานที่สั่งให้เกิดการทำงานของโปรเซสนั้นขึ้น และทำให้ประสิทธิภาพการทำงานของระบบโดยรวมลดลง
    20. Page Replacement
      • 2. การให้โปรเซสใดๆ หยุดการทำงานชั่วคราว เพื่อสามารถนำเพจที่เกิดจากการอ้างอิงของโปรเซสใดๆ นั้นไปเก็จไว้ยังฮาร์ดดิสก์ก่อน ซึ่งจะทำให้เกิดพื้นที่ว่างหรือเฟรมว่างในหน่วยความจำหลัก และสามารถนำเฟรมว่างที่เกิดขึ้นนี้ไปให้เพจที่ต้องการเข้าใช้งานก่อน
    21. Page Replacement
      • 3. โดยวิธีที่สองนี้เรียกว่า เทคนิคการสับเปลี่ยนเพจ (Page Replacement) กล่าวคือหากในหน่วยความจำหลักไม่มีเฟรมว่างอยู่เลย อันเนื่องมาจากการใช้งานของเพจใดๆ อยู่เต็มทุกพื้นที่ เมื่อเกิดความต้องการการเข้าใช้งานเฟรม หรือต้องการเฟรมว่าง จากเพจที่เกิดขึ้นใหม่และจำเป็นต้องจัดสรรเฟรมว่างให้ใช้งานก่อน ระบบจะทำการจัดสรรเฟรมว่างด้วยการนำเพจที่มีอยู่ในหน่วยความจำหลักก่อนหน้านี้ และเกิดการใช้งานน้อยที่สุดหรือเกิดขึ้นก่อนสุด ให้ออกไปจากหน่วยความจำหลักไปไว้ยังฮาร์ดดิสก์ก่อนชั่วคราวเพื่อให้เกิดเฟรมว่างขึ้นในหน่วยความจำหลัก จากนั้นจึงนำเฟรมที่ว่างขึ้นไปให้กับเพจที่เกิดขึ้นภายหลังและจำเป็นต้องเข้าทำงานก่อนเข้าใช้ ทั้งนี้ระบบจะต้องทำการแก้ไขตารางการจัดเพจให้สถานะของเพจที่ถูกนำออกไปจากหน่วยความจำหลักนั้นมีสถานะเป็นไม่สามารถใช้งานได้เพื่อป้องกันความผิดพลาดที่อาจเกิดขึ้นจากโปรเซสที่อ้างถึงเพจนั้นด้วย
    22. Need For Page Replacement
    23. Basic Page Replacement
      • Find the location of the desired page on disk.
      • Find a free frame: - If there is a free frame, use it. - If there is no free frame, use a page replacement algorithm to select a victim frame.
      • Read the desired page into the (newly) free frame. Update the page and frame tables.
      • Restart the process.
    24. Page Replacement
    25. Page Replacement Algorithms
      • In all our examples, the reference string is
      • 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5.
      • อัลกอริธึมการสลับเพจ
      • ด้วยเทคนิคการสลับเพจมีหลากหลายวิธี โดยปกติจะเลือกใช้วิธีที่ทำให้เกิดความผิดพลาดในการอ้างอิงถึงเพจ ต่ำสุด
      • สามารถค้นหาวิธีที่ดีที่สุดได้ด้วยการทดสอบด้วยการสร้างข้อมูล เพื่อให้เกิดการเข้าใช้ และดูว่าวิธีใดเกิดการผิดพลาดน้อยครั้งที่สุด
    26. Graph of Page Faults Versus The Number of Frames
    27. First-In-First-Out (FIFO) Algorithm อัลกอริธึมแบบ มาก่อนออกก่อน
      • Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
      • 3 frames (3 pages can be in memory at a time per process)
      • 4 frames
      • FIFO Replacement – Belady’s Anomaly
        • more frames  less page faults
      1 2 3 1 2 3 4 1 2 5 3 4 9 page faults 1 2 3 1 2 3 5 1 2 4 5 10 page faults 4 4 3
    28. FIFO Page Replacement (First-In-First-Out Algorithm: FIFO) เป็นวิธีการจัดการที่ง่ายที่สุด เลือกเพจที่มีอายุอยู่ในหน่วยความจำหลักมากที่สุด เป็นเพจที่จะต้องออกไปก่อน แต่ด้วยวิธีนี้เพจที่เก็บค่าสำคัญเพื่อการทำงานหลักของระบบอาจเป็นเพจที่ถูกเลือกให้เป็นเพจที่ต้องออกจากหน่วยความจำ และเมื่อเกิดการอ้างอิงถึงเพจนั้นก็จะต้องทำการโหลดเข้ามาใหม่ หากเพจนั้นถูกอ้างอิงถึงบ่อย จะทำให้เกิดความผิดพลาดในการจัดเพจ ขึ้นบ่อยไปด้วยแม้ว่าจะสามารถโหลดเพจนั้นกลับเข้ามาใหม่ก็ตามแต่ก็จะเกิดความสูญเสียเวลาและงานขึ้น ทำให้ประสิทธิภาพของระบบลดลง ปรากฏการณ์เช่นนี้เรียกว่า ความผิดปกติ แบบเบลาดี้
    29. FIFO Illustrating Belady’s Anomaly
    30. Optimal Algorithm
      • Replace page that will not be used for longest period of time.
      • 4 frames example
      • 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
      • How do you know this?
      • Used for measuring how well your algorithm performs.
      1 2 3 4 6 page faults 4 5
    31. Optimal Page Replacement
      • อัลกอริธึมแบบประสิทธิภาพดี
      • เป็นวิธีที่สามารถลดปัญหาการเกิดความผิดพลาดการจัดเพจ และหลีกเลี่ยงปัญหาความผิดพลาดแลลเบลาดี้
      • เลือกสับเปลี่ยนเพจที่จะเกิดการอ้างอิงถึงในอนาคตอันไกลที่สุด ออกจากหน่วยความจำก่อน
      • ทำให้เกิดความผิดพลาดจากการจัดเพจขึ้นน้อยที่สุด
    32. Least Recently Used (LRU) Algorithm
      • Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
      • Counter implementation
        • Every page entry has a counter; every time page is referenced through this entry, copy the clock into the counter.
        • When a page needs to be changed, look at the counters to determine which are to change.
      1 2 3 5 4 4 3 5
    33. LRU Page Replacement
      • อัลกอริธึมแบบเพจที่เคยถูกใช้เป็นครั้งสุดท้ายนานที่สุด
      • ด้วยแบบประสิทธิภาพดีที่สุดยากต่อการเขียนโปรแกรม เนื่องจากยากที่จะทราบได้ว่าเพจใดจะถูกเรียกใช้ในอนาคตอันไกลสุด เพราะต้องเกิดจากการคาดการณ์ซึ่งยากที่จะคาดการณ์ได้
    34. LRU Algorithm (Cont.) LRU เป็นวิธีที่ให้ผลทางประสิทธิภาพใกล้เคียงกับแบบประสิทธิภาพดี มากที่สุดโดยมีแนวคิดในการจัดการคือ เมื่อเกิดความต้องการที่จะต้องสลับเพจหนึ่งเพจใดออกจากหน่วยความจำหลัก ระบบจะเลือกเพจที่เคยถูกใช้เป็นครั้งสุดท้ายที่มีระยะเวลานานที่สุด หรืออีกนัยหนึ่งคือเพจนั้นเคยถูกใช้งานล่าสุดมานานกว่าเพจใดๆ ในระบบ จึงคาดว่าระบบนั้นอาจจะไม่ถูกใช้งานหรืออีกนานกว่าจะถูกใช้งาน หรือมีความถี่ที่ถูกอ้างอิงถึงน้อยที่สุดนั่นเอง ระบบก็จะเลือกนำเพจนี้ออกไปจากหน่วยความจำหลักก่อนเพื่อเปิดโอกาสให้เกิดเฟรมว่างขึ้นในหน่วยความจำหลักและสามารถให้เพจที่เกิดขึ้นใหม่และจำเป็นต้องเข้าใช้หน่วยความจำหลักสามารถทำงานได้ ระบบจะทำการบันทึกเวลาที่แต่ละเพจถูกอ้างอิงถึง ครั้งล่าสุดไว้ เมื่อต้องการเลือกเพจใดให้ออกจากหน่วยความจำ ก็จะเลือกจากเพจที่ไม่ถูกอ้างอิงหรือใช้งานเป็นระยะเวลานานที่สุด
    35. Use Of A Stack to Record The Most Recent Page References การใช้แสต็กในการจัดการกับ อ้างอิงถึงเพจเพื่อให้เพจที่ถูกอ้างอิงถึงล่าสุดอยู่บนสุด
    36. LRU Approximation Algorithms อัลกอริธึมเลียนแบบ LRU
      • โดยอาศัยบิทอ้างอิง
        • ขณะเริ่มต้นเพจใดๆ จะถูกกำหนดให้มีบิทด้างอิงมีค่าเป็น 0
        • เมื่อเพจนั้นๆ ถูกอ้างอิงถึงบิทอ้างอิงจะถูกเปลี่ยนค่าไปเป็น 1
      • อัลกอริธึมแบบ เปิดโอกาสให้เป็นครั้งที่สอง
        • มีการอ้างอิงถึงบิทอ้างอิง
        • มีการสลับเวลา
        • เมื่อเพจถูกโหลดกลับเข้ามาใว้ในหน่วยความจำอีกครั้ง จากการกำหนดของเวลา และบิทอ้างอิงมีค่าเป็น 1 แล้วให้ดำเนินการ
          • กำหนดค่าบิทอ้างอิงให้เป็น 0
          • นำเพจออกจากหน่วยความจำ
          • นำเพจถัดไปมาไว้ในหน่วยความจำ ด้วยเงื่อนไขเช่นเดียวกัน
    37. Second-Chance (clock) Page-Replacement Algorithm
    38. Counting Algorithms อัลกอริธึมการนับ
      • ใช้ตัวนับจำนวนในการอ้างอิงถึงแต่ละเพจ
      • อัลกอริธึมแบบ LFU จะเลือกเพจที่ต้องถูกนำออกจาหน่วยความจำจากการนับที่มีค่าน้อยที่สุด
      • อัลกอริธึมแบบ MFU จะเลือกเพจที่มีการอ้างอิงถึงมากออกก่อน จากแนวคิดที่ว่าเพจที่มีการอ้างอิงถึงน้อยเป็นเพจที่เพิ่งเกิดใหม่ ส่วนเพจที่ถูกอ้างอิงถึงบ่อยเป็นเพจที่เกิดขึ้นมานานแล้ว
    39. Allocation of Frames
      • Each process needs minimum number of pages.
      • Example: IBM 370 – 6 pages to handle SS MOVE instruction:
        • instruction is 6 bytes, might span 2 pages.
        • 2 pages to handle from .
        • 2 pages to handle to .
      • Two major allocation schemes.
        • fixed allocation
        • priority allocation
    40. Fixed Allocation
      • Equal allocation – e.g., if 100 frames and 5 processes, give each 20 pages.
      • Proportional allocation – Allocate according to the size of process.
    41. Priority Allocation
      • Use a proportional allocation scheme using priorities rather than size.
      • If process P i generates a page fault,
        • select for replacement one of its frames.
        • select for replacement a frame from a process with lower priority number.
    42. Global vs. Local Allocation
      • Global replacement – process selects a replacement frame from the set of all frames; one process can take a frame from another.
      • Local replacement – each process selects from only its own set of allocated frames.
    43. Thrashing
      • If a process does not have “enough” pages, the page-fault rate is very high. This leads to:
        • low CPU utilization.
        • operating system thinks that it needs to increase the degree of multiprogramming.
        • another process added to the system.
      • Thrashing  a process is busy swapping pages in and out.
    44. Thrashing
      • Why does paging work? Locality model
        • Process migrates from one locality to another.
        • Localities may overlap.
      • Why does thrashing occur?  size of locality > total memory size
    45. Locality In A Memory-Reference Pattern
    46. Working-Set Model
      •   working-set window  a fixed number of page references Example: 10,000 instruction
      • WSS i (working set of Process P i ) = total number of pages referenced in the most recent  (varies in time)
        • if  too small will not encompass entire locality.
        • if  too large will encompass several localities.
        • if  =   will encompass entire program.
      • D =  WSS i  total demand frames
      • if D > m  Thrashing
      • Policy if D > m, then suspend one of the processes.
    47. Working-set model
    48. Keeping Track of the Working Set
      • Approximate with interval timer + a reference bit
      • Example:  = 10,000
        • Timer interrupts after every 5000 time units.
        • Keep in memory 2 bits for each page.
        • Whenever a timer interrupts copy and sets the values of all reference bits to 0.
        • If one of the bits in memory = 1  page in working set.
      • Why is this not completely accurate?
      • Improvement = 10 bits and interrupt every 1000 time units.
    49. Page-Fault Frequency Scheme
      • Establish “acceptable” page-fault rate.
        • If actual rate too low, process loses frame.
        • If actual rate too high, process gains frame.
    50. Other Considerations
      • Prepaging
      • Page size selection
        • fragmentation
        • table size
        • I/O overhead
        • locality
    51. Other Considerations (Cont.)
      • TLB Reach - The amount of memory accessible from the TLB.
      • TLB Reach = (TLB Size) X (Page Size)
      • Ideally, the working set of each process is stored in the TLB. Otherwise there is a high degree of page faults.
    52. Increasing the Size of the TLB
      • Increase the Page Size . This may lead to an increase in fragmentation as not all applications require a large page size.
      • Provide Multiple Page Sizes . This allows applications that require larger page sizes the opportunity to use them without an increase in fragmentation.
    53. Other Considerations (Cont.)
      • Program structure
        • int A[][] = new int[1024][1024];
        • Each row is stored in one page
        • Program 1 for (j = 0; j < A.length; j++) for (i = 0; i < A.length; i++) A[i,j] = 0; 1024 x 1024 page faults
        • Program 2 for (i = 0; i < A.length; i++) for (j = 0; j < A.length; j++) A[i,j] = 0;
        • 1024 page faults
    54. Other Considerations (Cont.)
      • I/O Interlock – Pages must sometimes be locked into memory.
      • Consider I/O. Pages that are used for copying a file from a device must be locked from being selected for eviction by a page replacement algorithm.
    55. Reason Why Frames Used For I/O Must Be In Memory
    56. Demand Segmentation
      • Used when insufficient hardware to implement demand paging.
      • OS/2 allocates memory in segments, which it keeps track of through segment descriptors
      • Segment descriptor contains a valid bit to indicate whether the segment is currently in memory.
        • If segment is in main memory, access continues,
        • If not in memory, segment fault.
    57. Operating System Examples
      • Windows NT
      • Solaris 2
    58. Windows NT
      • Uses demand paging with clustering . Clustering brings in pages surrounding the faulting page.
      • Processes are assigned working set minimum and working set maximum .
      • Working set minimum is the minimum number of pages the process is guaranteed to have in memory.
      • A process may be assigned as many pages up to its working set maximum.
      • When the amount of free memory in the system falls below a threshold, automatic working set trimming is performed to restore the amount of free memory.
      • Working set trimming removes pages from processes that have pages in excess of their working set minimum.
    59. Solaris 2
      • Maintains a list of free pages to assign faulting processes.
      • Lotsfree – threshold parameter to begin paging.
      • Paging is performed by pageout process.
      • Pageout scans pages using modified clock algorithm.
      • Scanrate is the rate at which pages are scanned. This ranged from slowscan to fastscan .
      • Pageout is called more frequently depending upon the amount of free memory available.
    60. Solaris 2 Page Scanner
    61. Fig 10.03
    62. Fig. 10.2

    + Nuttha OtanasapNuttha Otanasap, 6 months ago

    custom

    1188 views, 0 favs, 2 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1188
      • 1178 on SlideShare
      • 10 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds
    • 9 views on http://learning.sau.ac.th
    • 1 views on http://static.slidesharecdn.com

    more

    All embeds
    • 9 views on http://learning.sau.ac.th
    • 1 views on http://static.slidesharecdn.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories