1 / 45

Computer Science Overview Chapter Three-Operation System (3)

Computer Science Overview Chapter Three-Operation System (3). JainShing Wu. Virtual Memory. Lack of memory For multi-tasking Paging. Virtual Memory. Provides application a full continuous memory but actual fragments

meda
Télécharger la présentation

Computer Science Overview Chapter Three-Operation System (3)

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. Computer Science OverviewChapter Three-Operation System (3) JainShing Wu

  2. Virtual Memory • Lack of memory • For multi-tasking • Paging

  3. Virtual Memory • Provides application a full continuous memory but actual fragments • Using secondary memory (disk) to provide more memory space for more processes

  4. Virtual Memory

  5. Page Table • Transfer virtual address into physical address • Every process has one page table • Consists of • Resident bit • Records the page in main memory or not • Page fault • Page at the storage address in Disk • The frame number that page is loaded in

  6. Page Table • Problem • Large amount of tables • Thrashing • High paging activity (load, process, remove) • CPU overhead (for handling page interrupt) • Necessary page hardware

  7. Page Fault • Occur when the required page not in the memory • Handling page fault SOP • Service the page-fault interrupt • Read in the required page from secondary memory (disk) • If not found => terminate the process • If found=> select a page to replace • Replace page algorithm • Resume the process

  8. Page Replacement Algorithm • FIFO • Optimality • Least Recently Used (LRU)

  9. First In First Out • New page replaces the first page that is loaded to memory in a circular buffer • Advantage • Simplest • Disadvantage • Performance is not always good • Belady's Anomaly

  10. First In First Out Ref string page 17 page faults

  11. Belady's Anomaly • Increase the page table size, but cause higher page faults

  12. Belady's Anomaly Ref string page 17 page faults Ref string page 14 page faults

  13. Belady's Anomaly Ref string page 15 page faults

  14. Optimality • Selects for replacement that page for which the time period to the next reference is the longest • Has the lowest page fault rate of all algorithm • Difficult to implement because of requiring the OS to have future knowledge of the reference string

  15. Optimality Ref string page 7page faults

  16. Least Recently Used • Replaces the page in memory that has not been referenced for the longest time • May require substantial hardware assistance • Two implementation are feasible to determine the order for the frames defined by the time of last use

  17. Least Recently Used Ref string page 12page faults

  18. Dead Lock • When two processes hold the resource that are the required resource of each other • Circular wait • No preemptive

  19. Dead Lock • EX: A room with a door that requires two keys, key1 and key2 to open • The one that first leaves the room wins $10000, and the second one wins $5000 • No kill !

  20. Dead Lock • There are two persons A and B. Both A and B want to leave this rooms • A holds key1, and B holds key2 • A waits B to release the key2 and B waits A to release the key1

  21. Dead Lock Handling • Abort all deadlock process • Back up each dead lock process to some previously defined checkpoint and restart all processes (Rollback) • Successively abort dead lock processes until deadlock no longer exits • Successively preempt resources until deadlock no longer exits

  22. Storage Management • Disk structure • Disk scheduling • Disk management • Swap space mangement

  23. Disk Structure • Information on the disk is referenced by a multiple address • Drive number, • Surface (cylinder) • Track • Sector • Sector is the smallest unit of information that can be read from or write to the disk

  24. Disk Structure • I/O transfer between memory and disk are performed in units of one or more sectors called blocks to improve I/O efficiency

  25. Disk Scheduling • Before sending system call to OS to perform disk I/O, the information • Input or output • Disk address (C/T/S) • The memory address that Load to /read from • How many bytes to transfer

  26. Disk Scheduling • Disk scheduling algorithm • FCFS • SSTF • SCAN • C-SCAN • Look scheduling

  27. First Come First Served • Process track items from the queue in sequential order • Advantage • Easy to program • Intrinsically fair • Disadvantage • Performance low

  28. First Come First Served • The header is parked at track 0 • Disk I/O sequence: 30,50,20,70,40 • The total movement: • (30-0)+(50-30)+(50-20)+(70-20)+(70-40)=130 30 50 20 70 40 Track 100 Track 0

  29. Shortest Seek Time First • Selects the request with minimum seek time from the current head position • High use, small queues • Like SJK scheduling, it may cause starvation of some requests

  30. Shortest Seek Time First • The header is parked at track 0 • Disk I/O sequence: 30,50,20,70,40 • The total movement: • (20-0)+(30-20)+(40-30)+(50-40)+(70-50)=70 20 30 40 50 70 Track 100 Track 0

  31. Scan Scheduling • The read-write head starts at one end of the disk • Move toward the other end • Servicing requests as it reaches each tack until it hit the other end of the disk • Better service distribution • Also called elevator scheduling

  32. Scan Scheduling 30 • The header is parked at track 30 • Disk I/O sequence: 30,50,20,70,40 • The total movement: • (30-0)+(20-0)+(30-20)+(40-30)+(50-40)+(70-50)=100 20 30 40 50 70 Track 100 Track 0

  33. C-Scan Scheduling • A variant of Scan scheduling • Designed to provide more uniform waiting time • Moves the head from one end to the other disk end and servicing the requests as it goes • Lower service variability

  34. C-Scan Scheduling 30 • The header is parked at track 30 • Disk I/O sequence: 30,50,20,70,40 • The total movement: • (30-0)+(100-70)+(70-50)+(50-40)+(40-30)+(30-20)=110 70 50 40 30 20 Track 100 Track 0

  35. Look Scheduling • More Commonly, the head is only moved as far as the last request in each direction • As soon as there are no request in the current direction, the movement is reversed • Service guarantee & load sensitive

  36. Look Scheduling 20 30 • The header is parked at track 30 • Disk I/O sequence: 30,50,20,70,40 • The total movement: • (30-20)+(30-20)+(40-30)+(50-40)+(70-50)=60 30 40 50 70 Track 100 Track 0

  37. Security • Data protection • Virus • Internet attack

  38. Data Protection • File Lock • Lock the files/directories and only the owner can open • File attributes • Read/Write/Execute (Unix like system) • Read only/File sharing (Windows system) • Data transfer protection • 加密 • Public key and private key • RSA

  39. Virus • First designed for copy wright protection • Behavior • Destroy the systems • Hacking the system • Obtain the personal private information • Obtain the control of the system • Virus Buster

  40. Internet Attack • Attack type • Deny of Service (DOS attack) • Intersection • Hacking • Net fishing • Firewall

  41. Password Policy • As long as possible • As hard to rememberas possible • Add more numbers in the password as possible • One password for one week • EX: • s5h6i7n8g • el vm/6284vm,6

  42. Question?

  43. Homework • Q1: If there are 10 jobs (job1, job 2, …, job 10) with working time {5, 1, 15, 2, 3 , 7, 11, 7, 9, 6}, Please specify the job finished order and the finial finish time using the following scheduling (a) SJF (b) Round-robin (c) FCFS

  44. Homework • If there is a page reference string • Please use the FIFO, Optimality, and LRU page replacement algorithms to replace the page and specify the page faults of three algorithms Ref string page

  45. Homework • Q3: Disk scheduling • The disk is from track 0 to track 100 • The header is parked at track 20 • The Disk I/O sequence: 10, 50, 15, 25, 75, 60, 70, 5, 30, 40 • Please use the following scheduling to show the process and the total movements • (a) FCFS (b) SSTF (d) Scan (d) Look

More Related