tcp + epoll 内核睡眠唤醒时序流程
2023-02-11 11:16:06 0 举报
主要描述 tcp 三次握手后,内核如何唤醒进程处理链接。 对应博客文章:tcp + epoll 内核睡眠唤醒工作流程 链接:https://wenfh2020.com/2021/12/16/tcp-epoll-wakeup/
作者其他创作
大纲/内容
3
epoll_filefd
+ file : struct file+ fd : int
server
sock
+ sk_wq : struct socket_wq*
TCP_NEW_SYN_RECV
ep_send_events
SYN
epoll_wait
socket
seq = x
tail
ACK
TCP_SYN_SENT
rbr
1
TCP_CLOSE
epoll_ctl
8
new socket
7
wake_up_locked(&ep->wq);
epi
tcp_poll
__add_wait_queue_exclusive
TASK_RUNNING
accept
2
eppoll_entry
base : struct epitem*llink : struct list_head whead : wait_queue_head_t *wait : wait_queue_entry_t
ep_poll_callback
wake_up_interruptible_all
w2
ep_pqueue
+ pt : poll_table+ epi : epitem*
TASK_INTERRUPTIBLE
5
9
6
4
driver
TCP_SYN_RECV
wait_queue_entry
entry : struct list_headfunc : wait_queue_func_t
__remove_wait_queue
TCP_ESTABLISHED
+ file :struct file*+ wq : struct socket_wq+ sk : struct sock*
epitem
head
tcp_v4_rcv
eventpoll
+ wq : wait_queue_head_t+ rdllist : list_head+ rbr : rb_root_cached+ file : file*
ep_ptable_queue_proc
wait_queue_head
+ lock : spinlock_t+ head : struct list_head
bind
connect
半连接队列
sock_def_wakeup
client
epoll_create
task_struct
+ files : struct files_struct *
listen
socket_wq
+ wait : wait_queue_head_t
sleep
全连接队列
schedule_hrtimeout_range
wenfh2020.comLinux 5.0.1
ep_item_poll
wakeup
SYN+ACK
w1
poll_table
+ _key : __poll_t+ _qproc : poll_queue_proc
ack = y + 1
ep_insert
TCP_LISTEN
0 条评论
下一页