文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>用户空间(userspace)引用jiffies

用户空间(userspace)引用jiffies

时间:2009-05-14  来源:hhtr001

用户空间(userspace)引用jiffies

写在前面,该方法并非原创,乃是根据csdn中一网友回帖改编而来。此方法可以推广,用以引用任何内核中的资源。
http://topic.csdn.net/u/20080905/12/a3355510-636e-4519-8205-dc482e07e8c8.html

#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main ()
{
    unsigned long offset = 0xc06e1740; /* 0xc06e1740 is from

                                        * /boot/System.map-2.6.xx
                                        * c06e1740 D jiffies
                                        */

    offset -= 0xc0000000;

    int fd;
    fd = open("/dev/mem", O_RDONLY);

    void *p;
    p = mmap(0, 0x10000, PROT_READ, MAP_SHARED, fd, (off_t)(offset - offset%0x10000));

    volatile unsigned long *pJiffies;
    pJiffies = (volatile unsigned long *)((char *)p + offset%0x10000);
    
    int i;
    for (i = 0; i < 1000; i++)
    {
     printf ("jiffies = %ul\n",(unsigned long)(*pJiffies));
    }
}

排行榜 更多 +
山雾搜剧 1.0.0

山雾搜剧 1.0.0

系统软件 下载
漫千绘

漫千绘

浏览阅读 下载
快找资源plu

快找资源plu

系统软件 下载