易截截图软件、单文件、免安装、纯绿色、仅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”。


相关文档:

贪心安装64位linux的尴尬

administer@administer-laptop:~/tem/tt$ cat hello.asm
[section .data]
strHello db "Hello, world!",0Ah
STRLEN  equ $-strHello
[section .text]
global _start
_start: 
mov edx,STRLEN
mov ecx,strHello
mov ebx,1
mov eax,4
int  0x80
mov  ......

Linux下Apache的安装

地址:http://httpd.apache.org/
下载地址:http://httpd.apache.org/download.cgi
1,解压缩
tar -xzvf httpd-2.0.63.tar.gz
2,配置
./configure --prefix=/usr/local/apache --enable-module=all --enable-shared=max
3,编译
make
4,安装
make install
5,管理
apachectl start
apachectl stop
apachectl rest ......

Linux 守护进程的编程方法

http://www.softhouse.com.cn/linux/knowledge/tech/7320.html      
                                   ......

linux知识

学习Linux终端命令
linux目录架构
/   根目录
/bin    常用的命令 binary file 的目錄
/boot   存放系统启动时必须读取的档案,包括核心 (kernel) 在内
     /boot/grub/menu.lst   GRUB设置
     /boot/vmlinuz & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号