![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
printk("HZ is %d\n",HZ); timeout = jiffies + 5*HZ/100; printk(KERN_INFO"time_after test\r\n"); while(1) { if(time_after(jiffies,timeout)) { printk("timeout\n"); break; } else { printk("not timeout %ld\n",jiffies); } } printk(KERN_INFO"time_before test\r\n"); timeout = jiffies + 5*HZ/100; while(1) { if(time_before(jiffies,timeout)) { printk("not timeout %ld\n",jiffies); } else { printk("timeout\n"); break; } } printk(KERN_INFO"time_before_eq test\r\n"); timeout = jiffies + 5*HZ/100; while(1) { if(time_before_eq(jiffies,timeout)) { printk("not equal: timeout %ld,jiffies %ld\n",timeout,jiffies); } else { printk("equal\n"); break; } } printk(KERN_INFO"time_after_eq test\r\n"); timeout = jiffies + 5*HZ/100; while(1) { if(time_after_eq(jiffies,timeout)) { printk("equal\n"); break; } else { printk("not equal: timeout %ld,jiffies %ld\n",timeout,jiffies); } }
time_after(a,b) a>b:返回true
time_before(a,b) a<b:返回true
time_after_eq(a,b) a>=b:返回true
time_before_eq(a,b) a<=b :返回true
可以解决回绕,不要自己去瞎搞了。。。。。