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

linuxÏÂʵÏÖ¶àÏß³Ìͬ²½£¨Ò»£©

²Î¿¼×ÊÁÏ£ºhttp://baike.baidu.com/view/400319.htm
¡¡LinuxϵͳϵĶàÏß³Ì×ñÑ­POSIXÏ߳̽ӿڣ¬³ÆÎªpthread¡£±àдLinuxϵĶàÏ̳߳ÌÐò£¬ÐèҪʹÓÃÍ·Îļþpthread.h£¬Á¬½ÓʱÐèÒª ʹÓÿâlibpthread.a¡£Ë³±ã˵һÏ£¬LinuxÏÂpthreadµÄʵÏÖÊÇͨ¹ýϵͳµ÷ÓÃclone£¨£©À´ÊµÏֵġ£clone£¨£©ÊÇLinuxËùÌØ ÓеÄϵͳµ÷Óã¬ËüµÄʹÓ÷½Ê½ÀàËÆfork£¬¹ØÓÚclone£¨£©µÄÏêϸÇé¿ö£¬ÓÐÐËȤµÄ¶ÁÕß¿ÉÒÔÈ¥²é¿´ÓйØÎĵµËµÃ÷¡£ÏÂÃæÎÒÃÇչʾһ¸ö×î¼òµ¥µÄ¶àÏ̳߳ÌÐò example1.c
 #include <stdio.h>
#include <pthread.h>
#include<sys/types.h>
void thread(void){
int i;
for(i=0;i<3;i++)
printf("This is a pthread.\n");
}
int main(void){
pthread_t id;
int i,ret;
ret = pthread_create(&id,NULL,(void*)thread,NULL);
if(ret!=0){
printf ("Create pthread error!\n");
// exit (1);
}
for(i=0;i<3;i++)
printf("This is the main process.\n");
pthread_join(id,NULL);
return (0);
}
       ÎÒÃDZàÒë´Ë³ÌÐò£º
¡¡¡¡gcc example1.c -lpthread -o example1
      ÎÒËùʹÓõÄÊÇÀÏʦ½ÌµÄ gcc example.c -g -o example -l phread
ÔËÐÐexample1£¬ÎÒÃǵõ½ÈçϽá¹û£º
This is the main process.
This is a pthread.
This is the main process.
This is the main process.
This is a pthread.
This is a pthread.
ÔÙ´ÎÔËÐУ¬ÎÒÃÇ¿ÉÄܵõ½ÈçϽá¹û£º
This is a pthread.
This is the main process.
This is a pthread.
This is the main process.
This is a pthread.
This is the main process.
 
¡¡¡¡Ç°ºóÁ½´Î½á¹û²»Ò»Ñù£¬ÕâÊÇÁ½¸öÏß³ÌÕù¶áCPU×ÊÔ´µÄ½á¹û¡£ÉÏÃæµÄʾÀýÖУ¬ÎÒÃÇʹÓõ½ÁËÁ½¸öº¯Êý£¬¡¡pthread_createºÍpthread_join£¬²¢ÉùÃ÷ÁËÒ»¸öpthread_tÐ͵ıäÁ¿¡£
¡¡¡¡pthread_tÔÚÍ·Îļþ/usr/include/bits/pthreadtypes.hÖж¨Ò壺
¡¡¡¡typedef unsigned long int pthread_t;
¡¡¡¡ËüÊÇÒ»¸öÏ̵߳ıêʶ·û¡£º¯Êýpthread_createÓÃÀ´´´½¨Ò»¸öỊ̈߳¬ËüµÄÔ­ÐÍΪ£º
¡¡¡¡extern int pthread_create __P ((pthread_t *__thread, __const pthread_attr_t *__attr,
¡¡¡¡void *(*__start_routine) (void *), void *__arg));
¡¡¡¡µÚÒ»¸ö²ÎÊýΪָÏòÏ̱߳êʶ·ûµÄÖ¸Õ룬µÚ¶þ¸ö²ÎÊýÓÃÀ´ÉèÖÃÏß³ÌÊôÐÔ£¬µÚÈý¸ö²ÎÊýÊÇÏß³ÌÔËÐк¯ÊýµÄÆðʼµØÖ·


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨Èý£© HCI²ã±à³Ì

1. HCI²ãЭÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI)  ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈЭÒé ......

linuxϵÄssh¡¢telnetµÇ¼½Å±¾£¨tcl£©

 ²Ù×÷ϵͳ£ºlinux£¨feroda4£©
tcl°æ±¾£ºtclsh8.4
expect£º5.43.0
sshµÇ¼½Å±¾
#!/usr/bin/tclsh8.4
package require Expect
set user "root"
set host "10.2.26.30"
spawn ssh $user@$host
expect {
             -re "password: $"       ......

linux cÎÊÌ⼯½õ

1.ΪʲôÎÒдµÄMakefile£¬Ôڱ༭ÁËÔ´´úÂëÎļþºó£¬Ê¹ÓÃmake£¬makeÈ´ÌáʾĿ±êÎļþÒѾ­Îª×îеÄÁË£¡
2.OpenGL,ÔÚ´°¿ÚÖл­µãʱ£¬ÔõÑùʹÓÃglVertexi()º¯Êý£¿ÒòΪ´«µÝµÄ²ÎÊýÈç¹ûÊÇ´óÓÚ1µÄintÐÍ£¬Ôò²»ÐУ¬¶ø±ØÐë´«µÝ[-0.1~0.1]Ö®¼äµÄfloat£¬¶øÇÒʹÓú¯Êý
gVertex2f().
3.OpenGL,ʹÓò˵¥Ê±£¬ÔõÑù½â¾öµã»÷²Ëµ¥ºó²»Òª²¶×½GLUT_UPÊ ......

LinuxÍü¼ÇÁËrootµÄÃÜÂëµÄ½â¾ö°ì·¨

1. ϵͳÆô¶¯ºó,ÔÚ³öÏÖgrub»­ÃæÊ±£¬ÓÃÉÏϼüÑ¡ÖÐÄãÆ½Ê±Æô¶¯linuxµÄÄÇÒ»ÏȻºó°´e¼ü
2. ÔÙ´ÎÓÃÉÏϼüÑ¡ÖÐÄãÆ½Ê±Æô¶¯linuxµÄÄÇÒ»Ïî(ÀàËÆÓÚkernel/boot mlinuz-2.4.18-14 ro root=LABEL=/)£¬È»ºó°´e¼ü
3. ÐÞ¸ÄÄãÏÖÔÚ¼ûµ½µÄÃüÁîÐУ¬¼ÓÈësingle£¬½á¹ûÈçÏ£º
    kernel /boot mlinuz-2.4.18-14 single ro ......

Ò»¸ölinuxÏÂg++ʹÓÃµÄ makefile Ä£°å

 refer:http://www.cnblogs.com/diylab/archive/2008/04/24/1169771.html
Õâ¸ömakefile¿ÉÓÃÓÚ±àÒë´ó¶àÊýµÄc++¹¤³Ì¡£
Äã¿ÉÒÔ¸ù¾ÝÐèÒªÐÞ¸ÄÏÂÃæµÄ²ÎÊý£º
VPATH: Ô´ÎļþµÄÎļþ·¾¶¡£¶à¸öÎļþ¼Ð·¾¶Óÿոñ·Ö¸ô
OBJ£º ±àÒëÄ¿±êËùÐèÒªµÄ.oÎļþ
µ±È»£¬ÄãÒ²¿ÉÒÔ²»¸Ä¶¯´ËÎļþ£¬¶øÖ±½ÓÔÚ make ÃüÁîµÄ²ÎÊýÖÐÖ¸¶¨
È磺
make ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ