Linux Kernel時ÐòµÄÈý種機ÖÆ
×î½üÔÚ寫Driver時£¬³£³£Óöµ½ÐèÒª¡¸µÈ´ýÒ»¶Î時間¡¹ÔÙ處ÀíµÄ動×÷£¬ÒÔÍùÎÒ¶¼ÉµÉµµÄÓÃmsleep()»òmdelay()£¬Êâ²»Öª這種busy waiting會holdסcpu資Ô´£¬ÔÚ這¶ÎÆÚ間內¶¼無·¨讓給ÆäËûprocess執ÐУ¬時間¶Ì(10msÒÔϵÈ級)»ò許還¿ÉÒÔ£¬Ì«長¾Í²»ÐÐÁË£¬ËùÒÔÐèÒªKernel±¾Éí¾ÍÓÐÌṩµÄ¡¸時Ðò¡¹機ÖÆ來×ö處Àí£¬ì¶ÊÇÎÒ漸漸學會ÁËÈçºÎʹÓÃTimer¡¢TaskletºÍWorkqueueµÄÓ÷¨£¬ÔÚO'ReillyµÄLinux Device DriversµÚÆßÕÂÓÐ詳細µÄ講½â£¬ÎÒ將書Éϵľ«華茲簡單ÕûÀíÈçÏ£º
##CONTINUE##
Ò»¡¢Timer
#include <linux/timer.h>
struct timer_list
{
/* ... */
unsigned long expires;//ÆÚÍû運ÐÐµÄ jiffies Öµ
void (*function)(unsigned long);
unsigned long data;//傳給functionµÄ參數
};//ʹÓÃǰ±Ø須³õʼ»¯
void init_timer(struct timer_list *timer);
//³õʼ»¯Ò»個timer_list
struct timer_list TIMER_INITIALIZER(_function, _expires, _data);
//³õʼ»¯Ò»個靜態µÄtimer_list
void add_timer(struct timer_list * timer);
int mod_timer(struct timer_list *timer, unsigned long expires);
int del_timer(struct timer_list * timer);
int del_timer_sync(struct timer_list *timer);
//ͬ del_timer Ò»樣,µ«±£證º¯數return時£¬¶¨時Æ÷º¯數²»ÔÚÈκΠCPU ÉÏ運ÐÐ
//±ÜÃâÔÚSMP ϵ統ÉÏ競爭
int timer_pending(const struct timer_list * timer);
//·µ»ØÕæ»ò¼Ù來ָʾÊÇ·ñ¶¨時Æ÷Òѱ»運ÐÐ
¶þ¡¢Tasklet
#include <linux/interrupt.h>
struct tasklet_struct {
/* ... */
void (*func)(unsigned long);
unsigned long data;
};
void tasklet_init(struct tasklet_struct *t,
void (*func)(unsigned long), unsigned long data);
//將¶¨義ºÃµÄ結構體³õʼ»¯£¬²Å¿ÉÓÃ
DECLARE_TASKLET(name, func, data);
//Ö±½ÓÉêÃ÷¾Í¿ÉÓÃÁË
DECLARE_TASKLET_DISABLED(name, func, data);
void tasklet_disable(struct
Ïà¹ØÎĵµ£º
£¨L2CAPÐÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPÐÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼Á¬½Ó¿ØÖƺÍÊÊÅäÐÒé (L2CAP) ΪÉϲãÐÒéÌá¹©ÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àÐÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãÐÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......
MEMCACHED°²×°
Ò»¡¢·þÎñ¶Ë¡£ÏȰ²×°libevent£¬ÔÙ°²×°memcached¡££¨×¢£ºlibeventÊÇÒ»Ì×¿çÆ½Ì¨µÄʼþ´¦Àí½Ó¿ÚµÄ·â×°£¬Äܹ»¼æÈݰüÀ¨£ºWindows/Linux/BSD/SolarisµÈ²Ù×÷ϵͳµÄʼþ´¦Àí£©
1¡¢ÏÂÔØ×îа汾µÄlibeventºÍmemcached£¬±ÊÕߵݲװĿ¼Ϊ/soft
>cd /soft
>wget http://www.dange.com/memcached/dist/memcach ......
linuxϵͳrootÓû§¿ÉÇ¿ÖÆÌßÖÆÆäËüµÇ¼Óû§£¬
Ê×ÏÈÒÔrootµÇ¼ÒÔ±ã²é¿´È«²¿µÄÔÚÏßÓû§ÐÅÏ¢£¬¿ÉÓÃwÃüÁî²é¿´µÇ¼Óû§ÐÅÏ¢
Ç¿ÖÆÌßÈËÃüÁî¸ñʽ£ºpkill -kill -t tty
½âÊÍ£º
pkill -kill -t ¡¡ÌßÈËÃüÁî
tty¡¡ËùÌßÓû§µÄTTY
ÈçÉÏÌß³öliuÓû§µÄÃüÁîΪ£º pkill -kill -t pts/1
......
ÔÎĵØÖ·£ºhttp://www.wangzhongyuan.com/archives/487.html
ÒÔÏÂÊÇÒ»¸öLinux/UnixÏÂÏÔʾijһĿ¼ÏÂÎļþÁбíµÄC³ÌÐò£¬Ï൱ÓÚ×î»ù±¾µÄlsÃüÁîµÄ¹¦ÄÜ£¬ÏÔʾµÄÄÚÈݱ¨¸æ¸ÃĿ¼ÏµÄ×ÓĿ¼ÒÔ¼°ÎļþÃû:
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
int m ......
º¯ÊýÔÐÍ£º
#include <pthread.h>
int pthread_create(pthread_t *restrict tidp,const pthread_attr_t *restrict attr, void *(*start_rtn)( ......