文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>学习内核第一天

学习内核第一天

时间:2006-07-06  来源:anhongkui

学习内核第一天,大致看了看linux内核里的双链表结构,并写了个简单的程序     #define __KERNEL__ #include <linux/list.h> struct mylist {
        struct list_head list;
        int index;
};
struct mylist top_conn; void
add_top_conn(struct mylist *list)
{
        list_add(&list->list, &top_conn.list);
}
void
print_top_conn(void)
{
        struct list_head *ptr;
        struct mylist *conn;
        for (ptr = top_conn.list.next; \
                ptr != &top_conn.list; ptr = ptr->next)
        {
                conn = list_entry(ptr, struct mylist, list);
                printf("index: %d \n", conn->index);
        }
}
int
main(void)
{
        struct mylist a;
        struct mylist b;
        struct mylist c;
        a.index=1;
        b.index=2;
        c.index=4;
        INIT_LIST_HEAD(&top_conn.list);
        add_top_conn(&a);
        add_top_conn(&b);
        add_top_conn(&c);
        print_top_conn();
        return 1;
}
相关阅读 更多 +
排行榜 更多 +
僵尸火车

僵尸火车

飞行射击 下载
飞机大战雷霆战机

飞机大战雷霆战机

飞行射击 下载
lonewolf

lonewolf

飞行射击 下载