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

LinuxÏÂÏ̵߳Ĵ´½¨

×÷Õß:Hoyt Email:hoytluo@21cn.comÔ­ÎĵØÖ· http://wiki.chinaunix.net/index.php/Zhuan_c7
Ç°ÑÔ: LinuxÏÂÏ̵߳Ĵ´½¨ºÍ»ù±¾µÄʹÓÃ
Ï̵߳Äͬ²½ºÍ»¥³â
Ï̵߳ÄÌõ¼þ±äÁ¿
ÏȽéÉÜʲôÊÇÏß³Ì.ÎÒÃDZàдµÄ³ÌÐò´ó¶àÊý¿ÉÒÔ¿´³ÉÊǵ¥Ï̵߳Ä.¾ÍÊdzÌÐòÊÇ°´ÕÕÒ»¶¨µÄ ˳ÐòÀ´Ö´ÐÐ.Èç¹ûÎÒÃÇʹÓÃÏ̵߳Ļ°,³ÌÐò¾Í»áÔÚÎÒÃÇ´´½¨Ï߳ɵĵط½·Ö²æ,±ä³ÉÁ½¸ö"³Ì Ðò"ÔÚÖ´ÐÐ.´ÖÂԵĿ´À´ºÃÏóºÍ×Ó½ø³Ì²î²»¶àµÄ,Æäʵ²»È».×Ó½ø³ÌÊÇͨ¹ý¿½±´¸¸½ø³ÌµÄµØ Ö·¿Õ¼äÀ´Ö´ÐеÄ.¶øÏß³ÌÊÇͨ¹ý¹²Ïí³ÌÐò´úÂëÀ´Ö´ÐеÄ,½²µÄͨË×Ò»µã¾ÍÊÇÏ̵߳ÄÏàͬµÄ ´úÂë»á±»Ö´Ðм¸´Î.ʹÓÃÏ̵߳ĺô¦ÊÇ¿ÉÒÔ½ÚÊ¡×ÊÔ´,ÓÉÓÚÏß³ÌÊÇͨ¹ý¹²Ïí´úÂëµÄ,ËùÒÔû Óнø³Ìµ÷¶ÈÄÇô¸´ÔÓ.
1.Ï̵߳Ĵ´½¨ºÍʹÓÃ
Ï̵߳Ĵ´½¨ÊÇÓÃÏÂÃæµÄ¼¸¸öº¯ÊýÀ´ÊµÏÖµÄ.
#include <pthread.h>

int pthread_create(pthread_t *thread,pthread_attr_t *attr,
void *(*start_routine)(void *),void *arg);
void pthread_exit(void *retval);
int pthread_join(pthread *thread,void **thread_return);

pthread_create´´½¨Ò»¸öÏß³Ì,threadÊÇÓÃÀ´±íÃ÷´´½¨Ï̵߳ÄID,attrÖ¸³öÏ̴߳´½¨Ê±ºò µÄÊôÐÔ,ÎÒÃÇÓÃNULLÀ´±íÃ÷ʹÓÃȱʡÊôÐÔ.start_routineº¯ÊýÖ¸ÕëÊÇÏ̴߳´½¨³É¹¦ºó¿ªÊ¼ Ö´Ðеĺ¯Êý,argÊÇÕâ¸öº¯ÊýµÄΨһһ¸ö²ÎÊý.±íÃ÷´«µÝ¸østart_routineµÄ²ÎÊý. pthrea d_exitº¯ÊýºÍexitº¯ÊýÀàËÆÓÃÀ´Í˳öÏß³Ì.Õâ¸öº¯Êý½áÊøÏß³Ì,Êͷź¯ÊýµÄ×ÊÔ´,²¢ÔÚ×îºó ×èÈû,Ö±µ½ÆäËûÏß³ÌʹÓÃpthread_joinº¯ÊýµÈ´ýËü.È»ºó½«*retvalµÄÖµ´«µÝ¸ø**thread_ return.ÓÉÓÚÕâ¸öº¯ÊýÊÍ·ÅËùÒԵĺ¯Êý×ÊÔ´,ËùÒÔretval²»Äܹ»Ö¸Ïòº¯ÊýµÄ¾Ö²¿±äÁ¿. pt hread_joinºÍwaitµ÷ÓÃÒ»ÑùÓÃÀ´µÈ´ýÖ¸¶¨µÄÏß³Ì.×¢ÒâÓÉÓÚÏ̲߳»Í¬ÓÚ½ø³Ì.ËùÒÔÏß³ÌµÄ Í˳öÒ»¶¨ÒªÓÃpthread_exit¶ø²»ÊÇʹÓÃexit.·ñÔòÕû¸ö³ÌÐò»áÍ˳öµÄ. ÏÂÃæÎÒÃÇʹÓÃÒ»¸ö ʵÀýÀ´½âÊÍÒ»ÏÂʹÓ÷½·¨.ÔÚʵ¼ùÖÐ,ÎÒÃǾ­³£Òª±¸·ÝһЩÎļþ.ÏÂÃæÕâ¸ö³ÌÐò¿ÉÒÔʵÏÖµ± ǰĿ¼ÏµÄËùÓÐÎļþ±¸·Ý.±¸·ÝºóµÄºó׺ÃûΪbak
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h&


Ïà¹ØÎĵµ£º

Èý¿î Linux ϵÄÃâ·Ñ×ÀÃ漶ɱ¶¾Èí¼þ(ͼ)


ÓÉÓÚ Linux Á¼ºÃµÄÓû§È¨ÏÞ¹ÜÀíÌåϵ£¬²¡¶¾ÍùÍùÊÇ Linux ϵͳ¹ÜÀíÔ±×îºó²ÅÐèÒª¿¼ÂǵÄÎÊÌâ¡£ÒÔÍù£¬Linux ÉϵÄɱ¶¾Èí¼þÖ÷ÒªÊÇΪÆóÒµµÄÓʼþºÍÎļþ·þÎñÆ÷ËùÉè¼ÆµÄ¡£Èç½ñ£¬Ëæ×Å Linux ×ÀÃæÓû§ÊýÁ¿µÄÔö³¤£¬×ÀÃæÓû§ÔÚÊÜÒæÓÚ Linux ϵͳ¶Ô²¡¶¾½ÏÇ¿µÄÌìÈ»ÃâÒßÁ¦µÄͬʱ£¬Ò²ÐèҪɱ¶¾Èí¼þÇåÀí´ÓÍøÂç»òUÅÌ´øÀ´µÄWIndows²¡¶¾¡£¾¡¹ÜÄÇЩ ......

¹ØÓÚLinuxµÄÊé¼®

Linux²¢²»ÊÇÒ»¸ö±Èwindows¸üÉñÃصÄϵͳ.
ÊǵÄLinuxûÓÐMSDN,µ«LinuxºÍÏà¹ØÈí¼þµÄÎĵµ¾ø¶Ô²»±ÈMSDNÒªÉÙ
¼ÇµÃ,Ò»¸ö¿´¹Ù·½ÍøÕ¾µÄÎĵµ,Ò»¸ögoogle.ÎÒÏë,´ó¶àÎÊÌⶼ»á½â¾öµÄ.ʣϵľͿ¿
Ä㶯ÊÖ½â¾öÁË.
linuxÈëÃÅ:
ûÓз¢ÏÖʲô±È½ÏºÃµÄÈëÃÅÊé,Ҫô̫¹ÅÀÏ,ҪôÕÕ¹ËÌ«¶àµÄ·ÅÐа汾,µ¼ÖÂûÓÐʲô
ʵ¼ÊÓô¦.ʵ¼ÊÉÏ,²Î¿¼·¢ÐÐ°æµ ......

Linux ÄÚºËÖÐµÄ GCC ÌØÐÔ(ת)

M. Tim Jones, ¹ËÎʹ¤³Ìʦ, Emulex Corp.
2009 Äê 4 ÔÂ 07 ÈÕ
Linux® ÄÚºËʹÓà GNU Compiler Collection (GCC) Ì×¼þµÄ¼¸¸öÌØÊ⹦ÄÜ¡£ÕâЩ¹¦ÄÜ°üÀ¨Ìṩ¿ì½Ý·½Ê½ºÍ¼ò»¯ÒÔ¼°Ïò±àÒëÆ÷ÌṩÓÅ»¯ÌáʾµÈµÈ¡£Á˽âÕâЩÌØÊâµÄ GCC ÌØÐÔ£¬Ñ§Ï°ÈçºÎÔÚ Linux ÄÚºËÖÐʹÓÃËüÃÇ¡£
GCC ºÍ Linux ÊdzöÉ«µÄ×éºÏ¡£¾¡¹ÜËüÃÇÊǶÀÁ¢µÄÈí¼þ ......

LINUX C++ REGEXP ÕýÔò±í´ïʽ

ÔÚPOSIXÖУ¬±ãÓÐ×ÅÖ§³ÖÕýÔò±í´ïʽµÄϵͳº¯Êý¡£GNU/LinuxÓÐÁ½Ì׿â¿ÉÓÃÓÚÕýÔò±í´ïʽ±à³Ì£ºPOSIX¿âºÍPCRE¿â¡£Ç°Õß²»ÐèÒªµ¥¶À°²×°£¬Ò»°ãÐèÇó»¹ÊÇÄÜÂú×ãµÄ£¬ËÙ¶ÈÉÔÂýЩ¡£ºóÕßÊǾøºÊ¢ÃûµÄPerlÕýÔò±í´ïʽ¿â£¬¹¦ÄÜÇ¿´ó£¬Æ¥ÅäËٶȿ죬²»¹ý¿ÉÄÜÐèÒªµ¥¶À°²×°¡£
int regcomp (regex_t *compiled, const char *pattern, int cflags)
& ......

linux ulimit ½²½â

1,˵Ã÷:
ulimitÓÃÓÚshellÆô¶¯½ø³ÌËùÕ¼ÓõÄ×ÊÔ´.
2,Àà±ð:
shellÄÚ½¨ÃüÁî
3,Óï·¨¸ñʽ:
ulimit [-acdfHlmnpsStvw] [size]
4,²ÎÊý½éÉÜ:
-H ÉèÖÃÓ²¼þ×ÊÔ´ÏÞÖÆ.
-S ÉèÖÃÈí¼þ×ÊÔ´ÏÞÖÆ.
-a ÏÔʾµ±Ç°ËùÓеÄ×ÊÔ´ÏÞÖÆ.
-c size:ÉèÖÃcoreÎļþµÄ×î´óÖµ.µ¥Î»:blocks
-d size:ÉèÖÃÊý¾Ý¶ÎµÄ×î´óÖµ.µ¥Î»:kbytes
-f size:ÉèÖô´½¨ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ