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

linux api±Ê¼Ç£¨3£©£ºỊ̈߳¨Ò»£©

±¾ÎÄÖн«½²Êölinux»·¾³±à³ÌÖÐÏ̵߳ÄʹÓᣲ»Ëµ·Ï»°Ö±½ÓÉÏ´úÂ룺
#include <pthread.h>
#include <assert.h>
struct ThreadData
{
int i;
};
void * ThreadProc(void* arg)
{
ThreadData* data = static_cast<ThreadData*>(arg);
//do something

pthread_exit(data);
}
int main()
{
pthread_t thread_handle = 0;

ThreadData *data = new ThreadData;
//create thread
pthread_create(&thread_handle, NULL, ThreadProc, data);
//wait the created thread finished
ThreadData * out_data = NULL;
pthread_join(thread_handle, (void**)&out_data);
assert(out_data == data);
delete (out_data);
return 0;
}
ÉÏÃæµÄ´úÂëÖ÷ÒªÓÐ3¸öÏ̲߳Ù×÷µÄϵͳµ÷Óã¬Ò»°ãÇé¿öÏÂÕâ3¸ö¾Í¹»ÎÒÃÇÓÃÁË¡£
pthread_create£º´´½¨Ï̡߳£µÚÒ»¸ö²ÎÊýÊÇout²ÎÊý£¬ËüÊä³öÁË´´½¨ºÃµÄÏ̵߳Ä
±êÖ¾·û-Ïß³ÌID¡£µÚ¶þ²ÎÊýÊÇÓÃÀ´ÉèÖÃÏ̵߳ÄÊôÐԵģ¬ºóÃæ»áÓн²½â¡£µÚÈý¸ö²ÎÊýÊÇ
Ò»¸öº¯ÊýÖ¸Õ룬Õâ¸öÖ¸ÕëÖ¸ÏòµÄº¯ÊýÔÚÏ̴߳´½¨³É¹¦Ö®ºóÔÙеÄÏß³ÌÖÐÖ´ÐС£µÚËĸö
²ÎÊýÊÇÒ»¸öÖ¸Õ룬Õâ¸öÖ¸ÕëÔÚµÚÈý¸ö²ÎÊýÖ¸ÏòµÄº¯ÊýÖ´ÐÐʱ´«ÈëÕâ¸öº¯ÊýÖС£
pthread_exit£ºÔÚÏß³ÌÍ˳ö֮ǰʹÓã¬Õâ¸öº¯ÊýÓÐÒ»¸ö²ÎÊý£¬ÊÇÖ¸Õ룬Õâ¸öÖ¸Õë
ÔÚpthread_joinµÄʱºò½«±»ÊÕµ½¡£Õâ¸öº¯Êý±ØÐëÔÚÏß³ÌÄÚ²¿Ê¹Óã¨ÆäʵÎÒÃÇÖ»Òª¿´µ½
ËüûÓÐpthread_tÀàÐ͵IJÎÊýÎÒÃǾÍÖªµÀÖ»ÄÜÔÚÏß³ÌÄÚʹÓã©¡£
pthread_join£ºµÚÒ»¸ö²ÎÊýÊÇpthread_t£¬ËµÃ÷Õâ¸öº¯Êý²»ÊÇÔÚ¶ÔÓ¦µÄÏß³ÌÄÚʹÓÃ
µÄ¡£ÔÚµ÷ÓÃÕâ¸öº¯Êýºó£¬µ÷ÓÃÕߣ¨Ä³¸öỊ̈߳©½«±»×èÈû£¬²¢ÇÒÒ»Ö±µÈ´ý£¬Ö±µ½µÚÒ»¸ö²ÎÊý
¶ÔÓ¦µÄÏß³ÌÖÐÖ¹£¬¶ÔÓ¦Ïß³ÌÖÕÖ¹Ö®ºóÕâ¸öº¯Êý½«·µ»Ø¡£pthread_joinµÄµÚ¶þ¸ö²ÎÊýÊÇÒ»¸ö
Ö¸ÕëµÄÖ¸ÕëÀàÐÍ£¬out²ÎÊý£¬º¯Êý½áÊøºóËüÖ¸ÏòÁËpthread_exitº¯ÊýÊäÈëµÄµÚ¶þ¸ö²ÎÊý¡£
±¾ÎÄÖнéÉܵÄ3¸öº¯ÊýµÄʹÓÃÆäʵÊÇһЩ×î»ù±¾µÄʹÓã¬ÆäÖв¢Ã»ÓÐÉæ¼°µ½Ò»Ð©Ï¸½Ú
ºÍ×¢ÒâÊÂÏºóÃæµÄÎÄÕÂÖÐÎÒ»á½áºÏmanÊÖ²á½Ðø²¹ÉÏ¡£


Ïà¹ØÎĵµ£º

Windows server 2008 R2 µÄHyper V ¶ÔLINUXµÄÖ§³ÖÌ«ÀÃ

Ì«ÀõÄÔ­ÒòÓÐÒÔÏÂ4Ìõ£º
£±¡¢ÔÚWINDOWS SERVER 2008 SP2ÉϾͰ²×°¹ýubuntu 9.04£¬°²×°Ê±ÏÔʾËÙ¶ÈÆæÂý£¬¼òµ¥ÎÞ·¨ÈÌÊÜ£¬Îı¾Ä£Ê½£¬Ò»ÐÐÒ»ÐÐË¢£¬ÈÃÎÒÏëÆðµ±ÄêÔÚ£²£¸£¶ÉÏʹÓÃEGAÏÔ¿¨µÄÒ£Ô¶¹ýÈ¥£»
£²¡¢ÔÚWINDOWS SERVER 2008 R2ÉÏ°²×°ubutun 10.04£¬Çé¿öÒ»¸öÑù£¬ÔÙҲûÓÐÓÂÆø°²×°½øÐÐÏÂÈ¥£»
£³¡¢ÔÚWINDOWS SERVER 2008 SP2ÉϾͰ ......

linuxÏÂTC+HTBÁ÷Á¿¿ØÖÆ


C¹æÔòÉæ¼°µ½ ¶ÓÁÐ(QUEUE) ·ÖÀàÆ÷(CLASS) ¹ýÂËÆ÷£¨FILTER£©,filter»®·ÖµÄ±ê־λ¿ÉÓÃU32»òiptablesµÄset-markÀ´ÊµÏÖ ) Ò»°ãÊÇ"¿Ø·¢"²»¿ØÊÕ linuxÏÂÓÐÁ½¿éÍø¿¨,Ò»¸öeth1ÊÇÍâÍø,ÁíÒ»¿éeth0ÊÇÄÚÍø.ÔÚeth0ÉÏ×öHTB¡££¨×¢Ò⣺filter»®·Ö±ê־λ¿ÉÓÃu32´ò±ê¹¦ÄÜ»òiptablesµÄset-mark¹¦ÄÜ£¬Èç¹ûÓÃiptablesÀ´´ò±ê¼ÇµÄ»°£¬ÏÂÐÐËÙLVÔÚet ......

linuxÏÂÃæʹÓÃdu

du -sh xmldb/
    du -sm * | sort -n //ͳ¼Æµ±Ç°Ä¿Â¼´óС ²¢°²´óС ÅÅÐò
    du -sk * | sort -n
    du -sk * | grep guojf //¿´Ò»¸öÈ˵ĴóС
    du -m | cut -d "/" -f 2 //¿´µÚ¶þ¸ö/ ×Ö·ûÇ°µÄÎÄ×Ö
    ²é¿´´ËÎļþ¼Ð ......

Linux C ʹÓÃÖ¸Õë·ÃÎʳÉÔ±

  ÔÚLinuxÓÃc±à³Ì£¬ºÜ¶àʱºò¶¼»áÅöµ½½á¹¹ÌåÕâ¸ö¸ÅÄÓÈÆäÊÇʹÓÃÖ¸Õë·ÃÎʽṹÌå³ÉÔ±¡££¨ÏÂÃæµÄÎÄ×Ö½éÉÜ£¬Çë²Î¿¼´úÂëÀí½â£©
        1. ʹÓÃÒ»¸öÐÂÔËËã·û£º->,Õâ¸öÔËËã·ûÓÐÒ»¸öÁ¬½ÓºÅ£¨-£©ºó¸úÒ»¸ö´óÓÚ·ûºÅ£¨>£©×é³É
        &nbs ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ