Cº¯ÊýÖ¸Õë×ܽá
±¾ÎĽöÏÞÓÚC£¬Ö÷Òª×Ô¼ºÀÏÍü¡£±ðµÄ·Ï»°ÉÙ˵¡£
1.Basic
Ê×ÏÈ¿¼ÂǺ¯ÊýÔÚº¯ÊýÌåÄڵĶ¨Ò壬ÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
int main()
{
int add(int,int);
int def(int, int);
printf("%d\n", add(1,3));
printf("%d\n", def(3,1));
return 0;
}
int add(int a, int b) { return a+b; }
int def(int a, int b) { return a-b; }
¶¨ÒåÒ»¸öº¯ÊýÖ¸Õ룺
ReturnValue (*fun_ptr)();
ÉÏÃæµÄ´úÂëÓú¯ÊýÖ¸ÕëµôÓÃÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
int main()
{
int add(int,int);
int def(int, int);
int (*p)();
p = add;
printf("%d\n", p(1,3));
p = def;
printf("%d\n", p(3,1));
return 0;
}
int add(int a, int b) { return a+b; }
int def(int a, int b) { return a-b; }
µ½´ËΪֹòËÆûÓÐʲôÓ㬲»¹ý¿ÉÒÔ¿¼ÂÇÒ»¸ö¸ü¼Ó¾ßÓÐÃÀ¸ÐµÄд·¨£¬ÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
typedef struct FuncPtrEle
{
int (*fun_ptr)();
int type_code;
} ptr_t;
int add(int,int);
int def(int, int);
int main()
{
int i = 0;
ptr_t ptr_array[2];
ptr_array[0].fun_ptr = add; //ÕâÁ½Ö¸Õ븳ֵµÄ¹ý³Ì¿ÉÒÔÈÎÒâ·¢»ÓÏëÏóÁ¦¡£
ptr_array[1].fun_ptr = def; //ÖÁÓÚ×÷Óã¬ÏëÏëÃæÏò¶ÔÏóÖеĶà̬°É....
for(i = 0; i < 2; i++)
{
printf("%d\n", ptr_array[i].fun_ptr(3,1));
}
return 0;
}
int add(int a, int b) { ret
Ïà¹ØÎĵµ£º
Ò»¡¢Ê²Ã´ÊÇc/sºÍb/s
ÒªÏë¶Ô“c/s”ºÍ“b/s”¼¼Êõ·¢Õ¹±ä»¯ÓÐËùÁ˽⣬Ê×ÏȱØÐë¸ãÇå³þÈý¸öÎÊÌâ¡£
µÚÒ»¡¢Ê²Ã´ÊÇc/s½á¹¹¡£
c/s£¨client/server£©½á¹¹£¬¼´´ó¼ÒÊìÖªµÄ¿Í»§»úºÍ·þÎñÆ÷½á¹¹¡£ËüÊÇÈí¼þϵͳÌåϵ½á¹¹£¬Í¨¹ýËü¿ÉÒÔ³ä·ÖÀûÓÃÁ½¶ËÓ²¼þ»·¾³µÄÓÅÊÆ£¬½«ÈÎÎñºÏÀí·ÖÅäµ½client¶ËºÍserver¶ËÀ´ÊµÏÖ£¬½µµÍÁ ......
Ô´³ÌÐò±àÒë
MakefileµÄ±àд
³ÌÐò¿âµÄÁ´½Ó
³ÌÐòµÄµ÷ÊÔ
Í·ÎļþºÍϵͳÇóÖú
1.Ô´³ÌÐòµÄ±àÒë
ÔÚLinuxÏÂÃæ,Èç¹ûÒª±àÒëÒ»¸öCÓïÑÔÔ´³ÌÐò,ÎÒÃÇҪʹÓÃGNUµÄgcc±àÒëÆ÷. ÏÂÃæÎÒÃÇÒÔÒ»¸öʵÀýÀ´ËµÃ÷ÈçºÎʹÓÃgcc±àÒëÆ÷.
......
ÒÔ i2c-mpc.c Çý¶¯Ä£¿éΪÀý
fsl_i2c_init -> of_register_platform_driver -> of_register_driver -> driver_register -> bus_add_driver -> driver_attach
-> bus_for_each_dev -> __driver_attach -> driver_probe_device -> really_probe -> drv->probe(dev); ......
¼ì²éÄں˲ÎÊý
ÕýÔÚ¼ì²é semmsl=250; ÒÑ·¢ÏÖ semmsl=250¡£ ͨ¹ý
ÕýÔÚ¼ì²é semmns=32000; ÒÑ·¢ÏÖ semmns=32000¡£ ͨ¹ý
ÕýÔÚ¼ì²é semopm=100; ÒÑ·¢ÏÖ semopm=32¡£ ʧ°Ü <<<<
ÕýÔÚ¼ì²é semmni=128; ÒÑ·¢ÏÖ semmni=128¡£ ͨ¹ý
ÕýÔÚ¼ì²é shmmax=536870912; ÒÑ·¢ÏÖ shmmax=33554432¡£ ʧ°Ü <<<< ......
9.2 ¹²ÓÃÌå
CÓïÑÔ³ýÁËÌṩ½á¹¹ÌåÕâÖÖ¿É°üº¬¶àÖÖÀàÐÍÊý¾ÝµÄ¹¹ÔìÀàÐÍÍ⣬»¹ÌṩÁËÒ»ÖÖ´ÓÐÎʽÉÏ¿´ºÍ½á¹¹Ìå¿°³Æ“ÂÏÉúÐֵܔµÄ¹¹ÔìÀàÐÍ——¹²ÓÃÌ壨union£©¡£
±¾½Ú´Ó¹²ÓÃÌåµÄ¸ÅÄîÈëÊÖ£¬´Ó¹²ÓÃÌåµÄ¸ÅÄî¡¢Óë½á¹¹ÌåµÄÒìͬ¡¢Ê¹Óõȷ½Ãæ½øÐÐÏêϸµÄ½éÉÜ¡£
9.2.1 ʲôÊǹ²ÓÃÌå
ÏÖʵÉú»îÖУ¬Ä³Ð©Ê ......