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

Linux内核常用数据结构和操作

1. 前言
 
本文介绍linux内核中一些常用的数据结构和操作。
 
2. 双向链表(list)
 
linux内核中的双向链表通过结构 struct list_head来将各个节点连接起来,此结构会作为链表元素结构中的一个参数:
struct list_head {
 struct list_head *next, *prev;
};
 
链表头的初始化,注意,结构中的指针为NULL并不是初始化,而是指向自身才是初始化,如果只是按普通情况下的置为NULL,而不是指向自身,系统会崩溃,这是一个容易犯的错误:
 
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
 struct list_head name = LIST_HEAD_INIT(name)
#define INIT_LIST_HEAD(ptr) do { \
 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
 
最常用的链表操作:
插入到链表头:
void list_add(struct list_head *new, struct list_head *head);
 
插入到链表尾:
void list_add_tail(struct list_head *new, struct list_head *head);
 
删除链表节点:
void list_del(struct list_head *entry);
 
将节点移动到另一链表:
void list_move(struct list_head *list, struct list_head *head);
 
将节点移动到链表尾:
void list_move_tail(struct list_head *list,struct list_head *head);
 
判断链表是否为空,返回1为空,0非空
int list_empty(struct list_head *head);
 
把两个链表拼接起来:
void list_splice(struct list_head *list, struct list_head *head);
 
取得节点指针:
#define list_entry(ptr, type, member) \
 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
 
遍历链表中每个节点:
#define list_for_each(pos, head) \
 for (pos = (head)->next, prefetch(pos->next); pos != (head); \
         pos = pos->next, prefetch(pos->next))
 
逆向循环链表中每个节点:
#define list_for_each_prev(pos, head) \
 for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \
         pos = pos->prev, prefetch(pos->prev))
 
举例:
 
LISH_HEAD(mylist);
&n


相关文档:

linux下samba共享打印机


      先说需求,公司有一台型号为HP LaserJet m1120 mfp的打印机,由于不是网络打印机使用起来十分不便,公司老大要求将这台打印机连在公司的内网linux服务器上(CentOS),然后配置samba共享打印机。下面开工,主要分三大步骤,如符合你的需求,请继续阅读。
第一步,要保证你的打印机在linu ......

linux下安装jdk及配置环境变量

apache-tomact的安装
一.JDK的安装 
1. 先从网上下载jdk(jdk-1_5_0-linux-i586.rpm) ,推荐SUN的官方网站http://www.sun.com/,下载后放在/home目录中(可以使用winscp软件施行上传),当然其它地方也行。
进入安装目录
#cd /home
#cp jdk-1_5_0_-linux-i586.rpm.bin  /usr/local (拷贝命令)
#cd /usr/lo ......

Linux下查看磁盘空间的方法

df 是来自于coreutils 软件包,系统安装时,就自带的;我们通过这个命令可以查看磁盘的使用情况以及文件系统被挂载的位置。
举例:
[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 6.0G 4.4G 58% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/sda1 56G 22G 35G 39% /mnt/sda1 ......

什么是linux Qt


Qt 是一个跨平台的 C++ 图形用户界面库,由挪威 TrollTech 公司出品,目前包括Qt,
基于 Framebuffer 的 Qt Embedded,快速开发工具 Qt Designer,国际化工具 Qt Linguist 等部分
Qt 支持所有 Unix 系统,当然也包括 Linux,还支持 WinNT/Win2k,Win95/98 平台。

Trolltech 公司在 1994 年成立,但是在 19 ......

linux gcc 的编译过程 详解

gcc的编译过程分为四步,分别为:
(1)预编译 (Pre-Processing)
(2)编译 (Compiling)
(3)汇编 (Assembling)
(4)链接 (Linking)
以hello.c为例说明:
#include<stdio.h>
int main(void)
{
 printf("Hello World!");
 return 0;
}
(1)预编译阶段 (Pre-Processing)
&nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号