linux fork() º¯ÊýʵÀýÏê½â
forkº¯Êýѧϰ£º
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
main ()
{
pid_t pid; pid=fork();
if (pid < 0)
printf("error in fork!");
else if (pid == 0)
printf("i am the child process, my process id is %dn",getpid());
else
printf("i am the parent process, my process id is %dn",getpid());
}
Õâ¶Î´úÂëдÁËÒ»¸öʹÓÃforkº¯Êý´´½¨×Ó½ø³Ì£¬¸¸×Ó½ø³ÌͬʱÔËÐжø²úÉú½»´íµÄ£¬²»Ò»ÑùµÄÔËÐнá¹û¡£ÔËÐнá¹ûÈçÏ£º
# ./a.out
i am the child process, my process id is 4286
i am the parent process, my process id is 4285
forkÔÚÓ¢ÎÄÖÐÊDzæ×Ó£¬·Ö²æµÄÒâ˼£¬ÔÚº¯ÊýforkÖУ¬È¡ºóÃæµÄÒâ˼¡£ºÜÐÎÏóµÄ±íʾ³ÌÐò´ÓÕâÀï·Ö²æ£¬forkº¯Êý´´½¨ÁË×Ó½ø³Ì£¬×Ó½ø³ÌºÍ¸¸½ø³Ìͬʱ£¨ÆäʵÊÇcpu·Öʱ´¦Àí£©¿ªÊ¼ÔËÐзֲæÖ®ºóµÄ³ÌÐò¡£
³ÌÐò¸ÄдÏ£º
main()
{
pid_t pid;
printf("\n[%d]not fork pid=%d\n",getpid(),pid);
pid=fork();
printf("\n[%d]forked pid=%d\n",getpid(),pid);
if(pid<0)
{
printf("error in fork!\n");
getchar();
exit(1);
}
else if(pid==0)
printf("\n[%d]in child process,p_id=%d\n",getpid(),getpid());
else
{
printf("\n[%d]in parent process,my pid=%d\n",getpid(),pid);
printf("\n[%d]in parent process,my getpid=%d\n",getpid(),getpid());
}
}
³ÌÐòÔËÐнá¹ûÈçÏ£º
$ ./fork
[3819]not fork
[3820]forked pid=0
[3820]in child process,p_id=3820
[3819]forked pid=3820
[3819]in parent process,my pid=3820
[3819]in parent process,my getpid=3819
¿ÉÒÔÇå³þµÄ¿´µ½ not forkÖ»´òÓ¡ÁËÒ»´Î£¬ÆäÖÐ[3819]ÊǸ¸½ø³ÌµÄ½ø³ÌºÅ£¬´´½¨forkÒÔºó£¬forkº¯Êý·µ»Ø¸ø¸¸½ø³ÌµÄÖµpidÊÇ×Ó½ø³ÌµÄ½ø³ÌºÅ[3820]£¬¶øÔÚ×Ó½ø³ÌÖУ¬pidֵΪÁã¡£Ò²¾ÍÊÇ˵×Ó½ø³ÌÖУ¬pid±»ÖÃÁã¡£ ÒýÓÃÍøÉÏÒ»Î»ÍøÓѵĽâÊÍ“Æäʵ¾ÍÏ൱ÓÚÁ´±í£¬½ø³ÌÐγÉÁËÁ´±í£¬¸¸½ø³Ìpid(p Òâζpoint)Ö¸Ïò×Ó½ø³ÌµÄ½ø³
Ïà¹ØÎĵµ£º
1. HCI²ãÐÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI) ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈÐÒé ......
ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......
COMÅäÖÃ
ÏȽøÐÐÐéÄâ»úÉ豸ÅäÖÃ
ÔÚÍê³ÉLINUXÏÂϵͳÅäÖÃ
com¶Ë¿ÚÅäÖÃ
ÒÔºóÖ»ÒªÔÚÃüÁîÐÐÏÂÊäÈë >minicom »Ø³µ¾Í¿ÉÒÔ¿´µ½Õâ¸ö²Ëµ¥ÁË ºÇºÇ
JTAGÅäÖã¨Ï൱ÓÚwinϵÄH-JTAG£©
ÏÂÔØJflashѹËõ°ü tar½âѹµ½/Ŀ¼ÏÂ
´ò¿ªÐéÄâ»ú
½ÓºÃJTAG²¢¿ÚÏߣ¬½øÈëlinuxϵͳÊäÈëÃüÁî
......
ÓÐʱºòΪÁË·½±ã£¬ÀûÓÃevent/triggerµ÷ÓÃϵͳÍⲿÃüÁ¿ÉÒòΪ°²È«ÎÊÌ⣬mysql×ÔÉí²¢Ã»ÓÐÌṩÏà¹ØÃüÁÕâÀïÌṩ¸öµ÷ÓÃϵͳÃüÁîµÄ×Ô¶¨Ò庯Êýmylab_sys_exec
soÎļþÏÂÔØ:mylab_sys_exec.so ( mysql5.1.34 ²âÊÔͨ¹ý)
¼ÓÔØ:
CREATE FUNCTION mylab_sys_exec RETURNS INTEGER SONAME "mylab_sys_exec.so";
ʹÓÃ:
SELECT myl ......