linuxÄÚºË(2.6)ÖеÄË«Ñ»·Á´±ídzÎö
Linux 2.6ÄÚºËÁ´±íÊý¾Ý½á¹¹µÄʵÏÖ
ÔÚ¼ÆËã»ú¿ÆѧÖУ¬Á´±íÊǷdz£Í¨ÓõÄÊý¾Ý½á¹¹£¬¹á´©ÓÚÕû¸ölinuxµÄÄںˡ£ÔÚlinuxÄÚºËÖУ¬Á´±íͨ³£ÒÔ
Ë«Ñ»·Á´±íµÄ·½Ê½³öÏÖ¡£ËùÓÐÁ´±íµÄ´úÂëÔÚinclude/linux/list.hÎļþÖС£
¶¨ÒåÈçÏ£º
struct list_head {
struct list_head *next, *prev;
};
ÕâÀïµÄlist_headûÓÐÊý¾ÝÓò¡£ÔÚLinuxÄÚºËÁ´±íÖУ¬²»ÊÇÔÚÁ´±í½á¹¹Öаüº¬Êý¾Ý£¬¶øÊÇÔÚÊý¾Ý½á¹¹Öаüº¬Á´±í¡£
list.h»¹¶¨ÒåÁËÐí¶àʹÓõĺêºÍÄÚÁªº¯Êý£¬ÏÂÃæ½éÉܼ¸¸öµäÐ͵ģº
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
}
ÔÚlinuxµÄºê¶¨ÒåÖУ¬Ê±³£Óõ½do{}while(0)£¬ÕâÊÇΪÁË·½±ãÔٺ궨ÒåÖаüº¬¶àÐдúÂ룬
¹ØÓÚÕâ¸öµÄ˵Ã÷ÔÚÍøÉÏ¿ÉÒÔÕÒµ½ºÜ¶àÏêϸµÄ½éÉÜ¡£
ÔÚºêINIT_LIST_HEADÖУ¬½«Ëü³õʼ»¯ÎªÇ°ºó¶¼Ö¸Ïò×Ô¼º
ÔÚlinuxÄں˵ÄÁ´±íÖУ¬Ò»¸ö¿ÕÁ´±í¶¨ÒåÈçÏ£º head->nextÖ¸ÏòÁ´±íµÄÍ·ÔªËØ¡£
list.hÖл¹¶¨ÒåÁË list_add() £¬ list_add_tail()£¬list_del()µÈ»ù±¾µÄÁ´±í²Ù×÷º¯Êý£¬¶¼ÊDZȽϼòµ¥µÄ
CÓïÑÔÕâÀï²»ÏêÊö¡£
ÔÚlist.hÖм«ÆäÓÐÓõÄÒ»¸öºêÊÇlist_for_each_entry
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \
prefetch(pos->member.next), &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
Ëü¿ÉÒÔ±éÀúÕû¸öÁ´±í£¬ÔÚlinuxÓõķdz£¹ã·º£¬ÀýÈçµ±CPU¿ªÊ¼¹¤×÷ʱ£¬¼¤»îÔÚ¹¤×÷¶ÓÁÐÖеÄÿ¸ö½ø³Ì
-----------------------------------------------------------------------------
kernel/workqueue.c
59 struct workqueue_struct {
60 struct cpu_workqueue_struct cpu_wq[NR_CPUS];
61 const char *name;
62 struct list_head list; /* Empty if single thread */
63 };
...
466 case CPU_ONLINE:
467 /* Kick off worker threads. */
468 list_for_each_entry(wq, &workqueues, list)
469 &nb
Ïà¹ØÎĵµ£º
Ò»£ºÇ°ÑÔ
×î½üÔÚÑо¿androidµÄsensor driver£¬Ö÷ÒªÊÇE-compass£¬ÆäÖÐÓõ½ÁËLinux input×Óϵͳ.ÔÚÍøÉÏÒ²¿´Á˺ܶàÕâ·½ÃæµÄ×ÊÁÏ£¬¸Ð¾õ»¹ÊÇÕâƪ·ÖÎöµÄ±È½ÏϸÖÂ͸³¹£¬Òò´ËתÔØÒ»ÏÂÒÔ±ã×Ô¼ºÑ§Ï°£¬Í¬Ê±ºÍ´ó¼Ò·ÖÏí£¡
£¨Õâƪ²©¿ÍÖ÷ÒªÊÇÒÔ¼üÅÌÇý¶¯ÎªÀýµÄ£¬²»¹ý½²½âµÄÊÇLinux Input Subsystem£¬¿ÉÒÔ×ÐϸµÄÑо¿Ò»Ï£¡£©
¼üÅÌÇý¶¯½«¼ì ......
1. ѧ»áд¼òµ¥µÄmakefile
2. ±àһЩӦÓÃ
³ÌÐò
£¬¿ÉÒÔÓÃmakefileÅÜÆðÀ´
3. ѧ»áдÇý¶¯
µÄmakefile
4. дһ¼òµ¥charÇý¶¯£¬makefile±àÒëͨ¹ý£¬¿ÉÒÔinsmod£¬ lsmod£¬ rmmod. ÔÚÇý¶¯µÄinitº¯ÊýÀï´òÓ¡hello world£¬insmodºóÓ¦¸ÃÄܹ»Í¨¹ýdmesg¿´µ½Êä³ö
¡£
5. дһÍêÕûÇý¶¯£¬ ¼ÓÉÏread£¬ write£¬ ioctl£¬ pollingµÈ¸ ......
/ :¸ùĿ¼£¬ÊÇFHS½á¹¹ÖеÄ×²ãĿ¼¡£ÆäËüËùÓÐĿ¼¶¼ÊÇËüµÄ×ÓĿ¼£¬Ëü×ÜÊÇÒÔ¶ÀÁ¢µÄ·ÖÇø¹ÒÔØ¡£ÆäËüËùÓв»ÊÇÒÔ¶ÀÁ¢·ÖÇø¹ÒÔصÄĿ¼¶¼°üº¬Ôڴ˸ùĿ¼·ÖÇø¡£
/bin:°üº¬Ò»Ð©ÓÐÓõÄÃüÁîÐй¤¾ß¡£²»Äܱ»µ¥¶À¹ÒÔØΪһ¸ö·ÖÇø£¬·ñÔòÓûָ´ÅÌÐÞ¸´ÏµÍ³Ê±½«²»ÄÜ·ÃÎÊÕâЩÃüÁî¡£
/boot:°üº¬LinuxÆô¶¯Îļþ£¬°üº¬LinuxϵͳµÄÄÚº ......
ÔÎÄÁ´½Ó£ºhttp://www.trucy.org/blog/archives/eoiae/000087.html
GDBÊÇÒ»¸öÇ¿´óµÄÃüÁîÐе÷ÊÔ¹¤¾ß¡£´ó¼ÒÖªµÀÃüÁîÐеÄÇ¿´ó¾ÍÊÇÔÚÓÚ£¬Æä¿ÉÒÔÐγÉÖ´ÐÐÐòÁУ¬Ðγɽű¾¡£UNIXϵÄÈí¼þÈ«ÊÇÃüÁîÐеģ¬Õâ¸ø³ÌÐò¿ª·¢Ìá´ú¹©Á˼«´óµÄ±ãÀû£¬ÃüÁîÐÐÈí¼þµÄÓÅÊÆÔÚÓÚ£¬ËüÃÇ¿ÉÒԷdz£ÈÝÒ׵ļ¯³ÉÔÚÒ» ......
Ò»¡¢ÏÂÔØ
gd-2.0.33.tar.gz http://www.boutell.com/gd/
jpegsrc.v6b.tar.gz http://www.ijg.org/
libpng-1.2.7.tar.tar http://sourceforge.net/projects/libpng/
zlib-1.2.2.tar.gz http://sourceforge.net/projects/zlib/
freetype-2.1.9.tar.gz http://sourceforge.net/projects/freetype/
php-4.3.9.tar.g ......