⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linux设备驱动程序学习(10)-时间、延迟及延缓操作 - linux设备驱动程序 - tekkaman ninja.htm

📁 Linux设备驱动程序学习(10)-时间、延迟及延缓操作 - Linux设备驱动程序.rar
💻 HTM
📖 第 1 页 / 共 5 页
字号:
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">long</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>b<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">-</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">long</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>a<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">&lt;</SPAN> 0<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><BR><SPAN 
                                style="COLOR: rgb(0,0,204)">#</SPAN><SPAN 
                                style="COLOR: rgb(255,0,0)">define</SPAN> 
                                time_before<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>a<SPAN 
                                style="COLOR: rgb(0,0,204)">,</SPAN>b<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;time_after<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>b<SPAN 
                                style="COLOR: rgb(0,0,204)">,</SPAN>a<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><BR><SPAN 
                                style="COLOR: rgb(0,0,204)">#</SPAN><SPAN 
                                style="COLOR: rgb(255,0,0)">define</SPAN> 
                                time_after_eq<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>a<SPAN 
                                style="COLOR: rgb(0,0,204)">,</SPAN>b<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;\<BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>typecheck<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">unsigned</SPAN> 
                                <SPAN 
                                style="COLOR: rgb(0,0,255)">long</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">,</SPAN> a<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">&amp;</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">&amp;</SPAN> 
                                \<BR>&nbsp;&nbsp;&nbsp;&nbsp; typecheck<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">unsigned</SPAN> 
                                <SPAN 
                                style="COLOR: rgb(0,0,255)">long</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">,</SPAN> b<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">&amp;</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">&amp;</SPAN> 
                                \<BR>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">long</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>a<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">-</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">long</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>b<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">&gt;</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">=</SPAN> 0<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><BR><SPAN 
                                style="COLOR: rgb(0,0,204)">#</SPAN><SPAN 
                                style="COLOR: rgb(255,0,0)">define</SPAN> 
                                time_before_eq<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>a<SPAN 
                                style="COLOR: rgb(0,0,204)">,</SPAN>b<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;time_after_eq<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN>b<SPAN 
                                style="COLOR: rgb(0,0,204)">,</SPAN>a<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN></FONT></SPAN></CODE></P></TD></TR></TBODY></TABLE></P>
                              <P>用户空间的时间表述法(struct timeval 和 struct timespec 
                              )与内核表述法的转换函数:</P>
                              <TABLE style="BORDER-COLLAPSE: collapse" 
                              borderColor=#999999 cellSpacing=0 cellPadding=0 
                              width="95%" bgColor=#f1f1f1 border=1>
                                <TBODY>
                                <TR>
                                <TD>
                                <P 
                                style="MARGIN: 5px; LINE-HEIGHT: 150%"><CODE><SPAN 
                                style="COLOR: rgb(0,0,0)"><SPAN 
                                style="COLOR: rgb(0,0,204)">#</SPAN><SPAN 
                                style="COLOR: rgb(255,0,0)">include</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">&lt;</SPAN>linux<SPAN 
                                style="COLOR: rgb(0,0,204)">/</SPAN><SPAN 
                                style="COLOR: rgb(255,0,0)">time</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">.</SPAN>h<SPAN 
                                style="COLOR: rgb(0,0,204)">&gt;</SPAN> <SPAN 
                                style="COLOR: rgb(255,153,0)">/* #include 
                                &lt;linux/jiffies.h&gt; --&gt; 
                                \kernel\time.c*/</SPAN><BR><BR><SPAN 
                                style="COLOR: rgb(0,0,255)">struct</SPAN> <SPAN 
                                style="COLOR: rgb(255,0,0)">timespec</SPAN> 
                                <SPAN 
                                style="COLOR: rgb(0,0,204)">{</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN 
                                style="COLOR: rgb(255,0,0)">time_t</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;tv_sec<SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN 
                                style="COLOR: rgb(255,153,0)">/* seconds 
                                */</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN 
                                style="COLOR: rgb(0,0,255)">long</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;tv_nsec<SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN 
                                style="COLOR: rgb(255,153,0)">/* nanoseconds 
                                */</SPAN><BR><SPAN 
                                style="COLOR: rgb(0,0,204)">}</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN><BR><SPAN 
                                style="COLOR: rgb(0,0,204)">#</SPAN><SPAN 
                                style="COLOR: rgb(255,0,0)">endif</SPAN><BR><BR><SPAN 
                                style="COLOR: rgb(0,0,255)">struct</SPAN> <SPAN 
                                style="COLOR: rgb(255,0,0)">timeval</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">{</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN 
                                style="COLOR: rgb(255,0,0)">time_t</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tv_sec<SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN 
                                style="COLOR: rgb(255,153,0)">/* seconds 
                                */</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;suseconds_t&nbsp;&nbsp;&nbsp;&nbsp;tv_usec<SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN 
                                style="COLOR: rgb(255,153,0)">/* microseconds 
                                */</SPAN><BR><SPAN 
                                style="COLOR: rgb(0,0,204)">}</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN><BR><BR><SPAN 
                                style="COLOR: rgb(0,0,255)">unsigned</SPAN> 
                                <SPAN style="COLOR: rgb(0,0,255)">long</SPAN> 
                                timespec_to_jiffies<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">struct</SPAN> <SPAN 
                                style="COLOR: rgb(255,0,0)">timespec</SPAN> 
                                <SPAN 
                                style="COLOR: rgb(0,0,204)">*</SPAN>value<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN><BR><SPAN 
                                style="COLOR: rgb(0,0,255)">void</SPAN> 
                                jiffies_to_timespec<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">unsigned</SPAN> 
                                <SPAN style="COLOR: rgb(0,0,255)">long</SPAN> 
                                jiffies<SPAN 
                                style="COLOR: rgb(0,0,204)">,</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,255)">struct</SPAN> <SPAN 
                                style="COLOR: rgb(255,0,0)">timespec</SPAN> 
                                <SPAN 
                                style="COLOR: rgb(0,0,204)">*</SPAN>value<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN><BR><SPAN 
                                style="COLOR: rgb(0,0,255)">unsigned</SPAN> 
                                <SPAN style="COLOR: rgb(0,0,255)">long</SPAN> 
                                timeval_to_jiffies<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">struct</SPAN> <SPAN 
                                style="COLOR: rgb(255,0,0)">timeval</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">*</SPAN>value<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN><BR><SPAN 
                                style="COLOR: rgb(0,0,255)">void</SPAN> 
                                jiffies_to_timeval<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">unsigned</SPAN> 
                                <SPAN style="COLOR: rgb(0,0,255)">long</SPAN> 
                                jiffies<SPAN 
                                style="COLOR: rgb(0,0,204)">,</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,255)">struct</SPAN> <SPAN 
                                style="COLOR: rgb(255,0,0)">timeval</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">*</SPAN>value<SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN></SPAN></CODE></P></TD></TR></TBODY></TABLE>
                              <P>访问jiffies_64 对于 32-位 
                              处理器不是原子的,这意味着如果这个变量在你正在读取它们时被更新你可能读到错误的值。若需要访问jiffies_64,内核有一个特别的辅助函数,为你完成适当的锁定: 
                              </P>
                              <P>
                              <TABLE style="BORDER-COLLAPSE: collapse" 
                              borderColor=#999999 cellSpacing=0 cellPadding=0 
                              width="95%" bgColor=#f1f1f1 border=1>
                                <TBODY>
                                <TR>
                                <TD>
                                <P 
                                style="MARGIN: 5px; LINE-HEIGHT: 150%"><CODE><SPAN 
                                style="COLOR: rgb(0,0,0)"><FONT face=新宋体><SPAN 
                                style="COLOR: rgb(0,0,204)">#</SPAN><SPAN 
                                style="COLOR: rgb(255,0,0)">include</SPAN> <SPAN 
                                style="COLOR: rgb(0,0,204)">&lt;</SPAN>linux<SPAN 
                                style="COLOR: rgb(0,0,204)">/</SPAN>jiffies<SPAN 
                                style="COLOR: rgb(0,0,204)">.</SPAN>h<SPAN 
                                style="COLOR: rgb(0,0,204)">&gt;</SPAN> <BR>u64 
                                get_jiffies_64<SPAN 
                                style="COLOR: rgb(0,0,204)">(</SPAN><SPAN 
                                style="COLOR: rgb(0,0,255)">void</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">)</SPAN><SPAN 
                                style="COLOR: rgb(0,0,204)">;</SPAN></FONT></SPAN></CODE></P></TD></TR></TBODY></TABLE></P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -