The Linux Kernel Module Programming Guide
http://www.faqs.org/docs/kernel/
µÄ11ºÍ12ÔÙÊÔÊÔ¡£
Linux Äں˵ÄWorkQueues API×öÁËÐÞ¸Ä
WorkQueue»úÖÆÔÊÐíÄں˴úÂëÔÚÍíÒ»µãµÄʱ¼äÖ´ÐС£Workqueueͨ¹ý´æÔÚµÄÒ»¸ö»òÕ߶à¸öרÃŵĽø³ÌʵÏÖ£¬È¥Ö´ÐжÓÁй¤×÷¡£ÒòΪÔÚ½ø³ÌµÄÉÏÏÂÎÄ»ã×ÜÖ´ÐУ¬Òò´ËÈç¹ûÐèÒª£¬Æä¿ÉÒÔsleep¡£WorkQueueÒ²¿ÉÒÔÑÓ³ÙÌض¨Ê±¼äÖ´Ðй¤×÷¡£ËùÒÔËüÃÇÔÚÄÚºËÖÐÐí¶àµØ·½Ê¹Óá£
David Howells×î½ü¼ì²éworkqueueʱ·¢ÏÖwork_struct£¨ÓÃÀ´ÃèÊöÒ»¸ö³ÌÐòÖ´ÐУ©ÊÇÏ൱´óµÄ£¬ÔÚ64-bit»úÆ÷ÉÏÓÐ96bytes£¬ÕâÊÇÏ൱´óµÄÊý¾Ý½á¹¹£¬ÒòΪºÜ¶àµØ·½¶¼Ê¹ÓÃÕâ¸ö½á¹¹¡£Òò´ËËûÏë³ö°ì·¨°ÑËüÃDZäС£¬Ëû³É¹¦Á˵«ÊÇÐèÒª¸Ä¶¯workqueueµÄAPI.
µ¼ÖÂstruct work_structÓ·Ö×µÄÔÒòÊÇ£º
1.ÆäÖÐËù°üº¬timer structure¡£Ðí¶àworkqueueµÄÓû§´ÓÀ´²»Ê¹ÓÃÕâ¸ödelayÌØÐÔ£¬µ«ÊÇÔڽṹÌåÄÚ¶¼°üº¬timer_list½á¹¹¡£
2.˽ÓÐÊý¾ÝÖ¸Õ룬ÕâÊÇ´«µÝ¸øworkº¯ÊýµÄ²ÎÊý¡£Ðí¶àº¯ÊýʹÓÃÕâ¸öÖ¸Õ룬µ«ÊÇËüͨ³£¿ÉÒÔ´Ówork_structÖ¸ÕëÖÐÓÃcontain_of()¼ÆËã³öÀ´¡£
3.Ò»¸öwordÖ»ÓÃÒ»¸öbitÀ´±íʾpending£¬ÓÃÀ´ËµÃ÷Õâ¸öwork_structÄ¿Ç°ÔÚ¶ÓÁÐÉϵȴýÖ´ÐС£
David´¦ÀíÁËÒÔÉϵÄÇé¿ö£¬Ê¹ÓÃÁËÒ»ÖÖеĽṹÌåstruct delayed_work£¬×¨ÃÅÓÃÓÚÑÓʱµ÷ÓÃʹÓ᣶ø°Ñstruct work_structureÖеÄtimer½á¹¹Ìåɾ³ýÁË¡£Ë½ÓÐÊý¾ÝÖ¸ÕëÏûʧÁË£¬workº¯ÊýʹÓÃÒ»¸öÖ¸Ïòwork_structureµÄÖ¸Õ룬typedef void (*work_func_t)(struct work_struct *work)¡£Ê¹ÓÃһЩ¼¼ÇÉɾ³ýÁËpending word¡£ÕâЩ±ä¶¯µÄ½á¹ûʹµÃworkqueueµÄAPI·¢ÉúÁ˱仯¡£ÓÐÁ½ÖÖ·½·¨ÉùÃ÷Ò»¸öworkqueueµÄentry¡£
DECLARE_WORK(name, func);
DECLARE_DELAYED_WORK(name, func);
¶ÔÓÚÔÚÔËÐÐʱÉú³ÉµÄwork structure£¬³õʼ»¯ºêÏÖÔÚÈçÏ£º
INIT_WORK(struct work_struct work, work_func_t func);
PREPARE_WORK(struct work_struct work, work_func_t func);
INIT_DELAYED_WORK(struct delayed_work work, work_func_t func);
PREPARE_DELAYED_WORK(struct delayed_work work, work_func_t func);
INIT_*°æ±¾µÄºê³õʼ»¯Õû¸ö½á¹¹£¬ËüÃDZØÐëÔÚÕâ¸ö½á¹¹µÚÒ»´Î³õʼ»¯µÄʱºòʹÓã¬PREPARE_*°æ±¾µÄºêÔËÐÐËÙ¶ÈÉÔ΢¿ìЩ¡£
The functions for adding entries to workqueues (and canceling them) now look like this:
int queue_work(struct workqueue_struct *queue,
Ïà¹ØÎĵµ£º
1. HCI²ãÐÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI) ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈÐÒé ......
Î壺kmem_cache_create£¨£©·ÖÎö
ÎÒÃÇÒÔÒ»¸öÀý×ÓÀ´¸ú×Ù·ÖÎöÒ»ÏÂslabµÄ»úÖÆ£º
ÏÂÃæÊÇÒ»¸ö²âÊÔÄ£¿éµÄ´úÂ룺
#include <linux/config.h>
#include <linux/module.h>
#include <linux/slab.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("ericxiao <xgr178@163.com>");
MODULE_DESCRI ......
Áù£ºkmem_cache_allocµÄʵÏÖ·ÖÎö:
ÎÒÃÇÔÚÉÏÃæ¿ÉÒÔ¿´µ½£¬´´½¨Ò»¸öcacheÃèÊö·ûµÄʱºò£¬²¢Ã»ÓÐÕâÖ®·ÖÅäslabÊý¾Ý¡£ÏÖÔÚÎÒÃÇÀ´¿´Ò»ÏÂÔõô´ÓcacheÖÐÉêÇë¶ÔÏó
void * kmem_cache_alloc (kmem_cache_t *cachep, int flags)
{
return __cache_alloc(cachep, flags);
}
ʵ¼ÊÉÏ»áµ÷ÓÃ__cache_allo ......
µãÆÀ£º°²×°Èí¼þ°ü rpm -i °üÈ«Ãû ɾ³ý rpm -e name(²»ÊÇ°üÃû) ²ÎÊý -ivh »ñµÃÒ»¸öÏêϸµÄ°²×°½ø³Ì --nodeps ºöÂÔÒÀÀµ¹Øϵ --force Ç¿ÖÆ°²×° -U °üÃû:Éý¼¶°²×° -F ¸üв»¹ÜÊÇʲôֱ½Ó¸²¸Ç --replacepkgsÕâÑù RPM ½«ºöÂԸôíÎóÐÅÏ¢ -vih --repla
ÄÚÈÝÀ´×Ô: ½Å±¾Ö®¼Ò www.jb51.net
°²×°Èí¼þ°ü
rpm -i °üÈ ......
Ò»¡¢ÒªÇó£º
1¡¢Äܹ»ÏÔʾ³öMakefileµÄ×ÜÊý
2¡¢ÄÜÏÔʾһ¼¶Ä¿Â¼ÏµÄMakefile×ÜÊý¡¢MakefileÁÐ±í¼°ÆäMakefileµÄÄÚÈÝ
3¡¢Äܽ«ÉÏÊöÄÚÈÝдÈëÏàÓ¦µÄÎļþ
¶þ¡¢ÊµÀý
rm -rf ~/Desktop/linux_Makefile/*
for i in `find . -maxdepth 1 -type d`
#½ö½öÊǵ±Ç°Ä¿Â¼£¬ËùÒÔÇ뽫±¾½Å±¾·ÅÔÚlinuxÔ´ÂëĿ¼ÏÂÖ´ÐС£
do
e ......