内核如何知道文件已关闭

发布于 2024-12-04 18:12:55 字数 134 浏览 1 评论 0原文

Linux 知道文件已关闭的机制到底是什么? 我知道诸如 INOTIFY 之类的命令会在文件关闭时触发 IN_CLOSE_WRITE 事件。但它是如何运作的呢?什么触发文件关闭?

同样,操作系统如何知道文件已被打开以及它在哪里注册该事实?

What exactly is the mechanism by which the linux knows that a file has been closed ?
I know commands such as INOTIFY would trigger IN_CLOSE_WRITE event when a file is closed. But how does it work ? What triggers close of a file ?

Similarly how does OS know that a file has been opened and where does it register that fact?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一抹微笑 2024-12-11 18:12:55

操作系统(即内核)是实际打开和关闭文件的操作系统。程序每次想要通过系统调用来打开/关闭文件时,都必须告诉操作系统代表它打开/关闭文件。操作系统可以简单地跟踪这些经过自身的调用。

The OS (i.e. kernel) is the one that actually opens and closes files. A program will have to tell the OS to open/close files on its behalf every time it wants to do so via system calls. The OS can simply keep track of these calls that go through itself.

通知家属抬走 2024-12-11 18:12:55

有一个打开文件表,列出了所有打开的流以及它们在内存中的指向位置。

这可能会有所帮助:http://www. cs.kent.edu/~walker/classes/os.f07/lectures/Walker-11.pdf

There is an open file table that lists all the streams that are open and where they point to in memory.

This may help: http://www.cs.kent.edu/~walker/classes/os.f07/lectures/Walker-11.pdf

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文