当前位置:网站首页>epoll()无论涉及wait队列分析
epoll()无论涉及wait队列分析
2022-07-06 10:20:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
事件1. epfd-file->eventpoll->wq:
struct eventpoll { … wait_queue_head_t wq; //用于epoll_pwait()事件的等待队列 情况1分析 struct list_head rdllist; //就绪的fd队列 ready list struct rb_root rbr; //红黑树根,epitem->rbn为红黑树结构的节点 struct file *file; //epoll文件系统中构建的虚拟文件 … }; 主要用于epoll_pwait()时候,判定epfd-file->eventpoll->rdlist(就绪fd)是否为空。假设为空而且epoll_pwait()为堵塞调用。那么将当前进程将被挂到epfd-file->eventpoll->wq中,而且当前进程进入堵塞等待,直到rdlist非空的时候唤起epfd-file->eventpoll->poll_wait链表中的进程(相互排斥唤起和非相互排斥唤起?)唤起的回调函数默觉得wake_up_interruptible或者wake_up
情况2.被监听的fd->poll_wait
将被监听套接字fd在epoll期间构建的epitem和eppoll_entry epitem{ struct rb_node rbn; //epitem挂在rbtree上的节点信息 struct list_head rdllink; //假设fd就绪,将挂入ready list struct eventpoll *ep; //所属主eventpoll(维护rbtree rdllist poll_wait队列…) struct epoll_event event; //fd上监听的事件 } struct eppoll_entry { struct list_head llink; struct epitem *base; //所属epitem wait_queue_t wait; //作为一元素挂入被监听fd的wait队列中 wait_queue_head_t *whead; //被监听fd的等待队列。假设fd为socket。那么whead为sock->sk_sleep }; eppoll_entry主要完毕epitem和epitem事件发生时的callback函数之间的关联。 首先将eppoll_entry的whead指向fd的设备等待队列(同select中的wait_address)。 然后初始化eppoll_entry的base变量指向epitem。 最后通过add_wait_queue将epoll_entry挂载到fd的设备等待队列上。 当在设备硬件数据到来时,硬件中断处理函数中会唤醒该等待队列上等待的进程时,会调用唤醒函数ep_poll_callback(ep_poll_callback: 当fd上出发事件后。将epitem中的rdllink节点增加到readlist中(epfd-file->eventpoll->rdlist))
对照:
1和2对照,主要是等待队列的回调函数用处不同,1的回调是为了唤起处于等待事件而处于休眠的进程,2的回调是为了将epitem中的rdllink结构增加到ready list中。
參考: http://www.cnblogs.com/apprentice89/archive/2013/05/09/3068274.html http://www.cnblogs.com/apprentice89/p/3234677.html
版权声明:本文博客原创文章。博客,未经同意,不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117402.html原文链接:https://javaforall.cn
边栏推荐
- 图片缩放中心
- 解读云原生技术
- Excellent open source fonts for programmers
- D binding function
- Distill knowledge from the interaction model! China University of science and Technology & meituan proposed virt, which combines the efficiency of the two tower model and the performance of the intera
- 2022暑期项目实训(三)
- I want to say more about this communication failure
- HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
- Dichotomy (integer dichotomy, real dichotomy)
- Jerry's watch reading setting status [chapter]
猜你喜欢
编译原理——自上而下分析与递归下降分析构造(笔记)
關於這次通信故障,我想多說幾句…
Coco2017 dataset usage (brief introduction)
传输层 拥塞控制-慢开始和拥塞避免 快重传 快恢复
C language exchanges two numbers through pointers
Maixll-Dock 摄像头使用
Today in history: the mother of Google was born; Two Turing Award pioneers born on the same day
UDP协议:因性善而简单,难免碰到“城会玩”
Rb157-asemi rectifier bridge RB157
【.NET CORE】 请求长度过长报错解决方案
随机推荐
最新财报发布+天猫618双榜第一,耐克蓄力领跑下个50年
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
win10系统下插入U盘有声音提示却不显示盘符
带你穿越古罗马,元宇宙巴士来啦 #Invisible Cities
当保存参数使用结构体时必备的开发技巧方式
C语言高校实验室预约登记系统
從交互模型中蒸餾知識!中科大&美團提出VIRT,兼具雙塔模型的效率和交互模型的性能,在文本匹配上實現性能和效率的平衡!...
Brief description of SQL optimization problems
重磅硬核 | 一文聊透对象在 JVM 中的内存布局,以及内存对齐和压缩指针的原理及应用
面试突击62:group by 有哪些注意事项?
Recommend easy-to-use backstage management scaffolding, everyone open source
Virtual machine VirtualBox and vagrant installation
Grafana 9.0 正式发布!堪称最强!
Olivetin can safely run shell commands on Web pages (Part 1)
The difference between parallelism and concurrency
Redis的五种数据结构
Distill knowledge from the interaction model! China University of science and Technology & meituan proposed virt, which combines the efficiency of the two tower model and the performance of the intera
[swoole series 2.1] run the swoole first
Common - magic number 7
Getting started with pytest ----- test case pre post, firmware