Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LinuxÏÂthread±à³Ì£¨Èý£©

×÷ÕߣºSam£¨Õç·å£© sam_cdoe@hotmail.com
1.´´½¨thread.
int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr,
              void *(*start_routine)(void*), void *restrict arg);
²ÎÊý1£ºpthread_t *restrict thread£º´´½¨threadµÄthread ID.
²ÎÊý2£ºconst pthread_attr_t *restrict attr£º´´½¨Ï̵߳ÄÊôÐÔ¡£
²ÎÊý3£ºvoid *(*start_routine)(void*)£ºthread·þÎñ³ÌÐò¡£
²ÎÊý4£ºvoid *restrict arg£ºthread·þÎñ³ÌÐò²ÎÊý¡£
2. µÈ´ýÄ¿±êÏß³ÌÖÕÖ¹£º
pthread_join() º¯Êý»áÒ»Ö±×èÈûµ÷ÓÃỊ̈߳¬Ö±µ½Ö¸¶¨µÄÏß³ÌÖÕÖ¹¡£
Ö¸¶¨µÄÏ̱߳ØÐëλÓÚµ±Ç°µÄ½ø³ÌÖУ¬¶øÇÒ²»µÃÊÇ·ÖÀëÏ̡߳£ËùÓд´½¨Ê±ÊôÐÔΪPTHREAD_CREATE_JOINABLEµÄ·Ç·ÖÀëthread. ×îÖÕ¶¼ÐèÒªµ÷ÓÃpthread_join() or pthread_detach() ¡£ÕâÑùthreadËùÕ¼×ÊÔ´ºÍ Thread ID ²Å±»ÊÍ·Å¡£
3. ·ÖÀëthread:
int pthread_detach(pthread_t thread);
pthread_detach()Ö¸³öµ±thread ½áÊøʱ£¬threadËùÕ¼×ÊÔ´ºÍThread ID»á±»ÊͷźÍÔÙÀûÓá£Èç¹ûµ÷ÓÃpthread_detach()ʱ£¬threadûÓнáÊø£¬Ëü²¢²»»áµ¼ÖÂthreadÍ˳ö¡£ËüÖ»¶ÔPTHREAD_CREATE_JOINABLE ·Ç·ÖÀëthreadÓÐЧ¡£
4. »ñÈ¡thread ID:
pthread_t pthread_self(void)£»
·µ»Øµ÷ÓÃthreadµÄthread ID.
5. ±È½Ïthread ID:
int pthread_equal(pthread_t t1, pthread_t t2);Èç¹û tid1 ºÍ tid2 ÏàµÈ£¬pthread_equal() ½«·µ»Ø·ÇÁãÖµ£¬·ñÔò½«·µ»ØÁã¡£
6. Ïòthread·¢Ðźţº
int pthread_kill(pthread_t thread, int sig);
tid ËùÖ¸¶¨µÄÏ̱߳ØÐëÓëµ÷ÓÃÏß³ÌÔÚͬһ¸ö½ø³ÌÖС£sig ²ÎÊý±ØÐëÀ´×Ô signal(5) ÌṩµÄÁÐ±í¡£
7. Í˳öỊ̈߳º
void pthread_exit(void *value_ptr);
pthread_exit()ÓÃÀ´ÖÕÖ¹µ÷ÓÃthread²¢ÖÃλvalue_ptr.Õâ¸öÖµ»á½»¸øpthread_join¡£
ThreadµÄÈ¡Ïû£º
ͬһ½ø³ÌÄÚ£¬Ä³¸öThread¿ÉÒÔÏòÆäËüthread·¢ËÍÈ¡ÏûÒªÇó£¬ÒªÇóÄ¿±êthreadÍ˳öÔËÐС£
È¡ÏûÇëÇóµÄ´¦Àí·½Ê½È¡¾öÓÚÄ¿±êÏ̵߳Ä״̬¡£×´Ì¬ÓÉÒÔÏÂÁ½¸öº¯ÊýÈ·¶¨£ºpthread_setcancelstate() ºÍ pthread_setcanceltype()¡£
 pthread_setcancelstate() ÆôÓûò½ûÓÃÏß³ÌÈ¡Ïû¹¦ÄÜ¡£´´½¨Ïß³Ìʱ£¬È±Ê¡Çé¿öÏÂÏß³ÌÈ¡Ïû¹¦ÄÜ´¦ÓÚÆôÓÃ״̬¡£
pthread_setcanceltype() ¿ÉÒÔ½«È¡ÏûÀàÐÍÉèÖÃΪÑÓ³Ù»òÒ첽ģʽ¡£´´½¨Ïß³Ìʱ£¬È±Ê¡Çé¿öÏ»ὫȡÏûÀàÐÍÉèÖÃΪÑÓ³Ùģʽ¡£ÔÚÑÓ³ÙģʽÏ£¬Ö»ÄÜÔÚÈ¡ÏûµãÈ¡ÏûÏ̡߳£ÔÚÒì


Ïà¹ØÎĵµ£º

ʹÓÃyumÉý¼¶ºÍyumʹÓüò½é(LInux, RedHat, Fedora)

ʲôÊÇ yum£¿
yum ÊÇ yellowdog updater modified µÄËõд¡£yellowdog ÊÇÒ»¸ö Linux µÄ distribution£¬RH ½«ÕâÖÖÉý¼¶¼¼ÊõÀûÓõ½×Ô¼ºµÄ distribution ÐγÉÁËÏÖÔÚµÄ yum£¬¸Ð¾õÉÏ yum ºÍ apt µÄÔ­ÀíÀàËÆ£¬µ«ÊÇ apt ÊDZàÒë´úÂ룬ִÐÐЧÂÊÔ¶¸ßÓÚʹÓà python д³ÉµÄ yum¡£ÕâÊÇ yum µÄÖ÷Ò³¡£
yum µÄÀíÄîÊÇʹÓÃÒ»¸öÖÐÐÄ²Ö ......

LinuxÍü¼ÇÁËrootµÄÃÜÂëµÄ½â¾ö°ì·¨

1. ϵͳÆô¶¯ºó,ÔÚ³öÏÖgrub»­Ãæʱ£¬ÓÃÉÏϼüÑ¡ÖÐÄãƽʱÆô¶¯linuxµÄÄÇÒ»ÏȻºó°´e¼ü
2. ÔÙ´ÎÓÃÉÏϼüÑ¡ÖÐÄãƽʱÆô¶¯linuxµÄÄÇÒ»Ïî(ÀàËÆÓÚkernel/boot mlinuz-2.4.18-14 ro root=LABEL=/)£¬È»ºó°´e¼ü
3. ÐÞ¸ÄÄãÏÖÔÚ¼ûµ½µÄÃüÁîÐУ¬¼ÓÈësingle£¬½á¹ûÈçÏ£º
    kernel /boot mlinuz-2.4.18-14 single ro ......

Linuxϲ鿴Îļþ±àÂë,Îļþ»òÎļþÃû±àÂë¸ñʽת»»


Èç¹ûÄãÐèÒªÔÚLinuxÖвÙ×÷windowsϵÄÎļþ£¬ÄÇôÄã¿ÉÄܻᾭ³£Óöµ½Îļþ±àÂëת»»µÄÎÊÌâ¡£WindowsÖÐĬÈϵÄÎļþ¸ñʽÊÇGBK(gb2312)£¬¶øLinuxÒ»°ã¶¼ÊÇUTF-8¡£ÏÂÃæ½éÉÜһϣ¬ÔÚLinuxÖÐÈçºÎ²é¿´ÎļþµÄ±àÂë¼°ÈçºÎ½øÐжÔÎļþ½øÐбàÂëת»»¡£
Ò»£¬²é¿´Îļþ±àÂ룺
ÔÚLinuxÖв鿴Îļþ±àÂë¿ÉÒÔͨ¹ýÒÔϼ¸ÖÖ·½Ê½£º
1.ÔÚVimÖпÉÒÔÖ±½Ó²é¿ ......

ÐÞ¸´Linuxϵͳ

ÐÞ¸´Linuxϵͳ
1£®Ê¹Óü±¾ÈÅÌ×é½øÐÐά»¤
¼±¾ÈÅÌ×飨Ҳ³ÆΪboot/rootÅÌ×飩£¬ÊÇϵͳ¹ÜÀíÔ±±Ø²»¿ÉÉٵŤ¾ß¡£ÓÃËü¿ÉÒÔ¶ÀÁ¢µØÆô¶¯ºÍÔËÐÐÒ»¸öÍêÕûµÄLinuxϵͳ¡£Êµ¼Ê ÉÏ£¬¼±¾ÈÅÌ×éÖеĵÚ2ÕÅÅÌÉϾÍÓÐÒ»¸öÍêÕûµÄLinuxϵͳ£¬°üÀ¨rootÎļþϵͳ£»¶øµÚ1ÕÅÅÌÔò´æ·ÅÁË¿ÉÆô¶¯µÄÄںˡ£
ʹÓü±¾ÈÅÌ×éά»¤ÏµÍ³ºÜ¼òµ¥¡£Ö»ÐèÓÃÕâÁ½ÕÅÅÌÆô¶ ......

ÅäÖÃlinuxÄÚºËdzÎö

Ëæ×Å Linux ²Ù×÷ϵͳµÄ¹ã·ºÓ¦Óã¬ÌرðÊÇ Linux ÔÚǶÈëʽÁìÓòµÄ·¢Õ¹£¬Ô½À´Ô½¶àµÄÈË¿ªÊ¼Í¶Éíµ½ Linux Äں˼¶µÄ¿ª·¢ÖС£Ãæ¶ÔÈÕÒæÅÓ´óµÄ Linux ÄÚºËÔ´´úÂ룬¿ª·¢ÕßÔÚÍê³É×Ô¼ºµÄÄں˴úÂëºó£¬¶¼½«ÃæÁÙ×ÅͬÑùµÄÎÊÌ⣬¼´ÈçºÎ½«Ô´´úÂëÈÚÈëµ½ Linux ÄÚºËÖУ¬Ôö¼ÓÏàÓ¦µÄ Linux ÅäÖÃÑ¡Ï²¢×îÖÕ±»±àÒë½ø Linux Äںˡ£Õâ¾ÍÐèÒªÁ˽â Linu ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ