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));
¡¡¡¡µÚÒ»¸ö²ÎÊýΪָÏòÏ̱߳êʶ·ûµÄÖ¸Õ룬µÚ¶þ¸ö²ÎÊýÓÃÀ´ÉèÖÃÏß³ÌÊôÐÔ£¬µÚÈý¸ö²ÎÊýÊÇÏß³ÌÔËÐк¯ÊýµÄÆðʼµØÖ·
Ïà¹ØÎĵµ£º
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
½øÈëviºó ÓÐÁ½ÖÖģʽ
1.±à¼Ä£Ê½
2.ÃüÁîģʽ
½øÈëviºóĬÈÏÊÇÃüÁîģʽ£¬ËùÒÔ²»ÒªÂÒ°´ ¾Í»áµÃµ½ddµÄ¾¯¸æÉù£¬ÒªÊäÈëÎÄ×ֵĻ° Çë°´aºói ¾Í¿ÉÒÔ¿ªÊ¼ÊäÈëÎÄ×ÖÀ£¡
ÊäÈë½áÊøºó Çë°´esc¼ü»ØÃüÁîģʽ
ÊäÈëq¾ÍÊÇÍ˳ö
ÊäÈëwq¾ÍÊÇ´æÅ̺óÍ˳ö
ÊäÈëq!·ÅÆú´æÅÌÇ¿ÐÐÍ˳ö
.
Vi µÄʹÓÃ
Vi ÒѾÊÇ Unix ϵͳÖбê×¼µÄÎÄ×Ö±à¼Æ ......
½ñÌìÆð¿ªÊ¼¶ÔLinuxѧϰ×öЩÏà¹ØµÄ±Ê¼Ç£¬ÒÔ±ãÈÕºóÄܹ»ÓõÄÉÏ
1.ÈçºÎÈÃsshÖ»ÔÊÐíÖ¸¶¨µÄÓû§µÇ¼
¿ÉÒÔÔÚ/etc/ssh/sshd_configÖÐÔö¼ÓAllowUsers user_name£¬È»ºóÖØÆô·þÎñ(service sshd restart)
2.¸Ä±ässhµÄ¶Ë¿ÚºÅ
¿ÉÔÚ/etc/ssh/ssd_configÎļþÖмÓÈëÀýÈ磺Port 2222£¬È»ºóÖØÆ ......
1.ΪʲôÎÒдµÄMakefile£¬ÔÚ±à¼ÁËÔ´´úÂëÎļþºó£¬Ê¹ÓÃmake£¬makeÈ´ÌáʾĿ±êÎļþÒѾΪ×îеÄÁË£¡
2.OpenGL,ÔÚ´°¿ÚÖлµãʱ£¬ÔõÑùʹÓÃglVertexi()º¯Êý£¿ÒòΪ´«µÝµÄ²ÎÊýÈç¹ûÊÇ´óÓÚ1µÄintÐÍ£¬Ôò²»ÐУ¬¶ø±ØÐë´«µÝ[-0.1~0.1]Ö®¼äµÄfloat£¬¶øÇÒʹÓú¯Êý
gVertex2f().
3.OpenGL,ʹÓò˵¥Ê±£¬ÔõÑù½â¾öµã»÷²Ëµ¥ºó²»Òª²¶×½GLUT_UPÊ ......
ÔÚlinux ÖУ¬ÊäÈëviʱºò£¬Æäʵ¾ÍÊÇÔÚµ÷ÓÃvimÁË;
ubuntuÖУ¬vi´ò¿ªÒ»¸öº¬ÖÐÎĵÄÎļþ£¬Èç.fcitx/configÎļþ£¬Ä¬ÈÏÏÔʾÂÒÂ룬½â¾ö·½·¨£º
1)¶ÔËùÓÐÓû§¶¼ÓÐЧ,½â¾öϵͳÖÐËùÓÃÓû§µÄviÖÐÎÄÂÒÂëÎÊÌâ
sudo /etc/vim/vimrc.tiny »ò/etc/vimrc
¼ÓÈëÈçÏÂÄÚÈÝ£º
#Ìṩһ¸öʵ¼ùÖо ......