当前位置:网站首页>DECLARE_ WAIT_ QUEUE_ HEAD、wake_ up_ Interruptible macro analysis
DECLARE_ WAIT_ QUEUE_ HEAD、wake_ up_ Interruptible macro analysis
2022-07-05 03:13:00 【_ Zer0】
DECLARE_WAIT_QUEUE_HEAD
// Source code
struct list_head {
struct list_head *next, *prev;
};
struct __wait_queue_head {
spinlock_t lock;
struct list_head task_list;
};
typedef struct __wait_queue_head wait_queue_head_t;
#define DECLARE_WAIT_QUEUE_HEAD (name)
wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
#define __WAIT_QUEUE_HEAD_INITIALIZER (name) {
.lock = __SPIN_LOCK_UNLOCKED(name.lock),
.task_list = {
&(name).task_list, &(name).task_list }
}
//DECLARE_WAIT_QUEUE_HEAD(wq); The result of unlocking the macro definition statement is as follows
wait_queue_head_t wq = {
.lock = __SPIN_LOCK_UNLOCKED(wq.lock),
.task_list = {
&(wq).task_list, &(wq).task_list }
}
#include <linux/wait.h>
// The following two lines are equivalent to DECLARE_WAIT_QUEUE_HEAD(wq);
wait_queue_head_t wq;
init_waitqueue_head(&wq);
wake_up_interruptible
#define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)
void __wake_up(wait_queue_head_t *q, unsigned int mode,
int nr_exclusive, void *key)
{
unsigned long flags;
spin_lock_irqsave(&q->lock, flags);
__wake_up_common(q, mode, nr_exclusive, 0, key);
spin_unlock_irqrestore(&q->lock, flags);
}
边栏推荐
- 8. Commodity management - commodity classification
- 返回二叉树中两个节点的最低公共祖先
- LeetCode 237. Delete nodes in the linked list
- Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles
- GFS分布式文件系统
- SPI and IIC communication protocol
- Azkaban actual combat
- Utilisation simple de devtools
- Sqoop命令
- Kbp206-asemi rectifier bridge kbp206
猜你喜欢

Voice chip wt2003h4 B008 single chip to realize the quick design of intelligent doorbell scheme

Design and practice of kubernetes cluster and application monitoring scheme

The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety

1.五层网络模型

Why are there fewer and fewer good products produced by big Internet companies such as Tencent and Alibaba?

SQL injection exercise -- sqli Labs

IPv6 experiment

qrcode:将文本生成二维码

2021 Li Hongyi machine learning (1): basic concepts

Azkaban overview
随机推荐
Linux安装Redis
Sqoop安装
Accuracy problem and solution of BigDecimal
Sqoop命令
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
Azkaban概述
Is there any way to change the height of the uinavigationbar in the storyboard without using the UINavigationController?
Kuboard
The database and recharge are gone
Why is this an undefined behavior- Why is this an undefined behavior?
Why are there fewer and fewer good products produced by big Internet companies such as Tencent and Alibaba?
Design and implementation of community hospital information system
Sqoop command
Master Fur
Port, domain name, protocol.
Simple use of devtools
2021 Li Hongyi machine learning (1): basic concepts
Apache Web page security optimization
This + closure + scope interview question
ICSI213/IECE213 Data Structures