1 2 3 4 5 6 7 8 | int mod_timer(struct timer_list *timer, unsigned long expires) { …… if (timer->expires == expires && timer_pending(timer)) return 1; return __mod_timer(timer, expires); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | signed long __sched schedule_timeout(signed long timeout) { struct timer_list timer; unsigned long expire; …… expire = timeout + jiffies; setup_timer(&timer, process_timeout, (unsigned long)current); __mod_timer(&timer, expire); schedule(); del_singleshot_timer_sync(&timer); timeout = expire - jiffies; out: return timeout < 0 ? 0 : timeout; } |
1 2 3 4 | static void process_timeout(unsigned long __data) { wake_up_process((struct task_struct *)__data); } |
1 | #define del_singleshot_timer_sync(t) del_timer_sync(t) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | void tcp_init_xmit_timers(struct sock *sk) { inet_csk_init_xmit_timers(sk, &tcp_write_timer, &tcp_delack_timer, &tcp_keepalive_timer); } void inet_csk_init_xmit_timers(struct sock *sk, void (*retransmit_handler)(unsigned long), void (*delack_handler)(unsigned long), void (*keepalive_handler)(unsigned long)) { struct inet_connection_sock *icsk = inet_csk(sk); setup_timer(&icsk->icsk_retransmit_timer, retransmit_handler, (unsigned long)sk); …… } static inline void setup_timer(struct timer_list * timer, void (*function)(unsigned long), unsigned long data) { timer->function = function; timer->data = data; init_timer(timer); } |
1 2 3 4 5 6 7 8 9 10 11 | static int tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle) { struct tcp_sock *tp = tcp_sk(sk); struct sk_buff *skb; …… if (unlikely(tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC))) break; tcp_event_new_data_sent(sk, skb); …… return !tp->packets_out && tcp_send_head(sk); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |