代码改变世界

随笔档案-2010年12月3日

Linux内核里的“智能指针” (续)

2010-12-03 22:13 by wwang, 5041 阅读, 收藏, 编辑
摘要: 在上一篇文章《Linux内核里的智能指针》里介绍了Linux内核如何使用引用计数来更加安全的管理内存,本文承接前篇,主要介绍几点使用kref时的注意事项。Linux内核文档kref.txt罗列了三条规则,我们在使用kref时必须遵守。规则一:If you make a non-temporary copy of a pointer, especially if it can be passed to another thread of execution, you must increment the refcount with kref_get() before passing it off 阅读全文
点击右上角即可分享
微信分享提示