Understanding Scheduling, Thread Context, and IRQL -- 18
Scheduling, Thread Context, and IRQL
ThángTư11,2012
Abstract
This paper presents information about how thread scheduling, thread context, and a processor’s current interrupt request level (IRQL) affect the operation of kernel - mode drivers for the Microsoftđ Windowsđ family of operating systems. It is intended to provide driver writers with a greater understanding of the environment in which their code runs.
A companion paper, “Locks, Deadlocks, and Synchronization” at http://www. microsoft. com/whdc/hwdev/driver/LOCKS. mspx, builds on these fundamental concepts to address synchronization issues in drivers.
Contents
Introduction 2
Thread Scheduling 2
Thread Context and Driver Routines 3
Driver Threads 4
Interrupt Request Levels 5
Processor - specific and Thread - specificIRQLs 6
IRQL PASSIVE_ LEVEL 7
IRQL PASSIVE_ LEVEL in a critical region 7
IRQL APC_ LEVEL 7
IRQL DISPATCH_ LEVEL 8
IRQL DIRQL 9
IRQL HIGH_ LEVEL 10
Guidelines for Running at IRQL DISPATCH_ LEVEL or Higher 10
Changing the IRQL at which Driver Code Runs 11
Standard Driver Routines, IRQL, and Thread Context 12
Interrupting a Thread: Examples 14
Single - Processor Example 15
Multiprocessor Example 16
Testing for IRQL Problems 17
Techniques for Finding the Current IRQL 17
PAGED_ CODE Macro 17
Driver Verifier Options 17
Best Practices for Drivers 18
Call to Action and Resources 18
Disclaimer
This is a preliminary document and may be changed substantially prior to final commercial release of the software described herein.
The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication.
This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.
â 2004 Microsoft Corporation. All rights reserved.