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

Ö÷Ì⣺һ¸ö¼òµ¥µÄlinuxÏ̳߳Ø

Ï̳߳Ø
£º¼òµ¥µØ˵£¬Ï̳߳Ø
¾ÍÊÇÔ¤ÏÈ´´½¨ºÃÒ»ÅúỊ̈߳¬·½±ã¡¢¿ìËٵش¦ÀíÊÕµ½µÄÒµÎñ¡£±ÈÆð´«Í³µÄµ½À´Ò»¸öÈÎÎñ£¬¼´Ê±´´½¨Ò»¸öÏß³ÌÀ´´¦Àí£¬½ÚÊ¡ÁËÏ̵߳Ĵ´½¨ºÍ»ØÊյĿªÏú£¬ÏìÓ¦¸ü¿ì£¬Ð§ÂÊ
¸ü¸ß¡£
ÔÚlinuxÖУ¬Ê¹ÓõÄÊÇposixÏ߳̿⣬Ê×ÏȽéÉܼ¸¸ö³£Óõĺ¯Êý£º
1 Ï̵߳Ĵ´½¨ºÍÈ¡Ïûº¯Êý
pthread_create
´´½¨
pthread_join
ºÏ²¢Ïß³Ì
pthread_cancel
È¡ÏûÏß³Ì
2 Ïß³Ìͬ²½º¯Êý
pthread_mutex_lock
pthread_mutex_unlock
pthread_cond_signal
pthread_cond_wait
¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬²Î¿¼manÊÖ²á
Ï̳߳صÄʵÏÖ£º
Ï̳߳صÄʵÏÖÖ÷Òª·ÖΪÈý²¿·Ö£¬Ï̵߳Ĵ´½¨¡¢Ìí¼ÓÈÎÎñµ½Ï̳߳ØÖС¢¹¤×÷Ï̴߳ÓÈÎÎñ¶ÓÁÐÖÐÈ¡³öÈÎÎñ½øÐд¦Àí¡£
Ö÷ÒªÓÐÁ½¸öÀàÀ´ÊµÏÖ£¬CTask,CThreadPool
/**
Ö´ÐÐÈÎÎñµÄÀ࣬ÉèÖÃÈÎÎñÊý¾Ý²¢Ö´ÐÐ
**/
class CTask
{
protected:
string m_strTaskName; //ÈÎÎñµÄÃû³Æ
void* m_ptrData; //ÒªÖ´ÐеÄÈÎÎñµÄ¾ßÌåÊý¾Ý
public:
CTask(){}
CTask(string taskName)
{
this->m_strTaskName = taskName;
m_ptrData = NULL;
}
virtual int Run()= 0;
void SetData(void* data); //ÉèÖÃÈÎÎñÊý¾Ý
};
ÈÎÎñÀàÊǸöÐéÀ࣬ËùÓеÄÈÎÎñÒª´ÓCTaskÀàÖм̳Ð
£¬ÊµÏÖrun½Ó¿Ú£¬run½Ó¿ÚÖÐÐèҪʵÏֵľÍÊǾßÌå½âÎöÈÎÎñµÄÂß¼­¡£m_ptrDataÊÇÖ¸ÏòÈÎÎñÊý¾ÝµÄÖ¸Õ룬¿ÉÒÔÊǼòµ¥Êý¾ÝÀàÐÍ£¬Ò²¿ÉÒÔÊÇ×Ô¶¨ÒåµÄ¸´ÔÓ
Êý¾ÝÀàÐÍ¡£
Ï̳߳ØÀà
/**
Ï̳߳Ø
**/
class CThreadPool
{
private:
vector<CTask*> m_vecTaskList; //ÈÎÎñÁбí
int m_iThreadNum; //Ï̳߳ØÖÐÆô¶¯µÄÏß³ÌÊý
static vector<pthread_t> m_vecIdleThread; //µ±Ç°¿ÕÏеÄÏ̼߳¯ºÏ
static vector<pthread_t> m_vecBusyThread; //µ±Ç°ÕýÔÚÖ´ÐеÄÏ̼߳¯ºÏ
static pthread_mutex_t m_pthreadMutex; //Ïß³Ìͬ²½Ëø
static pthread_cond_t m_pthreadCond; //Ïß³Ìͬ²½µÄÌõ¼þ±äÁ¿
protected:
static void* ThreadFunc(void * threadData); //ÐÂÏ̵߳ÄÏ̺߳¯Êý
static int MoveToIdle(pthread_t tid); //Ïß³ÌÖ´ÐнáÊøºó£¬°Ñ×Ô¼º·ÅÈëµ½¿ÕÏÐÏß³ÌÖÐ
static int MoveToBusy(pthread_t tid); //ÒÆÈ뵽æµÏß³ÌÖÐÈ¥
int Create(); //´´½¨ËùÓеÄÏß³Ì
public:
CThreadPool(int threadNum);
int AddTask(CTask *task); //°ÑÈÎÎñÌí¼Óµ½Ï̳߳ØÖÐ
int StopAll(


Ïà¹ØÎĵµ£º

LinuxÉ豸Çý¶¯Ö®——¹¹½¨ÄÚºËÊ÷

ѧLinuxÒ»Äê¶àÁË£¬¶ÔÇý¶¯µÄ֪ʶһµã¶¼Á˽⣬ÉÏÖÜÂòÁ˱¾¡¶LinuxÉ豸Çý¶¯¡·£¬O'REILLY³ö°æ£¬´òËãѧϰѧϰ¡£Ñ§Ï°¹ýµÄ´óÏÀ£¬Ï£Íû¿ÉÒÔÖ¸µ¼Ö¸µ¼¡£
Ê×ÏÈÏÂÔØLinuxÄںˣ¬°´×÷ÕßµÄ˵·¨£¬Ö»ÒªÊÇlinux-2.6.xxxµÄÄں˶¼¿ÉÒÔ£¬ÎÒµÄÊÇlinux-2.6.33.2¡£ÓÐλÍøÓÑ˵ÏÂÔغó×îºÃ½âѹµ½/usr/src/Ŀ¼Ï£¬½âѹ
ÔÚ¹¹½¨ÄÚºËÊ÷ÊDzο¼ÁËÔ­ÊéµÚËÄÕÂ& ......

´ÓUÅÌ°²×°Linux Fedoraƪ

1.ÏÂÔØFedora-9-i386-DVD£¬·ÅÔÚUÅÌÖУ¨FAT32·ÖÇø£¬Òª×ã¹»´ó²ÅÐÐ 4G¹»ÁË£© URL£ºhttp://fedoraproject.org/zh_CN/get-fedora
2.ÌáÈ¡³öisolinuxÎļþ¼ÐÏÂÃæµÄÁ½¸öÎļþ initrd.img ºÍ vmlinuz ·ÅÔÚCÅ̸ùĿ¼Ï¡£
3.ÏÂÔØgrub4dos£¬½âѹÌáÈ¡³ö¸öÈý¸öÎļþ grldr grub.exe ºÍ menu.lst(ÈôÎÞ´ËÎļþ£¬Ôò¿É×Ô¼ºÔÚCÅÌϽ¨Ò»¸ötxtÎļþ£ ......

linuxÏÂÌí¼Ó·Óɵķ½·¨

linuxÏÂÌí¼Ó·Óɵķ½·¨£º
Ò»£ºÊ¹Óà route ÃüÁîÌí¼Ó
ʹÓÃroute ÃüÁîÌí¼ÓµÄ·ÓÉ£¬»úÆ÷ÖØÆô»òÕßÍø¿¨ÖØÆôºó·ÓɾÍʧЧÁË£¬·½·¨£º
//Ìí¼Óµ½Ö÷»úµÄ·ÓÉ
# route add –host 192.168.168.110 dev eth0
# route add –host 192.168.168.119 gw 192.168.168.1
//Ìí¼Óµ½ÍøÂçµÄ·ÓÉ
# route add –net IP netma ......

¹ØÓÚLinuxʹÓõÄÕæʵÄÚ´æ

ÎÒÃÇʹÓõÄLinuxºÍWindows¿É²»Ì«Ò»Ñù£¬ÓÃtopÃüÁîµÃ³öÀ´µÄ¿ÉÄܲ»ÊÇÕæʵʹÓõÄÄڴ棬ÓÃfreeÃüÁîµÚ¶þÐвÅÊÇϵͳÕæʵʹÓõÄÄÚ´æ¡£Èç¹û·¢ÏÖPHP-CGI°ÑÄãµÄÄÚ´æÕ¼ÂúÁ˿ɲ»Òª¾ª»ÅŶ¡£
Page cacheºÍbuffer cacheÒ»Ö±ÒÔÀ´ÊÇÁ½¸ö±È½ÏÈÝÒ×»ìÏýµÄ¸ÅÄÔÚÍøÉÏÒ²ÓкܶàÈËÔÚÕù±çºÍ²ÂÏëÕâÁ½¸öcacheµ½µ×ÓÐʲôÇø±ð£¬ÌÖÂÛµ½×îºóҲһֱûÓÐÒ»¸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ