当前位置:网站首页>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
边栏推荐
- CRMEB 商城系统如何助力营销?
- 测试123
- 2022暑期项目实训(三)
- The difference between parallelism and concurrency
- 78 year old professor Huake has been chasing dreams for 40 years, and the domestic database reaches dreams to sprint for IPO
- C language exchanges two numbers through pointers
- Introduction and case analysis of Prophet model
- Declval (example of return value of guidance function)
- 2022暑期项目实训(二)
- Recursive way
猜你喜欢
從交互模型中蒸餾知識!中科大&美團提出VIRT,兼具雙塔模型的效率和交互模型的性能,在文本匹配上實現性能和效率的平衡!...
Coco2017 dataset usage (brief introduction)
Ms-tct: INRIA & SBU proposed a multi-scale time transformer for motion detection. The effect is SOTA! Open source! (CVPR2022)...
IP, subnet mask, gateway, default gateway
从交互模型中蒸馏知识!中科大&美团提出VIRT,兼具双塔模型的效率和交互模型的性能,在文本匹配上实现性能和效率的平衡!...
【.NET CORE】 请求长度过长报错解决方案
Compilation Principle -- C language implementation of prediction table
Open source and safe "song of ice and fire"
CSRF漏洞分析
declval(指导函数返回值范例)
随机推荐
d绑定函数
UDP协议:因性善而简单,难免碰到“城会玩”
Four processes of program operation
STM32+ESP8266+MQTT协议连接OneNet物联网平台
Jerry's updated equipment resource document [chapter]
Introduction and case analysis of Prophet model
阿里云国际版ECS云服务器无法登录宝塔面板控制台
2022暑期项目实训(二)
ADB common commands
Codeforces Round #803 (Div. 2)
celery最佳实践
I want to say more about this communication failure
Automatic reservation of air tickets in C language
The latest financial report release + tmall 618 double top, Nike energy leads the next 50 years
Jerry's setting currently uses the dial. Switch the dial through this function [chapter]
Cocos2d Lua 越来越小样本 内存游戏
用友OA漏洞学习——NCFindWeb 目录遍历漏洞
Splay
转载:基于深度学习的工业品组件缺陷检测技术
DNS hijacking