linux内核中sys_poll()的简化分析

app:poll or select;

kernel: sys_poll(); do_sys_poll(
struct pollfd __user *ufds, unsigned int nfds,struct timespec *end_time); poll_initwait(&table); init_poll_funcptr(&pwq->pt, __pollwait);>table->qproc =__pollwait; do_poll(nfds, head, &table, end_time); for (;;) { if (do_pollfd(pfd, pt)) { //mask = file->f_op->poll(file, pwait);return mask ----调用驱动中的poll函数 count++;//如果驱动的poll函数返回非零,那么count++ pt = NULL; } //break条件:count非零,超时,有信号等待处理 if (count || ! timed_out||signal_pending(current)) break; //休眠__timeout,期间没事发生,则timed_out减为零,再次循环,break //休眠期间被中断唤醒等待队列,则再次循环,执行驱动中的poll,返回非零mask, 则break __timeout=schedule_timeout(__timeout); }

 

转载于:https://www.cnblogs.com/hello2mhb/p/3325315.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值