« PreviousContinue »
(i9) United States
(12) Patent Application Publication
Li et al.
(io) Pub. No.: US 2008/0282111 Al (43) Pub. Date: Nov. 13, 2008
(54) WORKER THREAD CORRUPTION DETECTION AND REMEDIATION
(75) Inventors: Eric Li, Redmond, WA (US);
Dragos C. Sambotin, Issaquah, WA
ONE MICROSOFT WAY
REDMOND, WA 98052 (US)
(73) Assignee: Microsoft Corporation, Redmond, WA(US)
(21) Appl.No.: 11/801,309
(22) Filed: May 9, 2007
(51) Int. CI.
(52) U.S. CI 714/38
A thread has a corruption detection mechanism that compares a beginning state of a function with an ending state to determine any inconsistencies. Based on the type of inconsistency, a remedial action may be taken, such as ignoring the inconsistency, cleaning up the inconsistency, and terminating the thread with an exception. The analysis may also include analyzing various states after function execution to find problems such as incomplete transactions. Such a thread may be useful in an operating system as well as a multi-threaded application environment.
Patent Application Publication Nov. 13, 2008 Sheet 1 of 2 US 2008/0282111 Al
Patent Application Publication Nov. 13, 2008 Sheet 2 of 2 US 2008/0282111 Al
WORKER THREAD CORRUPTION
DETECTION AND REMEDIATION
 Worker threads may be used to execute functions from several services, applications, or other sources in an operating system or multi-threaded programming environment. The functions executed by a worker thread may come from several different sources and perform widely varying tasks.
 Many functions, especially in an operating system, may operate using different priorities, assume different impersonations, or operate in different activation contexts. If a function terminates improperly or as a result of sloppy programming, such states may be improperly reset, which may cause various problems, including race conditions, deadlocks, livelocks, starvation, or other problems.
 A thread has a corruption detection mechanism that compares a beginning state of a function with an ending state to determine any inconsistencies. Based on the type of inconsistency, a remedial action may be taken, such as ignoring the inconsistency, cleaning up the inconsistency, and terminating the thread with an exception. The analysis may also include analyzing various states after function execution to find problems such as incomplete transactions. Such a thread may be useful in an operating system as well as a multi-threaded application environment.
 This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
BRIEF DESCRIPTION OF THE DRAWINGS  In the drawings,
 FIG. 1 is a diagram of an embodiment showing a worker thread system.
 FIG. 2 is a flowchart illustration of an embodiment showing a method for operating a worker thread.
 A worker thread uses several tools to ensure that functions execute in the proper environment and generate a history of events for the thread. Several variables are evaluated by comparing a pre-execution snapshot of certain memory locations with the values after execution. Additional post-execution values may be examined to determine if the function left an improper state after executing.  An analysis of an inconsistency may lead to several different resolution or remediation actions, including ignoring the inconsistency, reverting the inconsistency to a preexecution state, raising an exception, and terminating the thread, process, application, or system. A log of such inconsistencies may be kept for debugging or other uses.  In some embodiments, the analysis, remediation, and logging functions may be different for debugging, code development, or general runtime operations. Different remediation and logging policies may be defined for various operational states.
 The worker thread may execute functions from various services at an operating system level. In some embodiments, such a worker thread may be used for multi-threaded applications programming environments as well.  Specific embodiments of the subject matter are used to illustrate specific inventive aspects. The embodiments are by way of example only, and are susceptible to various modifications and alternative forms. The appended claims are intended to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the invention as defined by the claims.
 Throughout this specification, like reference numbers signify the same elements throughout the description of the figures.
 When elements are referred to as being "connected" or "coupled," the elements can be directly connected or coupled together or one or more intervening elements may also be present. In contrast, when elements are referred to as being "directly connected" or "directly coupled," there are no intervening elements present.
 The subject matter may be embodied as devices, systems, methods, and/or computer program products. Accordingly, some or all of the subject matter may be embodied in hardware and/or in software (including firmware, resident software, micro-code, state machines, gate arrays, etc.) Furthermore, the subject matter may take the form of a computer program product on a computer-usable or computerreadable storage medium having computer-usable or computer-readable program code embodied in the medium for use by or in connection with an instruction execution system. In the context of this document, a computer-usable or computerreadable medium may be any medium that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
 The computer-usable or computer-readable medium may be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, device, or propagation medium. By way of example, and not limitation, computer readable media may comprise computer storage media and communication media.
 Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by an instruction execution system. Note that the computer-usable or computer-readable medium could be paper or another suitable medium upon which the program is printed, as the program canbe electronically captured, via, for instance, optical scanning of the paper or other medium, then compiled, interpreted, of otherwise processed in a suitable manner, if necessary, and then stored in a computer memory.
 Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information