![qt关闭计算机](https://i-blog.csdnimg.cn/blog_migrate/43be8a097e72541241be5185bed50542.png)
qt关闭计算机
![](https://i-blog.csdnimg.cn/blog_migrate/98229f039cfb0dce88a303b5904b4029.png)
When you start your computer up after an improper shutdown/system crash, it will usually suggest actions like booting into safe mode and running a disk check. How does the computer know it crashed?
当您在不适当的关机/系统崩溃后启动计算机时,它通常会建议诸如启动进入安全模式和运行磁盘检查之类的操作。 计算机如何知道它崩溃了?
Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-drive grouping of Q&A web sites.
今天的问答环节由SuperUser提供,它是Stack Exchange的一个分支,它是Q&A网站的社区推动组织。
问题 (The Question)
SuperUser reader FrozenKing wants to know how his computer knows when it has crashed or otherwise had an improper shutdown. He writes:
超级用户阅读器FrozenKing想要了解他的计算机在崩溃或不正常关机时如何知道。 他写:
Actually, this question struck me because of power cuts in my house. When there is a power cut, there is a sudden loss of power from the computer.
实际上,由于我家的断电,这个问题使我震惊。 断电时,计算机会突然断电。
How does the computer know that the shutdown was not properly done?
计算机如何知道关机未正确完成?
It’s an interesting question; clearly modern operating systems are well aware that something has gone wrong, but by what mechanism are they made aware?
这是一个有趣的问题; 显然,现代操作系统很清楚出了什么问题,但是通过什么机制知道了?
答案 (The Answers)
SuperUser contributor David Schwartz offers a general answer and insight into different operating systems:
超级用户贡献者David Schwartz提供了有关不同操作系统的一般答案和见解:
For non-Windows based PCs, the detection is usually done on a per-filesystem basis. When a filesystem is mounted in read/write mode, an entry is written to the filesystem marking it dirty. When the filesystem is unmounted, an entry is written marking it clean. On startup, the operating system checks if its core filesystems are marked dirty, and if so it knows there wasn’t a clean shutdown — at least of those filesystems.
对于非基于Windows的PC,检测通常是基于每个文件系统进行的。 当文件系统以读/写模式挂载时,会将条目写入文件系统,将其标记为脏。 卸载文件系统后,将写入一个条目,将其标记为干净。 在启动时,操作系统会检查其核心文件系统是否标记为脏文件,如果是,它会知道没有干净的关闭-至少是那些文件系统。
Another contributor, ChrisF answers more specifically for the Windows operating system:
另一个贡献者ChrisF专门针对Windows操作系统回答:
![]()
Windows also uses the Dirty Bit method to detect whether the PC was shut down properly:
Windows还使用“ 脏位”方法来检测PC是否已正确关闭:
When powered off as normal, the bit is switched off. However, in case of power outage or improper (forced) shutdown, the bit will still be on the next time the PC is started.
正常关闭电源后,该位将关闭。 但是,在断电或不正确(强制)关闭的情况下,下次启动PC时,该位仍会保留。
This means that Windows can suggest remedial action – such as booting into Safe Mode.
这意味着Windows可以建议采取补救措施,例如启动到安全模式。
In addition a Windows based PC will write an entry into event log detailing when and why (if known) it was shut down. It also writes an event when the PC starts up.
此外,基于Windows的PC将在事件日志中写入一个条目,详细说明何时以及为何(如果已知)将其关闭。 当PC启动时,它还会写入一个事件。
Have something to add to the explanation? Sound off in the 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/132490/how-does-a-computer-know-when-it-wasnt-properly-shut-down/
qt关闭计算机