Windows计算机关闭时实际上会发生什么?

what-is-actually-happening-when-a-windows-computer-is-shutting-down-00

While most of us probably give little thought to all that is happening each time we shut our computers down, what is actually going on ‘under the hood’ during the shutdown process? Today’s SuperUser Q&A post has the answers to a curious reader’s question.

虽然我们大多数人可能几乎不考虑每次关闭计算机时发生的所有事情,但是在关闭过程中“幕后”到底发生了什么? 今天的“超级用户问答”帖子回答了一个好奇的读者的问题。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

问题 (The Question)

SuperUser reader RACING121 wants to know what is actually happening when a Windows computer is shutting down:

超级用户阅读器RACING121想知道Windows计算机关闭时实际发生的情况:

When I click the shutdown button on my Windows system, it gives me another screen saying Shutting down:

当我单击Windows系统上的关闭按钮时,它会显示另一个屏幕,提示我正在关闭

what-is-actually-happening-when-a-windows-computer-is-shutting-down-01

What is actually going on during this stage?

在此阶段实际发生了什么?

If I recall correctly, in Windows XP it would say something like Saving Settings before powering off. However, what settings are there to actually save here? For example,  if you have applied a theme or completed some other action, it has already been “saved” when you clicked Apply or Ok.

如果我没记错的话,在Windows XP中关机前会说类似“ 保存设置” 。 但是,实际上有什么设置可以保存在这里? 例如,如果您已应用主题或完成了其他操作,则在单击“ 应用”或“ 确定 ”时已经“保存”了该主题。

If it is unmounting the hard drive, then surely it would be the same as forcing a shutdown by pulling the plug, right?

如果要卸下硬盘驱动器,那么肯定与通过拔下插头来强制关机一样吗?

What is actually happening when a Windows computer goes through the shutdown process?

Windows计算机执行关闭过程时实际上发生了什么?

答案 (The Answer)

SuperUser contributors Keltari and zzarzzur have the answer for us. First up, Keltari:

超级用户贡献者Keltari和zzarzzur为我们提供了答案。 首先,Keltari:

There are a lot of things happening during the shutdown process. Here are just a few examples:

关闭过程中发生了很多事情。 这里只是几个例子:

  • Checking to see if any user applications have not been closed yet (like an unsaved document) and prompt the user if necessary

    检查是否尚未关闭任何用户应用程序(例如未保存的文档),并在必要时提示用户
  • Stopping background services

    停止后台服务
  • Waiting for the termination signal from services and applications that are open or running

    等待来自打开或正在运行的服务和应用程序的终止信号
  • Flushing the cache to disk

    将缓存刷新到磁盘
  • Writing log files

    写入日志文件
  • All users are logged out

    所有用户都已注销
  • Ending the shell

    结束外壳
  • Start installing Windows updates and tell the system to finish the update process during the next system start-up if necessary

    开始安装Windows更新,并在必要时告诉系统在下次系统启动期间完成更新过程
  • Send the ACPI shutdown signal (this is what turns the machine off)

    发送ACPI关机信号(这就是关闭机器的信号)

Followed by the answer from zzarzzur:

随后是zzarzzur的回答:

The system registry is (maybe?) written to the disk. Back when I used Windows XP, I noticed that if you made any changes to the registry then pulled the power, the changes would not be saved. I am not quite sure about this one, just pointing it out.

系统注册表已(可能是?)写入磁盘。 回到使用Windows XP时,我注意到,如果您对注册表进行了任何更改然后再关闭电源,则更改将不会保存。 我对此不太确定,只是指出来。

Here is an excerpt from a document that Microsoft released:

这是Microsoft发布的文档的摘录:

  • System session shutdown. This phase includes the pre-shutdown notification and shutdown notification sub-phases.

    系统会话关闭。 此阶段包括关机前通知和关机通知子阶段。
  • Pre-shutdown notification. Windows serially shuts down all services that registered to receive pre-shutdown notifications. Ordered services—services that have set up the shutdown order of dependent services—are shut down before non-ordered services.

    关机前通知。 Windows依次关闭所有注册为接收关机前通知的服务。 有序服务(已设置从属服务的关闭顺序的服务)在无序服务之前被关闭。
  • Shutdown notification. All services that registered to receive shutdown notifications are shut down in parallel. If all services have not exited after 20 seconds (in Windows Vista) or 12 seconds (in Windows 7 client operating systems), the system continues the shutdown. Processes and services that do not shut down in a timely manner are left running as the system shuts down.

    关机通知。 注册为接收关闭通知的所有服务都将并行关闭。 如果20秒(在Windows Vista中)或12秒(在Windows 7客户端操作系统中)之后所有服务都没有退出,则系统将继续关闭。 系统关闭时,未及时关闭的进程和服务将保持运行状态。
  • Kernel shutdown. The remainder of the system, such as all devices and drivers, are shut down during the kernel shutdown phase.

    内核关闭。 系统的其余部分(例如所有设备和驱动程序)在内核关闭阶段会关闭。

Basically, what you are waiting on is each individual service to clean up and exit. Each service is given 12 seconds to exit before it is killed.

基本上,您正在等待的是每个服务都要清理并退出。 每项服务在退出之前都会有12秒的退出时间。

Half of the shutdown time is dedicated to shutting down system services. If you are really interesting in seeing what time is dedicated to whatever during a shutdown, Windows includes a tool for tracing shutdown time.

关闭时间的一半专门用于关闭系统服务。 如果您真的很想知道关机期间的时间是什么,Windows会提供一个跟踪关机时间的工具。

  • xbootmgr -trace shutdown -numRuns 3 -resultPath %systemdrive%\traces -postBootDelay 180 -traceFlags base

    xbootmgr -trace shutdown -numRuns 3 -resultPath%systemdrive%\ traces -postBootDelay 180 -traceFlags base

And to make sense of the generated file (be sure to run in %systemdrive%\traces)

并理解生成的文件(确保在%systemdrive%\ traces中运行 )

  • xperf -i trace.etl -o summary.xml -a shutdown

    xperf -i trace.etl -o summary.xml -a关闭

Sources

资料来源

Windows On/Off Transition Performance Analysis Document [Microsoft]

Windows开/关过渡性能分析文档 [Microsoft]

Windows On/Off Transitions Solutions Guide Document [Microsoft]

Windows开/关转换解决方案指南文档 [Microsoft]



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程

翻译自: https://www.howtogeek.com/235771/what-is-actually-happening-when-a-windows-computer-is-shutting-down/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值