本文介绍了什么意思是“原子的"?系统调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 atomic 通常用于种族条件的上下文中,并且意味着诸如 consistency 确定性结果之类的东西根据多线程/多处理环境.没关系.但是最近我读到了Linux中的原子系统调用,却不明白 atomic 在这里实际上是什么意思,即如何这种 atomicity 已实现.这是否意味着该系统调用仅使用对资源的锁定(例如,目标文件inode上的open())还是还有其他内容,也许可以保证某些内核?我考虑禁用中断,但并非所有中断都可以禁用.可能就足够了,因为可以禁用内核使用的所有中断,而其他中断太重要,并且可以中断我们的 atomic 系统调用?

I know that atomic is usually used in the context of race condition and means something like consistency and determinism of the result according to multithreading/multiprocessing environment. That's ok. But recently I read about atomic system calls in Linux and didn't understand what does atomic actually mean here, i.e. how this atomicity is implemented. Does it mean that this system calls simply use locks on the resources (e.g. open() on the target file inode) or there is anything more, may be some kernel guarantees? I think about disabling interrupts but not all interrupts can be disabled. May be that's enough because all interrupts used by the kernel can be disabled and others are too important and can interrupt our atomic system call?

推荐答案

这确实取决于系统调用.引用man 3 read,它引用了posix编程手册:

That really depends on the system call. Citing man 3 read, which cites the posix programming manual:

很明显,这仅适用于IO操作.

Obviously, this only applies to IO operations.

这篇关于什么意思是“原子的"?系统调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 17:21