Linux Ï߳̽ӿÚ˵Ã÷
×î½ü¶ÔLinuxµÄÏ߳̽ӿڽøÐÐÁËЩ×ܽᣬҲ²Î¿¼ÁËÍøÂçÉÏÐÖµÜÃǵÄһЩ×ÊÁÏ£¬×Ô¼ºÍ¬Ê±Ò²Ð´ÁËЩ³ÌÐò½øÐвâÊÔ£¬ÏȰѲο¼µÄ
×ÊÁÏÁгöÀ´°É
http://blog.mcuol.com/User/liuzhilii521/Article/12738_1.htm
ÏÂÃæÊÇÎÒµÄһЩÀí½â£º
pthread_key_create(pthread_key_t *key,void (*destructor)(void*))
destructorÕâ¸ö»Øµ÷º¯ÊýÔÚÏß³ÌÍ˳öµÄʱºò»á±»µ÷Ó㬲ÎÊýÊÇpthread_setspecial(pthread_key_t *key,const void *value)
ÖеIJÎÊývalue
void *pthread_getspecial(pthread_key_t key)
»ñÈ¡µÄÊǵ÷Óõĺ¯ÊýËùÔÚÏ̵߳ľßÌåÊý¾Ý
pthread_setspecial(pthread_key_t *key,const void *value)
±ØÐëÔÚ¾ßÌåµÄÏß³ÌÖе÷Óã¬ÒÔ´ïµ½¸úµ±Ç°Ḭ̈߳󶨵ÄЧ¹û
Ïß³ÌÍ˳öµÄÎÊÌ⣺
¶ÔÓÚǶÈëʽ³ÌÐòÀ´Ëµ£¬Ö±µ½¶ÏµçÇ°ºÜ¶àÏß³ÌÊÇÒ»Ö±ÔÚÔËÐеģ¬²¢²»´æÔÚÏß³ÌÍ˳öµÄÎÊÌ⣬µ«ÊÇÓÐÒ»²¿·ÖỊ̈߳¬ÌرðÊÇÄ£¿é
»¯Á˵ijÌÐò£¬µ«Ä£¿éµÄ¹¦ÄÜÍ˳öÁË£¬ÄÇôËùÓеÄ×ÊÔ´¶¼ÐèÒªÊÍ·Å£¬²»¹ÜÊÇÄڴ棬»¹ÊÇỊ̈߳¬»òÕßÓ²¼þ×ÊÔ´¡£
LinuxÌṩÁ˼¸ÖÖÍ˳ö»úÖÆ£º
1. pthread_exit
Õâ¸ö½Ó¿ÚÊÇ˵÷ÓÃËÍ˳ö£¬Ò»°ãÊÇÏß³Ì×Ô¼ºÍ˳ö
2. pthread_kill
Õâ¸ö½Ó¿ÚÊÇÏòijһ¸öÏ̷߳¢³öÒ»¸ösignal£¬µ±È»½Ó¿ÚµÄÏß³ÌÐèÒªÏȵǼǴ¦ÀíÕâ¸ösignalµÄ·½·¨£¬¿ÉÒÔÊÇÍ˳ö³ÌÐò£¬Ò²¿ÉÒÔ
ÊÇstop³ÌÐò¡£¿ÉÒÔÊDZ¾Ï̷߳¢³ö£¬Ò²¿ÉÒÔÊÇÆäËûÏ̷߳¢³öµÄ
3. pthread_concel
Õâ¸ö½Ó¿ÚÊÇÇ¿ÖÆÊÍ·Åijһ¸öỊ̈߳¬ÄÇôÊͷŸÃÏ̵߳Ä×ÊÔ´ÈçºÎ´¦ÀíÄØ£¿ Æäʵ¿ÉÒÔÔÚ¸ÃÏß³ÌÆô¶¯µÄʱºòÉèÖÃÏß³ÌÍ˳öµÄ
ÊÍ·Å×ÊÔ´µÄ»Øµ÷º¯Êý£¬pthread_cleanup_push(void (*routine)(void*),void *arg)¾ÍÊÇÉèÖÃÍ˳öµÄÊÍ·Å×ÊÔ´µÄ»Øµ÷º¯Êý
Ìõ¼þ±äÁ¿ÎÊÌ⣺
ËùνµÄÌõ¼þ±äÁ¿ÆäʵÕæµÄÃ÷·ûÆäʵ£¬¾ÍÊǰѱäÁ¿µ±³ÉÒ»ÖÖÌõ¼þ£¬Ò²¾ÍÊÇ˵ͨ¹ýÅжÏÒ»¸ö±äÁ¿£¬ÈóÌÐòÊÇ·ñ¹ÒÆ𣬻òÕß´¦Àí
Êý¾ÝµÄÒ»ÖÖÐÐΪ¡£
Ò»°ãµ÷ÓýӿÚÊÇpthread_cond_create, pthread_cond_wait, pthread_cond_timedwait, pthread_cond_signal
¹Ø¼üµÄÊÇÒª°Ñ±äÁ¿ºÍwaitµÄ½Ó¿Ú¶¼ÓÃmutex±£»¤ÆðÀ´£¬¶øÇÒwait²ÎÊý¶¼ÒªÊäÈëmutex½øÐб£»¤
ÆäʵÈç¹ûÎÒÃÇÓÃsemÒ²ÊÇ¿ÉÒÔʵÏÖÕâÖÖ¹¦Äܵġ£
Ïà¹ØÎĵµ£º
modinfo(module infomation)
¹¦ÄÜ˵Ã÷£ºÏÔʾkernelÄ£¿éµÄÐÅÏ¢¡£
Óï¡¡¡¡·¨£ºmodinfo [-adhpV][Ä£¿éÎļþ]
²¹³ä˵Ã÷£ºmodinfo»áÏÔʾkernelÄ£¿éµÄ¶ÔÏóÎļþ£¬ÒÔÏÔʾ¸ÃÄ£¿éµÄÏà¹ØÐÅÏ¢¡£
²Î¡¡¡¡Êý£º
-a»ò--author ¡¡ÏÔʾģ¿é¿ª·¢ÈËÔ±¡£
-d»ò--description ¡¡ÏÔʾģ¿éµÄ˵Ã÷¡£& ......
ÔÚLINUXµÄʱÖÓÖжÏÖÐÉæ¼°ÖÁ¶þ¸öÈ«¾Ö±äÁ¿Ò»¸öÊÇxtime,ËüÊÇtimevalÊý¾Ý½á¹¹±äÁ¿£¬ÁíÒ»¸öÔòÊÇjiffies£¬Ê×ÏÈ¿´timeval½á¹¹
struct timeval
{
time_t tv_sec; /***second***/
susecond_t tv_usec;/***microsecond***/
}
µ½µ×microsecondÊǺÁÃ뻹ÊÇ΢Ã룿£¿
1Ã룽1000ºÁÃ루3¸öÁ㣩£¬1Ã룽1000 000΢Ã루6¸öÁ㣩£¬1Ã룽1 ......
linuxÖУ¬ÔÚÖ§³Ö¶àÏ̵߳Ļ·¾³ÖУ¬Í¨³£Ã¿¸öÏ̶߳¼ÓÐÊôÓÚ×Ô¼ºµÄerrno±äÁ¿£¬ÊÇÓÃÀ´±íʾÌض¨´íÎóµÄ³£Á¿¡£
ÒÔÏÂÊÇ<errno.h>Öж¨ÒåµÄËùÓгö´íerrno³£Á¿
#define EPERM 1 /* Operation not permitted */
#define ENOEN ......
caddr_t //ºËÐĵØÖ·
clock_t //ʱÖӵδð¼ÆÊýÆ÷
compt_t //ѹËõµÄʱÖӵδð
dev_t //É豸ºÅ£¨Ö÷ºÍ´Î£©
fd_set //ÎļþÃèÊö·û¼¯
fpos_t //ÎļþλÖÃ
gid_t //ÊýÖµ×éID
ino_t //i½Úµã±àºÅ
mode_t //ÎļþÀ ......
°´ÒÔϲ½ÖèÀ´,ÏÈдÕâô¶àÀ´ÌáÐÑÏÂ×Ô¼º:
1.ÊìϤlinuxµÄ»ù±¾»·¾³,ÊìϤlinuxµÄ»ù±¾ÃüÁî.
2.ÊìϤlinuxµÄ½»²æ±àÒë»·¾³µÄµÄÅäÖÃ.
3.¸´Ï°»ù±¾µÄCÓïÑÔ֪ʶ.
&nbs ......