news 2026/5/12 6:07:20

ACPI!ACPIBuildProcessGenericList函数中2次InterlockedCompareExchange函数作用是标记为WORK_DONE_PENDING下次直接略过

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
ACPI!ACPIBuildProcessGenericList函数中2次InterlockedCompareExchange函数作用是标记为WORK_DONE_PENDING下次直接略过

ACPI!ACPIBuildProcessGenericList函数中2次InterlockedCompareExchange函数作用是标记为WORK_DONE_PENDING下次直接略过


//
// Check to see if we have any work to do on the request
//
workDone = InterlockedCompareExchange(
&(buildRequest->WorkDone),
WORK_DONE_PENDING,
WORK_DONE_PENDING
);

//
// Look at the dispatch table to see if there is a function to
// call
//
buildFunction = DispatchTable[ workDone ];
if (buildFunction != NULL) {

//
// Just to help us along, if we are going to the failure
// path, then we should not update the Current Work Done field.
// This gives us an easy means of find which step failed
//
if (workDone != WORK_DONE_FAILURE) {

//
// Mark the node as being in the state 'workDone'
//
buildRequest->CurrentWorkDone = workDone;

}

//
// Mark the request as pending
//
workDone = InterlockedCompareExchange(
&(buildRequest->WorkDone),
WORK_DONE_PENDING,
workDone
);

//
// Call the function
//
status = (buildFunction)( buildRequest );

1: kd> bp ACPI!ACPIBuildDeviceDpc
1: kd> g
Breakpoint 34 hit
eax=00000000 ebx=f7737120 ecx=f7737988 edx=f7737980 esi=f73fc5b2 edi=f7737980
eip=f73fc5b2 esp=f78aefa0 ebp=f78aeff4 iopl=0 nv up ei pl zr na pe nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000246
ACPI!ACPIBuildDeviceDpc:
f73fc5b2 53 push ebx
1: kd> kc
#
00 ACPI!ACPIBuildDeviceDpc
01 nt!KiRetireDpcList
02 nt!KiDispatchInterrupt
WARNING: Frame IP not in any known module. Following frames may be wrong.
03 0x0
1: kd> dv
Dpc = 0x00000000
DpcContext = 0x00000000
SystemArgument1 = 0x00000000
SystemArgument2 = 0x804ee186


1: kd> x acpi!AcpiBuildQueueList
f743b890 ACPI!AcpiBuildQueueList = struct _LIST_ENTRY [ 0xf743b890 - 0xf743b890 ]
1: kd> dx -r1 (*((ACPI!_LIST_ENTRY *)0xf743b890))
(*((ACPI!_LIST_ENTRY *)0xf743b890)) [Type: _LIST_ENTRY]
[+0x000] Flink : 0xf743b890 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0xf743b890 [Type: _LIST_ENTRY *]


1: kd> x acpi!AcpiBuildRunMethodList
f743b870 ACPI!AcpiBuildRunMethodList = struct _LIST_ENTRY [ 0x89d39ac0 - 0x89d39840 ]


1: kd> g
Breakpoint 35 hit
eax=f743b870 ebx=80afae90 ecx=f743b898 edx=f7737980 esi=f743b898 edi=f7737980
eip=f73fb8c4 esp=f78aef88 ebp=f78aeff4 iopl=0 nv up ei ng nz na pe cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000287
ACPI!ACPIBuildProcessGenericList:
f73fb8c4 55 push ebp
1: kd> kc
#
00 ACPI!ACPIBuildProcessGenericList
01 ACPI!ACPIBuildDeviceDpc
02 nt!KiRetireDpcList
03 nt!KiDispatchInterrupt
WARNING: Frame IP not in any known module. Following frames may be wrong.
04 0x0
1: kd> dv
ListEntry = 0xf743b870 [ 0x89d39ac0 - 0x89d39840 ]
DispatchTable = 0xf74380e8
tempEntry = 0xf73fb8c5 [ 0xec83ec8b - 0x84d8b0c ]
allWorkComplete = 0x00 ''
buildFunction = 0x00000000

1: kd> dv
ListEntry = 0xf743b870 [ 0x89d39ac0 - 0x89d39840 ]
DispatchTable = 0xf74380e8
tempEntry = 0xf73fb8c5 [ 0xec83ec8b - 0x84d8b0c ]
allWorkComplete = 0x00 ''
buildFunction = 0x00000000
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0xf743b870)
((ACPI!_LIST_ENTRY *)0xf743b870) : 0xf743b870 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39ac0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39840 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39ac0)
((ACPI!_LIST_ENTRY *)0x89d39ac0) : 0x89d39ac0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39a70 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0xf743b870 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39a70)
((ACPI!_LIST_ENTRY *)0x89d39a70) : 0x89d39a70 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d399d0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39ac0 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d399d0)
((ACPI!_LIST_ENTRY *)0x89d399d0) : 0x89d399d0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39980 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39a70 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39980)
((ACPI!_LIST_ENTRY *)0x89d39980) : 0x89d39980 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39930 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d399d0 [Type: _LIST_ENTRY *]

1: kd> dt ACPI_BUILD_REQUEST 0x89d39ac0
+0x000 ListEntry : _LIST_ENTRY [ 0x89d39a70 - 0xf743b870 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 1
+0x014 CurrentWorkDone : 3
+0x018 NextWorkDone : 4
+0x01c BuildContext : 0x89df4288 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0
+0x044 String : (null)
+0x044 TargetListEntry : (null)
1: kd> dt ACPI_BUILD_REQUEST 0x89d39a70
+0x000 ListEntry : _LIST_ENTRY [ 0x89d399d0 - 0x89d39ac0 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 1
+0x014 CurrentWorkDone : 3
+0x018 NextWorkDone : 4
+0x01c BuildContext : 0x89da2008 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0
+0x044 String : (null)
+0x044 TargetListEntry : (null)
1: kd> dt ACPI_BUILD_REQUEST 0x89d399d0
+0x000 ListEntry : _LIST_ENTRY [ 0x89d39980 - 0x89d39a70 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 1
+0x014 CurrentWorkDone : 3
+0x018 NextWorkDone : 4
+0x01c BuildContext : 0x89da2c40 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0
+0x044 String : (null)
+0x044 TargetListEntry : (null)


1: kd> dt ACPI_BUILD_REQUEST 0x89d39980
+0x000 ListEntry : _LIST_ENTRY [ 0x89d39930 - 0x89d399d0 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 1
+0x014 CurrentWorkDone : 5
+0x018 NextWorkDone : 2
+0x01c BuildContext : 0x89dea908 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0xf
+0x044 String : 0x0000000f "--- memory read error at address 0x0000000f ---"
+0x044 TargetListEntry : 0x0000000f _LIST_ENTRY


1: kd> dx -r1 (*((ACPI!_LIST_ENTRY *)0xf743b870))
(*((ACPI!_LIST_ENTRY *)0xf743b870)) [Type: _LIST_ENTRY]
[+0x000] Flink : 0x89d39ac0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39840 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39ac0)
((ACPI!_LIST_ENTRY *)0x89d39ac0) : 0x89d39ac0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39a70 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0xf743b870 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39a70)
((ACPI!_LIST_ENTRY *)0x89d39a70) : 0x89d39a70 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d399d0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39ac0 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d399d0)
((ACPI!_LIST_ENTRY *)0x89d399d0) : 0x89d399d0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39930 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39a70 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39930)
((ACPI!_LIST_ENTRY *)0x89d39930) : 0x89d39930 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d398e0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d399d0 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d398e0)
((ACPI!_LIST_ENTRY *)0x89d398e0) : 0x89d398e0 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d39890 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d39930 [Type: _LIST_ENTRY *]
1: kd> dx -r1 ((ACPI!_LIST_ENTRY *)0x89d39890)
((ACPI!_LIST_ENTRY *)0x89d39890) : 0x89d39890 [Type: _LIST_ENTRY *]
[+0x000] Flink : 0x89d396b0 [Type: _LIST_ENTRY *]
[+0x004] Blink : 0x89d398e0 [Type: _LIST_ENTRY *]


1: kd> g
Breakpoint 37 hit
eax=00000001 ebx=89d39940 ecx=00000000 edx=00000001 esi=89d398e0 edi=80b019f4
eip=f73fb8e1 esp=f78aef6c ebp=f78aef84 iopl=0 nv up ei ng nz na po cy
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000283
ACPI!ACPIBuildProcessGenericList+0x1d:
f73fb8e1 8b06 mov eax,dword ptr [esi] ds:0023:89d398e0=89d39890
1: kd> dt ACPI_BUILD_REQUEST 89d398e0
+0x000 ListEntry : _LIST_ENTRY [ 0x89d39890 - 0x89d39930 ]
+0x008 Signature : 0x5f534750
+0x00c Flags : 0xc
+0x00c UFlags : __unnamed
+0x010 WorkDone : 4
+0x014 CurrentWorkDone : 3
+0x018 NextWorkDone : 2
+0x01c BuildContext : 0x89d41a28 Void
+0x020 Status : 0n0
+0x024 CurrentObject : (null)
+0x028 CallBack : (null)
+0x02c CallBackContext : (null)
+0x030 DeviceRequest : __unnamed
+0x030 RunRequest : __unnamed
+0x030 SynchronizeRequest : __unnamed
+0x044 Integer : 0
+0x044 String : (null)
+0x044 TargetListEntry : (null)


ACPI_BUILD_REQUEST结构中的WorkDone什么时候变成4的?

VOID EXPORT
ACPIBuildCompleteMustSucceed(
IN PNSOBJ AcpiObject,
IN NTSTATUS Status,
IN POBJDATA ObjectData,
IN PVOID Context
)
/*++

Routine Description:

This is a generic completion handler. If the interperter has successfully
execute the method, it completes the request to the next desired WORK_DONE,
otherwise, it fails the request

Arguments:

AcpiObject - Points to the control that was run
Status - Result of the method
ObjectData - Information about the result
Context - PACPI_BUILD_REQUEST

Return Value:

VOID

--*/
{
PACPI_BUILD_REQUEST buildRequest = (PACPI_BUILD_REQUEST) Context;
ULONG nextWorkDone = buildRequest->NextWorkDone;

//
// Device what state we should transition to next
//
if (!NT_SUCCESS(Status)) {

//
// Remember why we failed, and mark the request as being failed
//
buildRequest->Status = Status;

//
// Death
//
KeBugCheckEx(
ACPI_BIOS_ERROR,
ACPI_FAILED_MUST_SUCCEED_METHOD,
(ULONG_PTR) AcpiObject,
Status,
(AcpiObject ? AcpiObject->dwNameSeg : 0)
);

} else {

//
// Note: we don't have a race condition here because only one
// routine can be processing a request at any given time. Thus it
// is safe for us to specify a new next phase
//
buildRequest->NextWorkDone = WORK_DONE_FAILURE;

//
// Transition to the next stage
//
ACPIBuildCompleteCommon(
&(buildRequest->WorkDone),
nextWorkDone
);

}

}


VOID
ACPIBuildCompleteCommon(
IN PULONG OldWorkDone,
IN ULONG NewWorkDone
)
/*++

Routine Description:

Since the completion routines all have to do some bit of common work to
get the DPC firing again, this routine reduces the code duplication

Arguments:

OldWorkDone - Pointer to the old amount of work done
NewWorkDone - The new amount of work that has been completed

NOTENOTE: There is an implicit assumption that the current value of
WorkDone in the request is WORK_DONE_PENDING. If that is
not the case, we will fail to transition to the next stage,
which means that we will loop forever.

Return Value:

None

--*/
{
KIRQL oldIrql;

//
// Update the state of the request
//
InterlockedCompareExchange( OldWorkDone, NewWorkDone,WORK_DONE_PENDING);//这个时候buildRequest->WorkDone变成了4

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/12 6:07:09

leetcode 881. Boats to Save People 救生艇

Problem: 881. Boats to Save People 救生艇 解题过程 排序,然后查找可以配对的,而且右上界是不断缩小的,用到了状态数组 优化版本只需要求出可以配对的,然后总数减去配对数量 Code class Solution { public:int numRescueBoats…

作者头像 李华
网站建设 2026/5/9 12:55:39

学术探险家指南:用书匠策AI解锁本科论文写作的“隐藏地图”

对于许多本科生而言,论文写作像一场充满未知的“学术探险”——选题撞车、文献迷航、逻辑混乱、语言生硬……这些问题如同隐藏的陷阱,让新手学者屡屡受挫。但如今,一款名为书匠策AI的智能工具正以“学术探险装备库”的姿态,将论文…

作者头像 李华
网站建设 2026/5/9 17:48:18

导入自己的读书笔记数量(每本书的笔记数),统计笔记最多的书籍,输出深度阅读建议

1. 实际应用场景描述场景某知识工作者长期阅读各类书籍,并在笔记软件中记录了每本书的笔记数量。他希望:- 找出笔记最多的书(代表投入时间多、思考深入)- 根据笔记数量获得深度阅读建议- 优化未来的阅读计划痛点- 手动翻阅笔记软件…

作者头像 李华
网站建设 2026/5/10 0:25:34

学长亲荐2026 TOP10 AI论文写作软件:本科生毕业论文必备工具测评

学长亲荐2026 TOP10 AI论文写作软件:本科生毕业论文必备工具测评 2026年AI论文写作工具测评:为何需要一份权威榜单? 随着人工智能技术的不断进步,AI论文写作工具逐渐成为高校学生和科研人员的重要辅助工具。然而,市面上…

作者头像 李华
网站建设 2026/5/10 1:43:20

【多无人机路径规划】基于K均值聚类与遗传算法的无人机路径规划,对任务区域进行划分,并优化每个区域内的访问路径研究附Matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,擅长数据处理、建模仿真、程序设计、完整代码获取、论文复现及科研仿真。🍎 往期回顾关注个人主页:Matlab科研工作室🍊个人信条:格物致知,完整Matlab代码及仿真咨询…

作者头像 李华