- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我刚刚开始研究(嵌入式)Linux(准确地说是 Beaglebone Black)上的 I2C 支持。既然是linux,一切都是文件,所以I2C也是。
int file = open( "/dev/i2c-0", O_RDWR );
然后通过ioctl()
选择总线上的实际地址。我的问题是 - 在应用程序执行期间缓存 file
是否安全,甚至合法?在我天真的眼中,打开资源以每 250 毫秒读取一次的开销对内核来说是不必要的压力。所以打开是有效的,然后在需要时使用 ioctl()
切换地址,或者我必须 close()
读写之间的描述符?
最佳答案
is it safe, or even legal, to cache
file
for the duration of application execution?
只要您的程序需要继续执行,文件描述符(从 open() 返回)就有效。
/dev 中的设备节点可能类似于文件名,但一旦您查看系统调用接口(interface),它们就会与文件系统条目区别对待。设备文件描述符上的 open() 或 read() 将调用设备驱动程序,而对于实际文件,将调用其文件系统,最终可能调用存储设备驱动程序。
It would seem to my naive eyes that the overheading of opening a resource to read every 250ms would be an unnecessary strain on the kernel.
是的,因为那些 open() 和 close() 系统调用是不必要的。
So it is valid to open, and then just use ioctl() to switch address whenever I need to,
是的,这才是正确的用法。
or must I close() the descriptor between reads and writes?
没有必要也不建议这样做。
关于Linux I2C 文件句柄 - 缓存安全吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26216377/
我设置了 Helm 柄和 Helm 柄。我有tiller-deploy。昨天,我可以定期运行了。但今天我收到此错误消息 Error: could not find a ready tiller pod
我以前已将分er安装到特定的 namespace 中。 我设置了一个环境变量来设置'tiller'命名空间-但我不记得该环境变量的名称-而且似乎无法通过网络搜索找到它。 这是什么 key ? 最佳答案
当我在 View 模型中使用如下界面时 class MainViewModel @ViewModelInject constructor( private val trafficImagesR
我正在尝试找到如何在某个 fragment 相关场景中定义 Hilt 的解决方案。我有以下设置: Activity 父 fragment 1 子 fragment 1 子 fragment 2 ...
Hilt 指出如果没有@Provides 注解就不能提供这个接口(interface): interface PlannedListRepository { fun getAllLists()
我的问题非常简单明了:两个注释/示例之间有什么区别: 例子一 @Singleton class MySingletonClass() {} @Module @InstallIn(FragmentCom
我是一名优秀的程序员,十分优秀!