浅谈linux内核中的list.h[2]
链表的删除
83/*
84 * Delete a list entry by making the prev/next entries
85 * point to each other.
86 *
87 * This is only for internal list manipulation where we know
88 * the prev/next entries already!
89 */
90static inline void __list_del(struct list_head * prev, struct list_head * next)
91{
92 next->prev = prev;
93 prev->next = next;
94}
该函数通过设置prev和next指针指向彼此,实现了删除二者之间节点的功能。但是这里我有个疑惑,删除的指针的释放在哪里实现。
96/**
97 * list_del - deletes entry from list.
98 * @entry: the element to delete from the list.
99 * Note: list_empty() on entry does not return true after this, the entry is
100 * in an undefined state.
101 */
102#ifndef CONFIG_DEBUG_LIST
103static inline void list_del(struct list_head *entry)
104{
105 __list_del(entry->prev, entry->next);
106 entry->next = LIST_POISON1;
107 entry->prev = LIST_POISON2;
108}
109#else
110extern void list_del(struct list_head *entry);
111#endif
该函数通过调用上面的内联函数实现节点的删除,这里的LIST_POISON1和LIST_POISON2是在linux/poison.h定义的。此处仍然是条件编译。
链表节点的置换
113/**
114 * list_replace - replace old entry by new one
115 * @old : the element to be replaced
116 * @new : the new element to insert
117 *
118 * If @old was empty, it will be overwritten.
119 */
120static inline void list_replace(struct list_head *old,
121 struct list_head *new)
122{
123 new->next = old->next;
124 new->next->prev = new;
125 new->prev = old->prev;
126 new->prev->next = new;
127}
128
129static inline void list_replace_init(struct list_head *old,
130 struct list_head *new)
131{
132 list_replace(old, new);
133 INIT_LIST_HEAD(old);
134}
静态内联函数list_replace接受两个参数:old和new,并通过new替换old。而list_replace_init函数则是通过调用list_replace进行替换,之后调用INIT_LIST_HEAD对被替换的old进行链表初始化。
链表的移动
146/**
147 * list_move - delete from one list
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
Intel 集成显卡的Linux驱动安装
目前使用Intel 集成显卡的计算机主要集中在中低端商务台式机和中低端笔记本电脑。这里介绍一下Linux下显卡驱动安装方法。Intel针对集成显示芯片提供了两种驱动程序:i915Graphics和i810Graphics。
一、 使用82830M, 82845G, 82852GM, 82855GM, 82865G, 82915G芯 ......
一、cd用来进入指定的某个目录。
说cd这个命令是Linux上使用率最高的两个命令之一不为过吧(另一个当然是ls了),前两天看到了一个cd命令的小技巧是我一直都不知道的,呵呵,这里顺便记下来。
cd - #回到上次所在目录,感觉还是比较有用,省略了很多输入。
cd !$ ......
~ 当前用户目录的缩写
cd ~
cd /home/<user-name>/
--help 获取帮助
vi --help
tab 自动补全。双击tab给出补全提示。
若当前命令无歧义,则完整补全。若有歧义双击可列出提示选项。
cd /e [tab], 补全为cd /etc/
cd /b [tab-tab], 列出选项bin/ bo ......
在linux中,运行的一个进程,会占去linux的三个地方,代码区,堆栈区和数据区.如果同时运行多个相同的程序,他们就会使用相同的代码区,代码区中存放的就程序的代码,但是数据区和堆栈区分别存放的是程序的数据,全局变量和局部变量,因此即使是相同的程序,也不可同时使用相同的数据和堆栈区.
#include<stdio.h>
#incl ......