易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux的内核延迟函数

当内核需要等待一个比较短的时间间隔时,比方说:有时候设备驱动器会等待预先定义的若干个微妙的时间直到硬件完成某些操作。由于动态定时器通常有很大的设置开销和一个相当大的最小等待时间(1ms),所以设备驱动器使用它会很不方便。
在这些情况下,内核使用udelay()和ndelay()函数:前者接收一个微妙级的时间间隔作为它的参数,并在指定的延迟结束后返回;而后者所接收的指定延迟的参数是纳秒级的,同样在指定的延迟结束后返回。
udelay()和ndelay()这两个函数定义如下:
void udelay(unsigned long usecs)
{
    unsigned long loops;
    loops = (usecs*HZ*current_cpu_data.loops_per_jiffy)/1000000;
    cur_timer->delay(loops);
}
void ndelay(unsigned long nsecs)
{
    unsigned long loops;
    loops = (nsecs*HZ*current_cpu_data.loops_per_jiffy)/1000000000;
    cur_timer->delay(loops);
}
    这两个函数都是依赖与cur_timer定时器对象的delay方法,它接收“loops”中的时间间隔作为参数。每一次“loop”精确的持续时间取决于cur_timer涉及的定时器对象。
【如果cur_timer指向time_hpet、time_pmtmr和timer_tsc对象,那么一次“loop”时间对应一个CPU循环——也就是两个连续CPU时钟信号间的时间间隔。】
【如果cur_timer指向timer_none或timer_pit对象,那么一次“loop”时间对应一条紧凑指令循环在一次单独的循环中所花费的时间。】
     始化阶段,select_timer()设置好cur_timer后,内核通过执行calibrate_delay()函数来决定一个节拍里有多少次“loop”。这个值被保存在current_cpu_data.loops_per_jiffy变量中,这样udelay()和ndelay()就能根据它来把微妙和纳秒转换成“loops”。


相关文档:

Linux Kernel API (2.6)

#protect share data
spin_lock/spin_unlock: protect the data during process context(and only at process context), and make sure your code bewteen lock/unlock is fast enough.There may deadlock if the same spin_lock is called at interrupt context.
spin_lock_irq/spin_unlock_irq: call it during interru ......

Linux的工作队列

1,先看看工作队列和tasklet的区别:
    (1) 定时器和tasklet:
    Tasklets resemble kernel timers in 3 ways.
      1)They are always run at interrupt time,
      2)they always run on the same CPU that schedules the ......

VMware下Windows与Linux文件共享

此处vmware版本为6.5 ,主机为windows xp,vmware 安装了redhat linux
1.网络设置:
打开vmware,点vmware->setting->Hardware->Newwork Adapter->Custom - >
VMnet1(host-only) 
查看windows网络连接,看到一个VMnet1的连接,设置它的ip与子网掩码。如:IP:192.168.13.1 ,子网掩码 255.255.255.0 ......

学用Linux命令

学用Linux命令
2006-01-23 11:18:22 虫子虫子爬@-FiFb /article/-FiFb-liXUWS.html 复制 评论
基础教程-学用Linux命令(1)
Linux虽然是免费的,但它的确是一个非常优秀的操作系统,与MS-WINDOWS相比具有可靠、稳定、速度快等优点,且拥有丰富的根据UNIX版本改进的强大功能。下面,作为一个典型的DOS 和WINDOWS用户, ......

SUSE Linux 维护笔记二

1.实现外网访问内网的远程桌面
单位机器服务器的IP地址是10.3.198.108,可以上外网,路由器上设置了内网的外网映射地址,内网的地址是192.168.0.*
现在要实现从10.x.x.x的校园网内访问或者从internet网络上访问 192.168.0.*的远程桌面
方法如下
下载rinetd
vi /etc/rinetd.conf
--------------------------------------- ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号