麻烦看下程序:我是想验证一下linux下的udelay、mdelay、ndelay的延时时间时候真的是如n(单位)时间所示,但我用下面的程序,通过调用current_kernel_time();读取当前的时间,在delay前后打印出时间多少,但1us、1ms的时间差为何
s3c2410_gpio_cfgpin(S3C2410_GPG14,S3C2410_GPG14_OUTP);
s3c2410_gpio_setpin(S3C2410_GPG14,1);
ntime1=current_kernel_time();
printk(KERN_INFO"the ntime1.ctn is %ld\n",ntime1.tv_nsec);
udelay(100); //在终端没有显示延时的时间
ntime2=current_kernel_time();
printk(KERN_INFO"the ntime2.ctn is %ld\n",ntime2.tv_nsec);
s3c2410_gpio_setpin(S3C2410_GPG14,0);
ntime1=current_kernel_time();
printk(KERN_INFO"the ntime1.ctn is %ld\n",ntime1.tv_nsec);mdelay(1);
ntime2=current_kernel_time();
printk(KERN_INFO"the ntime2.ctn is %ld\n",ntime2.tv_nsec);
s3c2410_gpio_setpin(S3C2410_GPG14,1);
ntime1=current_kernel_time();
printk(KERN_INFO"the time1.ctn is %ld\n",ntime1.tv_sec);mdelay(1000);
ntime2=current_kernel_time();
printk(KERN_INFO"the time2.ctn is %ld\n",ntime2.tv_sec);
s3c2410_gpio_setpin(S3C2410_GPG14,0);
为何在终端打印出来的信息udelay没起到延时的效果。
[root@EmbedSky qdts]# ./test
OPEN SUCCESS!
the ntime1.ctn is 262755000
the ntime2.ctn is 262755000
the ntime1.ctn is 262755000
the ntime2.ctn is 262755000
the time1.ctn is 1630257097
the time2.ctn is 1630257098
[root@EmbedSky qdts]# ./test
OPEN SUCCESS!
the ntime1.ctn is 902755000
the ntime2.ctn is 902755000
the ntime1.ctn is 902755000
the ntime2.ctn is 902755000
the time1.ctn is 1630257109
the time2.ctn is 1630257110
[root@EmbedSky qdts]# ./test
OPEN SUCCESS!
the ntime1.ctn is 102755000
the ntime2.ctn is 102755000
the ntime1.ctn is 102755000
the ntime2.ctn is 102755000
the time1.ctn is 1630257125
the time2.ctn is 1630257126
是不是跟打印函数的调用需要时间?还是什么原因 |