wait queue 5
来源:互联网 发布:mac os x 重装 超慢 编辑:程序博客网 时间:2024/06/05 17:36
在使用bit_waitqueue的时候一般通过下面的函数得到wait_queue_head_t
wait_queue_head_t *wq = bit_waitqueue(&whole->bd_claiming, 0);
其中bit_wait_table是一个cacheline 对其的静态数组
static wait_queue_head_t bit_wait_table[WAIT_TABLE_SIZE] __cacheline_aligned;
wait_queue_head_t *bit_waitqueue(void *word, int bit)
{
const int shift = BITS_PER_LONG == 32 ? 5 : 6;
unsigned long val = (unsigned long)word << shift | bit;
return bit_wait_table + hash_long(val, WAIT_TABLE_BITS);
}
总共支持256元素
#define WAIT_TABLE_BITS 8
#define WAIT_TABLE_SIZE (1 << WAIT_TABLE_BITS)
用户调用bit_waitqueue 的到wait queue的时候,起始就是更加word和要检测的bit产生一个唯一的hash
值,当时这个值必须在256 之内,这点是由hash_long(val, WAIT_TABLE_BITS)的WAIT_TABLE_BITS 来决定的
#if BITS_PER_LONG == 32
#define GOLDEN_RATIO_PRIME GOLDEN_RATIO_32
#define hash_long(val, bits) hash_32(val, bits)
#elif BITS_PER_LONG == 64
#define hash_long(val, bits) hash_64(val, bits)
#define GOLDEN_RATIO_PRIME GOLDEN_RATIO_64
#else
#error Wordsize not 32 or 64
#endif
我们BITS_PER_LONG == 32 因此hash_long == hash_32
这个函数在算出32 bit的hash值后,会右移动24bit(因为WAIT_TABLE_BITS==8),因此就保证hash_32_generic 返回的值在256之内.
static inline u32 hash_32_generic(u32 val, unsigned int bits)
{
/* High bits are more random, so use them. */
return __hash_32(val) >> (32 - bits);
}
以后自己写driver的时候也可以考虑采用hash table这种方法.
wait_queue_head_t *wq = bit_waitqueue(&whole->bd_claiming, 0);
其中bit_wait_table是一个cacheline 对其的静态数组
static wait_queue_head_t bit_wait_table[WAIT_TABLE_SIZE] __cacheline_aligned;
wait_queue_head_t *bit_waitqueue(void *word, int bit)
{
const int shift = BITS_PER_LONG == 32 ? 5 : 6;
unsigned long val = (unsigned long)word << shift | bit;
return bit_wait_table + hash_long(val, WAIT_TABLE_BITS);
}
总共支持256元素
#define WAIT_TABLE_BITS 8
#define WAIT_TABLE_SIZE (1 << WAIT_TABLE_BITS)
用户调用bit_waitqueue 的到wait queue的时候,起始就是更加word和要检测的bit产生一个唯一的hash
值,当时这个值必须在256 之内,这点是由hash_long(val, WAIT_TABLE_BITS)的WAIT_TABLE_BITS 来决定的
#if BITS_PER_LONG == 32
#define GOLDEN_RATIO_PRIME GOLDEN_RATIO_32
#define hash_long(val, bits) hash_32(val, bits)
#elif BITS_PER_LONG == 64
#define hash_long(val, bits) hash_64(val, bits)
#define GOLDEN_RATIO_PRIME GOLDEN_RATIO_64
#else
#error Wordsize not 32 or 64
#endif
我们BITS_PER_LONG == 32 因此hash_long == hash_32
这个函数在算出32 bit的hash值后,会右移动24bit(因为WAIT_TABLE_BITS==8),因此就保证hash_32_generic 返回的值在256之内.
static inline u32 hash_32_generic(u32 val, unsigned int bits)
{
/* High bits are more random, so use them. */
return __hash_32(val) >> (32 - bits);
}
以后自己写driver的时候也可以考虑采用hash table这种方法.
0 0
- wait queue 5
- wait queue
- linux wait queue
- wait queue 笔记
- linux wait queue
- linux join wait queue!
- 等待队列wait queue
- linux driver wait queue
- linux 内核wait queue
- wait queue 1
- wait queue 2
- wait queue 3
- wait queue 4
- wait queue 6
- wait queue 7
- wait queue 8
- Wait Queue等待队列
- link list and wait queue
- H264码流结构分析
- python使用rabbitmq实例三,交换机
- js高级程序设计笔记3--继承
- 通过React.cloneElement给所有子元素添加属性
- selenium定位动态id元素
- wait queue 5
- update-alternatives——linux软件版本管理命令
- jquery添加和移除disabled属性
- iOS开发(Swift)——宏定义
- python使用rabbitmq实例四,路由键
- C++11中的变参模板的使用
- Java GC及堆内存
- stl容器算法迭代器三大概念入门
- 关于eclipse标题栏乱码