为什么高手都喜欢把锁存到结构中,有什么优点吗?
时间:2010-08-12
来源:互联网
本帖最后由 zhangsuozhu 于 2010-08-12 15:52 编辑
复制代码
见spinlock_t lock;
- struct nf_conn {
- /* Usage count in here is 1 for hash table/destruct timer, 1 per skb,
- plus 1 for any connection(s) we are `master' for */
- struct nf_conntrack ct_general;
-
- spinlock_t lock;
-
- /* XXX should I move this to the tail ? - Y.K */
- /* These are my tuples; original and reply */
- struct nf_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX];
-
- /* Have we seen traffic both ways yet? (bitset) */
- unsigned long status;
-
- /* If we were expected by an expectation, this will be it */
- struct nf_conn *master;
-
- /* Timer function; drops refcnt when it goes off. */
- struct timer_list timeout;
-
- #if defined(CONFIG_NF_CONNTRACK_MARK)
- u_int32_t mark;
- #endif
-
- #ifdef CONFIG_NF_CONNTRACK_SECMARK
- u_int32_t secmark;
- #endif
-
- /* Storage reserved for other modules: */
- union nf_conntrack_proto proto;
-
- /* Extensions */
- struct nf_ct_ext *ext;
- #ifdef CONFIG_NET_NS
- struct net *ct_net;
- #endif
- };
作者: zhangsuozhu 发布时间: 2010-08-12
表示这个锁,是对这个结构的一致性起作用的,很好阿。
作者: peidright 发布时间: 2010-08-12


作者: zhangsuozhu 发布时间: 2010-08-12
与结构相关的都应该放在一起,而不是分开
作者: wenkai169 发布时间: 2010-08-12
与结构相关的锁不放在结构中,放在哪里呢?
作者: mirnshi 发布时间: 2010-08-12
结构化,一致性
作者: @sky 发布时间: 2010-08-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28