gpt4 book ai didi

linux - register_pernet_subsys 和 register_pernet_device 有什么区别?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:50:18 30 4
gpt4 key购买 nike

http://lists.openfabrics.org/pipermail/general/2007-January/032093.html

At creation all subsys init functions are called before device init functions, and at destruction all device exit functions are called before subsys exit function.

也许这就是答案。然而,距该职位已过去 8 年。它可能不再正确。

我看了linux/net/core/net_namespaces.c中的代码,还是没完全看懂。

谁能帮帮我?谢谢。

最佳答案

好吧,我会在几个月的学习之后回答我自己的问题。

关键在于对列表(include/list.h)的理解。如果你对这个linux内核广泛使用的数据结构不熟悉,建议你先用它写一些代码。

Initially , pernet_listfirst_device 都是指向同一个列表头的指针。

如果 register_pernet_subsys 被调用,pernet_listfirst_device 仍然是同一个指向列表头的。准确的说,如果没有调用register_pernet_device,它们都指向privious location。

但是调用register_pernet_device后,first_device会指向新的list_head,而pernet_list仍然指向原来的list head。

关于linux - register_pernet_subsys 和 register_pernet_device 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32223367/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com