1 / 30

Buffer Cache

Buffer Cache. 내 용. 개념 Why Needs ? Dat structure Algorithms Getblk(), brease(), bread(), breada(), bwrite(). Buffer Cache 의 개념. File system 과 Hard Disk 관계 overview 그림 참조 Contains the data in recently used disk blocks Software structure, not hardware cache. Buffer Cache 를 사용하는 이유.

Télécharger la présentation

Buffer Cache

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. Buffer Cache 선문대학교 컴퓨터정보학부

  2. 내 용 • 개념 • Why Needs ? • Dat structure • Algorithms • Getblk(), brease(), bread(), breada(), bwrite() 선문대학교 컴퓨터정보학부

  3. Buffer Cache의 개념 • File system과 Hard Disk 관계 • overview 그림 참조 • Contains the data in recently used disk blocks • Software structure, not hardware cache 선문대학교 컴퓨터정보학부

  4. Buffer Cache를 사용하는 이유 • Disk access 횟수를 최소화 한다. • Minimize response time • Maximize thruput for disk read/write • Pre_cached data • breada • Delayed write data 선문대학교 컴퓨터정보학부

  5. Buffer • A number of buffers • allocated space by kernel • configurable parameter • A buffer • a buffer header + a memory array • a logical disk block of a file system • in memory copy of the disk block • one buffer = one disk block 선문대학교 컴퓨터정보학부

  6. Buffer Header(1) • Figure 3-1 • A device number field • logical file system number • not physical device unit number • A block number field • A pointer to a array for the buffer 선문대학교 컴퓨터정보학부

  7. Buffer Header(2) • Status of a buffer • locked/unlocked(busy/free) • delayed write • reading/writing • waiting for the buffer to become free 선문대학교 컴퓨터정보학부

  8. Structure of the Buffer Pool • Figure 3-2 • LRU • 최근에 free 된 것을 free list의 뒤에 배치한다. • A free list of buffers • Hashed queue • doubly linked list • the number of hash queue • hash function • uniformly distributed in each hash queue • 하나의 버퍼는 항상 해쉬 큐에 존재하지만, free list에는 존재하지 않을 수도 있다. 선문대학교 컴퓨터정보학부

  9. ReadDisk Block BufCache Read Block 15 Rblock 180 15 Rblock 300 15 300 Queue Head 15 180 300 180 180 300 선문대학교 컴퓨터정보학부

  10. Find Disk Block BufCache 15 Find 300 15 300 300 300 Queue Head 15 15 180 180 300 300 180 180 300 선문대학교 컴퓨터정보학부

  11. Algorithm for Free Buffer Management • getblk() • brelese() • Algorithm for buffer allocation must be safe • do not control user mode • process must not sleep forever • eventually get a buffer • 예외  disk driver corruption • starvation(indefinite postponement) • Theoretically, possible • Practically, not a problem 선문대학교 컴퓨터정보학부

  12. Device num Block num status Ptr to data ares Ptr to next buf on hash queue Ptr to previous buf On bash queue Ptr to next buf On free list Ptr to previous buf On free list 선문대학교 컴퓨터정보학부

  13. Forward ptrs Forward ptrs Free list head Buf 2 Buf 2 Buf n Free list head Buf 1 Buf n Back ptrs Back ptrs before after 선문대학교 컴퓨터정보학부

  14. Five Typical Scenarios on Buffer Allocation 1) 해당 블록이 해쉬 큐에 있고, 버퍼가 free인 경우. 2)해당 블록이 해쉬 큐에 없고, 버퍼를 free list에서 할당하는 경우. 3) 2)의 경우에 버퍼가 delayed write인 경우 4) 2)의 경우에 free list가 empty인 경우 5) 해당 블록이 해쉬 큐에 있지만 버퍼가 busy인 경우 선문대학교 컴퓨터정보학부

  15. Case 1) a 선문대학교 컴퓨터정보학부

  16. Case 1) b 선문대학교 컴퓨터정보학부

  17. Case 2) a 선문대학교 컴퓨터정보학부

  18. Case 2) b 선문대학교 컴퓨터정보학부

  19. Case 3) a 선문대학교 컴퓨터정보학부

  20. Case 3) b 선문대학교 컴퓨터정보학부

  21. Case 4) 선문대학교 컴퓨터정보학부

  22. Case 5) 선문대학교 컴퓨터정보학부

  23. Reading Disk Block • from disk block to buffer cache • bread() • Fig 3-13 • using getblk • from disk to buffer • block이 buffer cache안에 있으면, return. • 없으면 “page fault” • call disk driver • “schedule” a read request • sleep until I/O completion • return 선문대학교 컴퓨터정보학부

  24. bread() • anticipatory paging • Fig 3-14 • anticipate the need for a second disk block • improving performance • first block은 immediate read • second block은 asynchronous read 선문대학교 컴퓨터정보학부

  25. Writing Disk Block • From buffer cache to disk block • bwrite • disk에 쓰고자 하는 buffer를 disk driver에게 알린다 • synchronous • asynchronous • start disk operation immediately • not wait for its completion • delayed write • put off the physical write 선문대학교 컴퓨터정보학부

  26. Buffer Cache의 장점 • Disk access에 관하여 modular approach가 가능 • Data alignment에 관한 제약이 user space로 부터 제거됨 • Disk traffic 감소 기능 선문대학교 컴퓨터정보학부

  27. Buffer Cache의 단점 • Vulnerable to crash • data inconsistency problem between buffer and disk block • require an extra data copy from buffer to user space 선문대학교 컴퓨터정보학부

  28. User programs libraries User Level trap System Call Interface File subsystem Process Control Subsystem Inter-process communication scheduler Kernel Level Buffer cache Memory management Character block Device drivers Hardware Interface Hard ware < Block Diagram of the system kernel > Hardware Level 선문대학교 컴퓨터정보학부

  29. < process & subsystem > < File subsystem > Proc table < upper > File Table Inode table Inode 1 . Inode 0 (64 byte) U block . Inode 15 Buffer Cache (Pool) On Disk User file Descriptor Table Data super inode Boot block list block block Block 0 Buffer 0 < lower > Hash gueue Buffer Header device Buffer 1 Block 1 . . . . . B l o c k 2 Buffer 2 Block n . . . . Block n+1 - File system overview - . . Buffer N Free list header J block = jK 선문대학교 컴퓨터정보학부

  30. File System calls Lower level File System algorlthms Buffer allocation algorithms 선문대학교 컴퓨터정보학부

More Related