LinuxϵͳϵĶàÏ̱߳à³ÌÈëÃŶþ
ÐÞ¸ÄÏ̵߳ÄÊôÐÔ
¡¡¡¡ÔÚÉÏÒ»½ÚµÄÀý×ÓÀÎÒÃÇÓÃpthread_createº¯Êý´´½¨ÁËÒ»¸öỊ̈߳¬ÔÚÕâ¸öÏß³ÌÖУ¬ÎÒÃÇʹÓÃÁËĬÈϲÎÊý£¬¼´½«¸Ãº¯ÊýµÄµÚ¶þ¸ö²ÎÊýÉèΪNULL¡£µÄÈ·£¬¶Ô´ó¶àÊý³ÌÐòÀ´Ëµ£¬Ê¹ÓÃĬÈÏÊôÐԾ͹»ÁË£¬µ«ÎÒÃÇ»¹ÊÇÓбØÒªÀ´Á˽âÒ»ÏÂÏ̵߳ÄÓйØÊôÐÔ¡£
¡¡¡¡ÊôÐԽṹΪpthread_attr_t£¬ËüͬÑùÔÚÍ·Îļþ/usr/include/pthread.hÖж¨Ò壬ϲ»¶×·¸ùÎʵ׵ÄÈË¿ÉÒÔ×Ô¼ºÈ¥²é¿´¡£ÊôÐÔÖµ²»ÄÜÖ±½ÓÉèÖã¬ÐëʹÓÃÏà¹Øº¯Êý½øÐвÙ×÷£¬³õʼ»¯µÄº¯ÊýΪpthread_attr_init£¬Õâ¸öº¯Êý±ØÐëÔÚpthread_createº¯Êý֮ǰµ÷Óá£ÊôÐÔ¶ÔÏóÖ÷Òª°üÀ¨ÊÇ·ñ°ó¶¨¡¢ÊÇ·ñ·ÖÀë¡¢¶ÑÕ»µØÖ·¡¢¶ÑÕ»´óС¡¢ÓÅÏȼ¶¡£Ä¬ÈϵÄÊôÐÔΪ·Ç°ó¶¨¡¢·Ç·ÖÀ롢ȱʡ1MµÄ¶ÑÕ»¡¢Ó븸½ø³ÌͬÑù¼¶±ðµÄÓÅÏȼ¶¡£
¡¡¡¡¹ØÓÚÏ̵߳İ󶨣¬Ç£Éæµ½ÁíÍâÒ»¸ö¸ÅÄÇá½ø³Ì£¨LWP£ºLight Weight Process£©¡£Çá½ø³Ì¿ÉÒÔÀí½âΪÄÚºËỊ̈߳¬ËüλÓÚÓû§²ãºÍϵͳ²ãÖ®¼ä¡£ÏµÍ³¶ÔÏß³Ì×ÊÔ´µÄ·ÖÅä¡¢¶ÔÏ̵߳ĿØÖÆÊÇͨ¹ýÇá½ø³ÌÀ´ÊµÏֵģ¬Ò»¸öÇá½ø³Ì¿ÉÒÔ¿ØÖÆÒ»¸ö»ò¶à¸öÏ̡߳£Ä¬ÈÏ×´¿öÏ£¬Æô¶¯¶àÉÙÇá½ø³Ì¡¢ÄÄЩÇá½ø³ÌÀ´¿ØÖÆÄÄЩÏß³ÌÊÇÓÉϵͳÀ´¿ØÖƵģ¬ÕâÖÖ×´¿ö¼´³ÆΪ·Ç°ó¶¨µÄ¡£°ó¶¨×´¿öÏ£¬Ôò¹ËÃû˼Ò壬¼´Ä³¸öÏ̶̹߳¨µÄ"°ó"ÔÚÒ»¸öÇá½ø³ÌÖ®ÉÏ¡£±»°ó¶¨µÄÏ߳̾ßÓнϸߵÄÏìÓ¦Ëٶȣ¬ÕâÊÇÒòΪCPUʱ¼äƬµÄµ÷¶ÈÊÇÃæÏòÇá½ø³ÌµÄ£¬°ó¶¨µÄÏ߳̿ÉÒÔ±£Ö¤ÔÚÐèÒªµÄʱºòËü×ÜÓÐÒ»¸öÇá½ø³Ì¿ÉÓá£Í¨¹ýÉèÖñ»°ó¶¨µÄÇá½ø³ÌµÄÓÅÏȼ¶ºÍµ÷¶È¼¶¿ÉÒÔʹµÃ°ó¶¨µÄÏß³ÌÂú×ãÖîÈçʵʱ·´Ó¦Ö®ÀàµÄÒªÇó¡£
¡¡¡¡ÉèÖÃḬ̈߳ó¶¨×´Ì¬µÄº¯ÊýΪ pthread_attr_setscope£¬ËüÓÐÁ½¸ö²ÎÊý£¬µÚÒ»¸öÊÇÖ¸ÏòÊôÐԽṹµÄÖ¸Õ룬µÚ¶þ¸öÊÇ°ó¶¨ÀàÐÍ£¬ËüÓÐÁ½¸öÈ¡Öµ£º PTHREAD_SCOPE_SYSTEM£¨°ó¶¨µÄ£©ºÍPTHREAD_SCOPE_PROCESS£¨·Ç°ó¶¨µÄ£©¡£ÏÂÃæµÄ´úÂë¼´´´½¨ÁËÒ»¸ö°ó¶¨µÄÏ̡߳£
#include £¼pthread.h£¾
pthread_attr_t attr;
pthread_t tid;
/*³õʼ»¯ÊôÐÔÖµ£¬¾ùÉèΪĬÈÏÖµ*/
pthread_attr_init(&attr);
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
pthread_create(&tid, &attr, (void *) my_function, NULL);
¡¡¡¡Ï̵߳ķÖÀë״̬¾ö¶¨Ò»¸öÏß³ÌÒÔʲôÑùµÄ·½Ê½À´ÖÕÖ¹×Ô¼º¡£ÔÚÉÏÃæµÄÀý×ÓÖУ¬ÎÒÃDzÉÓÃÁËÏ̵߳ÄĬÈÏÊôÐÔ£¬¼´Îª·Ç·ÖÀë״̬£¬ÕâÖÖÇé¿öÏ£¬ÔÓеÄÏ̵߳ȴý´´½¨µÄÏ߳̽áÊø¡£Ö»Óе±pthread_join£¨£©º¯Êý·µ»Øʱ£¬´´½¨µÄÏ̲߳ÅËãÖÕÖ¹£¬²ÅÄÜÊÍ·Å×Ô¼ºÕ¼ÓõÄϵͳ×ÊÔ´¡£¶ø·ÖÀëÏ̲߳»ÊÇÕâÑù×ӵģ¬ËüûÓб»ÆäËûµÄÏß³ÌËùµÈ´ý£¬×Ô¼ºÔËÐнáÊøÁË£¬Ïß³ÌÒ²¾ÍÖÕÖ¹ÁË£¬ÂíÉÏÊÍ·Åϵͳ×ÊÔ´¡£³ÌÐòÔ±Ó¦¸
Ïà¹ØÎĵµ£º
2.2 ¹¹½¨ARM Linux½»²æ±àÒ빤¾ßÁ´
¹¹½¨½»²æ±àÒëÆ÷µÄµÚÒ»¸ö²½Öè¾ÍÊÇÈ·¶¨Ä¿±êƽ̨¡£ÔÚGNUϵͳÖУ¬Ã¿¸öÄ¿±êƽ̨¶¼ÓÐÒ»¸öÃ÷È·µÄ¸ñʽ£¬ÕâЩÐÅÏ¢ÓÃÓÚÔÚ¹¹½¨¹ý³ÌÖÐʶ±ðҪʹÓõIJ»Í¬¹¤¾ßµÄÕýÈ·°æ±¾¡£Òò´Ë£¬µ±ÔÚÒ»¸öÌض¨Ä¿±ê»úÏÂÔËÐÐGCCʱ£¬GCC±ãÔÚĿ¼·¾¶ÖвéÕÒ°üº¬¸ÃÄ¿±ê¹æ·¶µÄÓ¦ÓóÌÐò·¾¶¡£GNUµÄÄ¿±ê¹æ·¶¸ñʽΪCPU-PLATF ......
ÔõÑù´´½¨ÕæÕýºÜСµÄLinuxϵÄELF¿ÉÖ´ÐÐÎļþ
תÔØ: ELFÎļþ¸ñʽÑо¿
ÈÕÆÚ: Friday, July 25 @ 14:46:16 CST
Ö÷Ì⣺ Èí¼þ¿ª·¢
·¢ÐÅÈË: someone (++), ÐÅÇø: Linux
±ê Ìâ: ÔõÑù´´½¨ÕæÕýºÜСµÄLinuxϵÄELF¿ÉÖ´ÐÐÎļþ
·¢ÐÅÕ¾: ......
·½±ãµÄlinuxÃüÁîÊÖ²á
À´Ô´: ChinaUnix²©¿Í ¡¡ÈÕÆÚ£º 2006.07.24 00:31¡¡(¹²ÓÐ0ÌõÆÀÂÛ) ÎÒÒªÆÀÂÛ
NO
·ÖÀà
PS1
ÃüÁîÃû
Ó÷¨¼°²ÎÊý
¹¦ÄÜ×¢½â
¶ÔÓ¦Õ½Ú
1
Îļþ¹ÜÀí
#
ls
ls -a
Áгöµ±Ç°Ä¿Â¼ÏµÄËùÓÐÎļþ£¬°üÀ¨ÒÔ.Í·µÄÒþº¬Îļþ
Îļþ¹ÜÀí
#
ls
ls -l»òll
Áгöµ±Ç°Ä¿Â¼ÏÂÎļþµÄÏêϸР......
1£ºËùÐèÍ·Îļþ£º<systypes.h>£¨Êý¾ÝÀàÐͶ¨Ò壩 < sys/socket.h>£¨Ìṩsocketº¯ÊýºÍÊý¾Ý½á¹¹£©
<netinet/in.h>£¨¶¨ÒåÊý¾Ý½á¹¹sockaddr_in£© <netdb.h>£¨Ìṩ»ñÈ¡ÓòÃû»òIPµÄº¯Êý£©
<arpa/inet.h>£¨ÌṩIPµØַת»»º¯Êý£© < ......