当前位置:网站首页>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
边栏推荐
- Markdown grammar - better blogging
- Dichotomy (integer dichotomy, real dichotomy)
- DNS hijacking
- 最新财报发布+天猫618双榜第一,耐克蓄力领跑下个50年
- Codeforces Round #803 (Div. 2)
- Transport layer congestion control - slow start and congestion avoidance, fast retransmission, fast recovery
- 测试123
- ADB common commands
- MS-TCT:Inria&SBU提出用于动作检测的多尺度时间Transformer,效果SOTA!已开源!(CVPR2022)...
- 【.NET CORE】 请求长度过长报错解决方案
猜你喜欢
IP, subnet mask, gateway, default gateway
Distiller les connaissances du modèle interactif! L'Université de technologie de Chine & meituan propose Virt, qui a à la fois l'efficacité du modèle à deux tours et la performance du modèle interacti
Introduction to the usage of model view delegate principal-agent mechanism in QT
Implementation of queue
On time and parameter selection of asemi rectifier bridge db207
UDP协议:因性善而简单,难免碰到“城会玩”
Prophet模型的简介以及案例分析
Tree-LSTM的一些理解以及DGL代码实现
F200 - UAV equipped with domestic open source flight control system based on Model Design
Splay
随机推荐
传输层 拥塞控制-慢开始和拥塞避免 快重传 快恢复
图片缩放中心
node の SQLite
Top command details
MSF horizontal MSF port forwarding + routing table +socks5+proxychains
1700C - Helping the Nature
Take you through ancient Rome, the meta universe bus is coming # Invisible Cities
Recommend easy-to-use backstage management scaffolding, everyone open source
F200 - UAV equipped with domestic open source flight control system based on Model Design
2022/02/12
CRMEB 商城系统如何助力营销?
Why does wechat use SQLite to save chat records?
关于这次通信故障,我想多说几句…
【剑指 Offer】 60. n个骰子的点数
模板于泛型编程之declval
C language exchanges two numbers through pointers
J'aimerais dire quelques mots de plus sur ce problème de communication...
MS-TCT:Inria&SBU提出用于动作检测的多尺度时间Transformer,效果SOTA!已开源!(CVPR2022)...
1700C - Helping the Nature
std::true_type和std::false_type