1 / 16

SNU FMS 99 개요

SNU FMS 99 개요. SNU OOPSLA Lab. 조교 : 장문성. 구조. Application. toy application. File Manager. B+ tree (insert/retrieve/remove). Buffer Manager. buffering (lock / unlock). Disk Manager. basic file access (read/write). 제출 / 검사 방법. 제출 POSIX 시스템 콜만을 사용하는 ANSI-C++

cachez
Télécharger la présentation

SNU FMS 99 개요

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. SNU FMS 99 개요 SNU OOPSLA Lab. 조교 : 장문성

  2. 구조 Application toy application File Manager B+ tree (insert/retrieve/remove) Buffer Manager buffering (lock / unlock) Disk Manager basic file access (read/write)

  3. 제출 / 검사 방법 • 제출 • POSIX 시스템 콜만을 사용하는 ANSI-C++ • 하나의 cpp 파일 (이진 파일, makefile 불필요) • 검사 방법 • main() : 조교가 게시한 테스트 베드 사용 • 하위 모듈 : 임의 추출한 샘플 모듈 사용 • 제출자의 cpp 파일을 이들과 함께 컴파일/링크하여 수행

  4. Interface • interface • 특정 객체와 통신하기 위한 수단 • 이 프로젝트에서는 모듈이 제공하는 표준화된 함수 집합 • 이 프로젝트에서는 다른 계층의 모듈과 통신하기 위해서 사용

  5. Interface (cont’d) • 정의 struct IDisk { virtual void Read( char*, long sector ) = 0; virtual void Write( const char*, long sector ) = 0; }; • 사용예 (조교의 main.cpp) IDisk* pDisk = CreateDisk(); pDisk->Read( buf1, 1000 ); pDisk->Write( buf2, 1001 ); ...

  6. Interface (cont’d) • 구현 예 (제출된 cpp 파일) class CDisk : public IDisk { virtual void Read(…) { … } virtual void Write(…) { … } }; IDisk* CreateDisk() { return new CDisk; }

  7. Part I - Disk Manager • IRawFile 인터페이스 • Open/Close • IFile 인터페이스 (IRawFile 에서 계승) • Read/Write/Allocate/Deallocate • 제출물 • IFile* GetDiskManager() 함수의 구현

  8. Part I - cont’d • Allocation / Deallocation 의 구현 • bitmap • av-list (in this project) • 유의 사항 • 블록 크기는 고정 길이1024 바이트 • 슈퍼 블록(블록 #0)에는 av-list 헤더 정보와 파일 크기 정보등이 기록되어야 함 • 파일 크기를 증가시키는 시스템 콜은 lseek

  9. Part II - Buffer Manager • IBuffer 인터페이스 (IRawFile에서 계승) • Lock/Unlock • GetDiskManager()로 생성한 디스크 매니저의 IFile 인터페이스를 사용 • 제출물 • IBuffer* GetBufferManager() • 이 함수는 내부적으로 GetDiskManager() 를 호출해서 DiskManager 객체를 얻음

  10. Part II - cont’d • Lock • 레코드 번호로 해당 레코드 데이터 내용에 접근할 수 있게 하는 함수 • 메모리에 해당 레코드가 없으면 버퍼 매니저는 빈 버퍼에 레코드를 로드하고 이 버퍼의 주소를 리턴 • 빈 버퍼가 없으면 기존의 버퍼중 가장 오래전에 접근된 버퍼를 flush한 후 이 버퍼의 주소를 리턴 (LRU) • Lock 된 버퍼는 flush 할 수 없음

  11. Part II - cont’d • Unock • Lock 된 메모리를 해제함 • Unlock 된 메모리는 디스크로 flush되거나나중을 위해 메모리에 남아 있을 수 있음 • Dirty한 데이터는 flush할 때 write-back • Unlock 되는 순간 LRU 접근 시간 갱신 • Lock Counter • 한 블록에 Lock된 회수만큼 Unlock을 해야 비로소 Unlock이 됨 → Lock Counter 유지

  12. Part II - cont’d • Lock/Unlock 예제 void* pBuff; pBuffer->Lock( &pBuff, 10 /*BLOCKNUM*/ ); … pBuffer->Unlock( 10 /*BLOCKNUM*/ ); • 잘못된 예 char* pBuff2 = new char[BLOCKSIZE]; memcpy( pBuff2, pBuff, BLOCKSIZE );

  13. Part III - File Manager • IFMS 인터페이스 (IRawFile에서 계승) • Insert/Remove/Retrieve/RetrieveRange • 키 크기 : 16 byte, 레코드 크기 : 64 byte • B+ 트리 구현 ( 추후 추가 설명 ) • 제출물 • IFMS* GetFMS() • 이 함수는 내부적으로 GetBufferManager() 를 호출해서 BufferManager 객체를 얻음

  14. Closing • IRawFile::Close() 에서 하는 일 • 파일 등 열려 있는 자원을 닫음 • 모든 Buffer 를 Flush 함 • 학번과 접근 통계를 출력 • 하위 레벨 모듈의 Close() 함수 호출 • 자신을 삭제함 ( delete this; )

  15. Closing - cont’d • 통계 출력 • 디스크 매니저 : 디스크 접근 회수 (r/w별)등 • 버퍼 매니저 : 버퍼 교체 회수 • 파일 매니저 : Insert/Retrieve/Remove시 각각의 평균 버퍼 접근 회수

  16. 기술적 힌트 • http://wwwoopsla/classes/filestruct/project • in WIN32 • #include <io.h> • open option : _O_BINARY, _O_RANDOM • 이름 충돌 문제 • namespace or static • 화면 출력 • printf(“…\n”); • cout << … << endl; cout << … << flush;

More Related