当前位置:网站首页>Epoll () whether it involves wait queue analysis
Epoll () whether it involves wait queue analysis
2022-07-06 18:25:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
event 1. epfd-file->eventpoll->wq:
struct eventpoll { … wait_queue_head_t wq; // be used for epoll_pwait() Waiting queue for events situation 1 analysis struct list_head rdllist; // Ready fd queue ready list struct rb_root rbr; // Red and black root ,epitem->rbn It is the node of red black tree structure struct file *file; //epoll Virtual files built in the file system … }; It is mainly used for epoll_pwait() When , determine epfd-file->eventpoll->rdlist( be ready fd) Is it empty . Suppose it is empty and epoll_pwait() Call for blocking . Then the current process will be hung to epfd-file->eventpoll->wq in , And the current process is blocked waiting , until rdlist Evoke when it is not empty epfd-file->eventpoll->poll_wait Processes in the linked list ( Mutually exclusive arousal and non mutually exclusive arousal ?) The callback function called silently feels wake_up_interruptible perhaps wake_up
situation 2. Monitored fd->poll_wait
Socket that will be monitored fd stay epoll Built during epitem and eppoll_entry epitem{ struct rb_node rbn; //epitem Hang on rbtree Node information on struct list_head rdllink; // hypothesis fd be ready , Hook in ready list struct eventpoll *ep; // Owner eventpoll( maintain rbtree rdllist poll_wait queue …) struct epoll_event event; //fd Events monitored on } struct eppoll_entry { struct list_head llink; struct epitem *base; // Belongs to epitem wait_queue_t wait; // Hook in as an element to be monitored fd Of wait In line wait_queue_head_t *whead; // Be monitored fd Waiting queue . hypothesis fd by socket. that whead by sock->sk_sleep }; eppoll_entry Mainly finished epitem and epitem At the time of the incident callback The relationship between functions . First of all, will eppoll_entry Of whead Point to fd Device waiting queue ( Same as select Medium wait_address). Then initialize eppoll_entry Of base Variable pointing to the epitem. Finally through add_wait_queue take epoll_entry Mount to fd On the device waiting queue . When the hardware data of the device arrives , When the hardware interrupt processing function wakes up the waiting process on the waiting queue , Will call the wake-up function ep_poll_callback(ep_poll_callback: When fd After the departure event . take epitem Medium rdllink Node added to readlist in (epfd-file->eventpoll->rdlist))
contrast :
1 and 2 contrast , The main reason is that the callback function of waiting queue is different ,1 The callback of is to wake up the process that is waiting for an event and is asleep ,2 The callback of is to put epitem Medium rdllink The structure is increased to ready list in .
Refer to : http://www.cnblogs.com/apprentice89/archive/2013/05/09/3068274.html http://www.cnblogs.com/apprentice89/p/3234677.html
Copyright notice : This article is an original blog article . Blog , Without consent , Shall not be reproduced .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117402.html Link to the original text :https://javaforall.cn
边栏推荐
- Recursive way
- Introduction to the usage of model view delegate principal-agent mechanism in QT
- [.Net core] solution to error reporting due to too long request length
- Compilation principle - top-down analysis and recursive descent analysis construction (notes)
- 1700C - Helping the Nature
- C language exchanges two numbers through pointers
- 【LeetCode第 300 场周赛】
- 具体说明 Flume介绍、安装和配置
- C语言高校实验室预约登记系统
- Markdown syntax for document editing (typera)
猜你喜欢

declval(指导函数返回值范例)

1700C - Helping the Nature

Grafana 9.0 is officially released! It's the strongest!
![Jerry is the custom background specified by the currently used dial enable [chapter]](/img/32/6c22033bda8ff1b53993bacef254cd.jpg)
Jerry is the custom background specified by the currently used dial enable [chapter]

Declval of template in generic programming

Grafana 9.0 正式发布!堪称最强!

Compilation Principle -- C language implementation of prediction table
![[swoole series 2.1] run the swoole first](/img/cd/88abf7e83e9d9d416051b33263690b.png)
[swoole series 2.1] run the swoole first

【Swoole系列2.1】先把Swoole跑起来

Comparative examples of C language pointers *p++, * (p++), * ++p, * (++p), (*p) + +, +(*p)
随机推荐
Unity资源顺序加载的一个方法
Jerry is the custom background specified by the currently used dial enable [chapter]
287. Find duplicates
Coco2017 dataset usage (brief introduction)
78 year old professor Huake has been chasing dreams for 40 years, and the domestic database reaches dreams to sprint for IPO
celery最佳实践
随着MapReduce job实现去加重,多种输出文件夹
第三季百度网盘AI大赛盛夏来袭,寻找热爱AI的你!
C language college laboratory reservation registration system
容器里用systemctl运行服务报错:Failed to get D-Bus connection: Operation not permitted(解决方法)
Insert dial file of Jerry's watch [chapter]
J'aimerais dire quelques mots de plus sur ce problème de communication...
最新财报发布+天猫618双榜第一,耐克蓄力领跑下个50年
Jerry's watch deletes the existing dial file [chapter]
首先看K一个难看的数字
2022 Summer Project Training (II)
CRMEB 商城系统如何助力营销?
面向程序员的精品开源字体
Recommend easy-to-use backstage management scaffolding, everyone open source
The third season of Baidu online AI competition is coming in midsummer, looking for you who love AI!