Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÊÖ²á½Ðø²¹ÉÏ¡£


Ïà¹ØÎĵµ£º

linuxÏÂÃæʹÓÃdu

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

¸ÃÈçºÎÐÞ¸´linuxÒýµ¼ÄØ£¿ÔÚ´Ó×°xpºó£¿

¸ÃÈçºÎÐÞ
¸´linuxÒýµ¼ÄØ£¿ÔÚ´Ó×°xpºó£¿ÎÒ·ÖÏíÒ»ÏÂÎҵľ­Ñ飺ÎÒÊÇÓùâÅÌ°²×°ºìÆì6.0µÄ£¬Ê×ÏȽ«¹âÅÌ·ÅÈë¹âÇý£¬ÏÖÔڵĵçÄÔÒ»°ã¶¼Ö§³Ö´Ó¹âÇýÆô¶¯£¬È»ºóÖØÆôµç
ÄÔÕâʱ»á³öÏÖºìÆìµÄ°²×°½çÃ棬ÏÂÃ滹ÓÐboot£ºµÄ×ÖÑùÕâʱ£¬ÎÒ°´f5£¬½øÈëlinux
rescue½çÃæ¾ÍÊÇlinuxÐÞ¸´½çÃ棬½Ó×Å°´»Ø³µ¼ü£¬¾Í»á½øÈëºÍ¿ªÊ¼°²×°½çÃæÒ»ÑùµÄ½çÃ棬
......

Linux makefile ½Ì³Ì ·Ç³£Ïêϸ£¬ÇÒÒ׶®

 ×î½üÔÚѧϰLinuxϵÄC±à³Ì£¬ÂòÁËÒ»±¾½Ð¡¶Linux»·¾³ÏµÄC±à³ÌÖ¸ÄÏ¡·¶Áµ½makefile¾ÍÔ½¿´Ô½ÃÔºý£¬¿ÉÄÜÊÇÎÒµÄÀí½âÄܲ»ÐС£
            ÓÚÊÇgoogleµ½ÁËÒÔÏÂÕâƪÎÄÕ¡£Í¨Ë×Ò׶®¡£È»ºó°ÑËüÌù³öÀ´£¬·½±ãѧϰ¡£
        & ......

¼ÇÒäÖеļÆËã»ú 11 (DELL Pentium IV ºÍ GNU/Linux)

À뿪Õâ¼Ò¹«Ë¾Ò²ÒѾ­ÎåÄê¶àÁË£¬ÔÙ֮ǰÓÐÒ»¸öÅóÓÑÀ뿪ʱ£¬ÎÒ»¹Ì¸µ½ÐÄÖеÄÓ²¼þÀíÏ룬ËûÖ»ÊÇ˵À뿪Ӳ¼þºÜ¶àÄêÖ®ºó¿ÖÅÂÒѾ­ÎÞ·¨»ØÈ¥ÁË£¬µ±Ê±ÎÒËäȻû˵ʲô£¬ÐÄÀﻹÊÇÓÐЩÎÞÄεġ£½ñÌ쵱дµ½ÏÖÔÚµÄʱºò£¬·¢ÏÖÓ²¼þÔÚÎҵŤ×÷ÖÐÒѾ­½¥½¥µ­»¯ÁË£¬ÊDz»ÊÇËüÕæµÄ²»ÖØÒªÁË£¿
ÓÚÊÇдϽñÌìµÄ±êÌâµÄʱºò£¬¾ö¶¨¼ÓÉÏGNU/Linux£¬ÒòΪËü³ÉΪÁ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ