160 likes | 331 Views
Ch 3. Kernel-Mode I/O Processing. Contents. 커널모드의 코드 수행 인터럽트 Priority Deferred Procedure Calls(DPCs) Access to User Buffers Structure of a Kernel-Mode Driver I/O Processing Sequence Summary. How Kernel-Mode Code Executes. CPU Context Trap or Exception Context
E N D
Contents • 커널모드의 코드 수행 • 인터럽트 Priority • Deferred Procedure Calls(DPCs) • Access to User Buffers • Structure of a Kernel-Mode Driver • I/O Processing Sequence • Summary Ch 3. Kernel-Mode I/O Processing
How Kernel-Mode Code Executes • CPU Context • Trap or Exception Context • User mode -> Kernel Mode (System Call) • Direct I/O요청 시 I/O Manager의 Dispatch routine • Interrupt Context • Interrupt 발생시 • Kernel-Mode Thread Context • Device polling or Time out Ch 3. Kernel-Mode I/O Processing
Use of Interrupt Priorities by Windows 2000 • CPU Priority level • Interrupt Request Level (IRQL) • Priority를 정의하는 숫자 • Interrupt Processing Sequence • 현재 명령의 수행 중지 • 상태정보 저장 • 현재 CPU의 IRQL을 요청된 IRQL값과 같게 함 • 적절한 Interrupt service routine 수행 • Software-generated Interrupt Ch 3. Kernel-Mode I/O Processing
System DPC Queue DIRQL Schedules DPC Object DPC 1 Interrupt Service Routine DPC 2 … DPC Software Interrupt DPC 3 DPC객체를 꺼내옴 DPC Routine 1 DPC Dispatcher DPC Routine n DPC Routine 2 꺼내온 DPC객체의 DPCRoutine을 호출 … Deferred Procedure Calls (DPCs) • DPC의 동작 • 높은 IRQL작업을 지연 수행을 함 Ch 3. Kernel-Mode I/O Processing
Deferred Procedure Calls (DPCs) • DPC의 특성 • 오직 한 개의 DPC객체의 인스턴스가 존재해야 함 • DPC큐에 이미 존재하는 DPC객체를 중복으로 Schedule 불가 • DPC요청에 대한 카운트를 유지 or 개별적인 큐의 구현 • Multiprocessor 상에서 작업의 동기화 • 병렬적인 processor의 interrupt routine Ch 3. Kernel-Mode I/O Processing
Access to User Buffers • Buffer Access Mechanisms • I/O manager에게 User buffer를 RAM에 복사 요청 (Buffered I/O) • RAM의 내용을 Write하거나 I/O를 통한 Read내용을 저장시킴 • Driver가 User buffer를 직접 접근 (Direct I/O) • I/O Manager : User buffer 에 Lock 을 설정함 Ch 3. Kernel-Mode I/O Processing
Structure of a Kernel-Mode Driver • I/O Manager의 Driver routine 호출 시점 • Driver load • Driver Unload or System shutting sown • Device insert or remove • User-Mode에서의 I/O요청 (System Call) • 공유 hardware resource의 사용 가능 시점 • 실제 Device가 동작시 여러 상황 Ch 3. Kernel-Mode I/O Processing
Structure of a Kernel-Mode Driver • Driver Initialization and Cleanup Routine • Driver Entry routine • Driver load시, 자원할당-조정-수락 • Reinitialize routine • 부팅 시 초기화가 불가능한 Driver의 초기화 • Unload routine • Driver의 동적 Unload • Shutdown routine • System 종료 • Bug-check Call-Back routine • System Crash발생시 Ch 3. Kernel-Mode I/O Processing
Structure of a Kernel-Mode Driver • I/O System Service Dispatch Routine • I/O Manager가 I/O요청에 알맞은 Driver와 routine을 찾음 • Open and Close Operation • File • Device Operation • Device Ch 3. Kernel-Mode I/O Processing
Structure of a Kernel-Mode Driver • Data Transfer Routine • Start I/O routine • Device의 데이터 전송 • Interrupt Service Routine (ISR) • Interrupt 생성 • DPC routine • Device 동작의 완료 Ch 3. Kernel-Mode I/O Processing
Structure of a Kernel-Mode Driver • Resource Synchronization Callback • 자원 공유시 동기화 (Kernel-Mode) • Controller Control routine • Controller Register 공유 • Adapter Control routine • DMA Hardware (DMAC) 공유 • Synchronize Critical Section routine • 공유 버퍼 or 자원 Ch 3. Kernel-Mode I/O Processing
Structure of a Kernel-Mode Driver • Other Driver Routine • Timer routine • I/O completion routine • Cancel I/O routine Ch 3. Kernel-Mode I/O Processing
I/O Processing Sequence I/O Request from User-Mode Driver – Start I/O Device Start and Interrupt Service Preprocessing by I/O Manager Win32 Subsystem Driver - ISR Postprocessing by the Driver I/O Manager Driver - DPC Preprocessing by Device Driver IRP Passed Postprocessing by the I/O Manager Driver-Dispatch I/O Manager Ch 3. Kernel-Mode I/O Processing
Summary • Windows 2000 의 SubSystem • Device Driver Architecture • I/O Processing Sequence Ch 3. Kernel-Mode I/O Processing