try_module_get简析
来源:互联网 发布:pdf全文翻译软件 编辑:程序博客网 时间:2024/05/22 17:43
try_module_get 如果模块已经插入内核,则递增该模块引用计数;如果该模块还没有插入内核,则返回0表示出错
代码如下:
include/linux/module.h
413 static inline int try_module_get(struct module *module)
414 {
415 int ret = 1;
416
417 if (module) {
418 unsigned int cpu = get_cpu();
419 if (likely(module_is_live(module)))
420 local_inc(&module->ref[cpu].count);
421 else
422 ret = 0;
423 put_cpu();
424 }
425 return ret;
426 }
例如在fs/char_dev.c 中cdev_get中使用。
268 static struct kobject *cdev_get(struct cdev *p)
269 {
270 struct module *owner = p->owner;
271 struct kobject *kobj;
272
273 if (owner && !try_module_get(owner))
274 return NULL;
275 kobj = kobject_get(&p->kobj);
276 if (!kobj)
277 module_put(owner);
278 return kobj;
279 }
- try_module_get简析
- (6)try_module_get和module_put
- try_module_get和module_put
- try_module_get和module_put
- try_module_get和module_put
- linux try_module_get和module_put
- try_module_get和module_put
- try_module_get和module_put
- try_module_get和module_put
- try_module_get和module_put
- try_module_get和module_put
- 模块API之try_module_get
- linux-2.6内核模块引用计数的实现(try_module_get和module_put)
- linux-2.6内核模块引用计数的实现(try_module_get和module_put)
- linux-2.6内核模块引用计数的实现(try_module_get和module_put)
- 通过try_module_get 来检测需要的ko是否已经insmod了
- UML简析
- JSP简析
- SPF记录
- vim多行注释、替换和其他操作
- 图的遍历
- Android应用自动更新功能的代码实现
- 我感兴趣的博客和网站
- try_module_get简析
- lpcxpresso-cn开发板编译环境IAR Embedded Bench使用小结
- 留着
- Ffmpeg开发手册
- 转义符 自备
- windows7 修改窗口背景色
- 使用WinINet和WinHTTP实现HTTP访问
- 动态修改strings文件中的字符串 使用占位符
- Flex4.5RadioButton组件的应用