º¯ÊýÖ¸Õë&»Øµ÷º¯Êý&linuxÖеÄsignalº¯Êý
1.
int (*func)();º¯ÊýÖ¸Õ룬ָÏòµÄº¯ÊýΪ¿Õ²ÎÊý£¬·µ»ØÕûÐÍ£»
2.
»Øµ÷º¯ÊýÊÇÒ»¸ö³ÌÐòÔ±²»ÄÜÏÔʽµ÷Óõĺ¯Êý£»Í¨¹ý½«»Øµ÷º¯ÊýµÄµØÖ·´«¸ø±»µ÷ÓÃÕß´Ó¶øʵÏÖµ÷Óá£
»Øµ÷º¯ÊýÊÇÒ»¸öͨ¹ýº¯ÊýÖ¸Õëµ÷Óõĺ¯Êý¡£Èç¹ûÄã°Ñº¯ÊýµÄÖ¸Õ루µØÖ·£©×÷Ϊ²ÎÊý´«µÝ¸øÁíÒ»¸öº¯Êý£¬µ±Õâ¸öÖ¸Õë±»ÓÃΪµ÷ÓÃËüËùÖ¸ÏòµÄº¯Êýʱ£¬ÎÒÃǾÍ˵ÕâÊǻص÷º¯Êý¡£
void f()£»// º¯ÊýÔÐÍ
ÉÏÃæµÄÓï¾äÉùÃ÷ÁËÒ»¸öº¯Êý£¬Ã»ÓÐÊäÈë²ÎÊý²¢·µ»Øvoid¡£ÄÇôº¯ÊýÖ¸ÕëµÄÉùÃ÷·½·¨ÈçÏ£º
void (*) ();
ÈÃÎÒÃÇÀ´·ÖÎöһϣ¬×ó±ßÔ²À¨»¡ÖеÄÐǺÅÊǺ¯ÊýÖ¸ÕëÉùÃ÷µÄ¹Ø¼ü¡£ÁíÍâÁ½¸öÔªËØÊǺ¯ÊýµÄ·µ»ØÀàÐÍ£¨void£©ºÍÓɱßÔ²À¨»¡ÖеÄÈë¿Ú²ÎÊý£¨±¾ÀýÖвÎÊýÊÇ¿Õ£©¡£×¢Òâ±¾ÀýÖл¹Ã»Óд´½¨Ö¸Õë±äÁ¿-Ö»ÊÇÉùÃ÷Á˱äÁ¿ÀàÐÍ¡£Ä¿Ç°¿ÉÒÔÓÃÕâ¸ö±äÁ¿ÀàÐÍÀ´´´½¨ÀàÐͶ¨ÒåÃû¼°ÓÃsizeof±í´ïʽ»ñµÃº¯ÊýÖ¸ÕëµÄ´óС£º
// »ñµÃº¯ÊýÖ¸ÕëµÄ´óС
unsigned psize = sizeof (void (*) ());
// Ϊº¯ÊýÖ¸ÕëÉùÃ÷ÀàÐͶ¨Òå
typedef void (*pfv) ();
pfvÊÇÒ»¸öº¯ÊýÖ¸Õ룬ËüÖ¸ÏòµÄº¯ÊýûÓÐÊäÈë²ÎÊý£¬·µ»ØÀàÐÐΪvoid¡£Ê¹ÓÃÕâ¸öÀàÐͶ¨ÒåÃû¿ÉÒÔÒþ²Ø¸´Ôӵĺ¯ÊýÖ¸ÕëÓï·¨¡£
Ö¸Õë±äÁ¿Ó¦¸ÃÓÐÒ»¸ö±äÁ¿Ãû£º
void (*p) (); //pÊÇÖ¸Ïòijº¯ÊýµÄÖ¸Õë
pÊÇÖ¸Ïòijº¯ÊýµÄÖ¸Õ룬¸Ãº¯ÊýÎÞÊäÈë²ÎÊý£¬·µ»ØÖµµÄÀàÐÍΪvoid¡£×ó±ßÔ²À¨»¡ÀïÐǺźóµÄ¾ÍÊÇÖ¸Õë±äÁ¿Ãû¡£ÓÐÁËÖ¸Õë±äÁ¿±ã¿ÉÒÔ¸³Öµ£¬ÖµµÄÄÚÈÝÊÇÊðÃûÆ¥ÅäµÄº¯ÊýÃûºÍ·µ»ØÀàÐÍ¡£ÀýÈ磺
void func()
{
/* do something */
}
p = func;
pµÄ¸³Öµ¿ÉÒÔ²»Í¬£¬µ«Ò»¶¨ÒªÊǺ¯ÊýµÄµØÖ·£¬²¢ÇÒÊðÃûºÍ·µ»ØÀàÐÍÏàͬ¡£
´«µÝ»Øµ÷º¯ÊýµÄµØÖ·¸øµ÷ÓÃÕß
ÏÖÔÚ¿ÉÒÔ½«p´«µÝ¸øÁíÒ»¸öº¯Êý£¨µ÷ÓÃÕߣ©- caller()£¬Ëü½«µ÷ÓÃpÖ¸ÏòµÄº¯Êý£¬¶ø´Ëº¯ÊýÃûÊÇδ֪µÄ£º
void caller(void(*ptr)())
{
ptr(); /* µ÷ÓÃptrÖ¸ÏòµÄº¯Êý */
}
void func();
int main()
{
p = func;
caller(p); /* ´«µÝº¯ÊýµØÖ·µ½µ÷ÓÃÕß */
}
Èç¹û¸³Á˲»Í¬µÄÖµ¸øp£¨²»Í¬º¯ÊýµØÖ·£©£¬ÄÇôµ÷ÓÃÕß½«µ÷Óò»Í¬µØÖ·µÄº¯Êý¡£¸³Öµ¿ÉÒÔ·¢ÉúÔÚÔËÐÐʱ£¬ÕâÑùʹÄãÄÜʵÏÖ¶¯Ì¬°ó¶¨¡£
3.º¯ÊýÖ¸ÕëÔÚlinuxÖеÄÓ¦ÓÃsignalº¯Êý
ÔÚUnix/LinuxÖÐsignalº¯ÊýÊDZȽϸ´ÔÓµÄÒ»¸ö,Æ䶨ÒåÔÐÍÈçÏÂ:
void (*signal(int signo,void (*func)(int))) (int)
signal(int signo, void(*func)(int))ÊÇsignalº¯ÊýµÄÖ÷Ìå.
ÐèÒªÁ½¸ö²ÎÊý:intÐ͵Äsigno,ÒÔ¼°Ò»¸öÖ¸Ïòº¯ÊýµÄÖ¸Õë.
void (*
Ïà¹ØÎĵµ£º
ת×Ô£ºhttp://www.yesky.com/366/1793366_1.shtml
2004Äê4ÔÂ20ÈÕ×îа汾µÄGCC±àÒëÆ÷3.4.0·¢²¼ÁË¡£Ä¿Ç°£¬GCC¿ÉÒÔÓÃÀ´±àÒëC/C++¡¢FORTRAN¡¢JAVA¡¢OBJC¡¢ADAµÈÓïÑԵijÌÐò£¬¿É¸ù¾ÝÐèҪѡÔñ°²×°Ö§³ÖµÄÓïÑÔ¡£GCC 3.4.0±ÈÒÔÇ°°æ±¾¸üºÃµØÖ§³ÖÁËC++±ê×¼¡£±¾ÎÄÒÔÔÚRedhat LinuxÉÏ°²×°GCC3.4.0ΪÀý£¬½éÉÜÁËGCCµÄ°²×°¹ý³Ì¡£
¡¡¡¡°²×° ......
ÒëÕߣº¹ùÉÙ±¯
2009/12/02
ÔÎÄ£ºlinux/Documentation/driver-model/device.txt
»ù±¾µÄÉ豸Êý¾Ý½á¹¹
~~~~~~~~~~~~~~~~~~
struct device {
struct list_head g_list;
struct list_head node;
......
×î½ü¶¨ÖÆÁËÒ»¸öubuntuµÄ°²×°½çÃæ,¸Ð¾õ±È½ÏÓÐÒâ˼,дÉÏÀ´,ÓÐÐËȤµÄÅóÓÑ¿ÉÒÔʵ¼ùÒ»ÏÂ...
ÏȽéÉÜÒ»ÏÂgrubºÍisolinux,ÒÔ¼°Ò»Ð©¿ª»úÒýµ¼³ÌÐò...
1)BIOS:basic input output system,Ò»°ãµÄÇé¿öÏÂÊǹé½áÓÚfirmwareÕâÒ»ÀàµÄ.ÕâÀïÊÇΪÁËÁ¬½Óͨ˳,¾Í¼òµ¥µÄ˵һÏÂbios.BIOSÊÇÓû§ÔÚ°´ÏµçÔ´µÄÄÇÒ»¿Ì,¸ºÔðºÍÓ²¼þ¹µÍ¨²¢³ÊÏÖµ½Óû§ÃæÇ°µ ......
1¡¢LinuxÀï²é¿´ËùÓÐÓû§
¡¡¡¡linuxÀï,²¢Ã»ÓÐÏñwindowsµÄnet user,net localgroupÕâЩ·½±ãµÄÃüÁîÀ´ÖÎÀíÓû§.
¡¡¡¡Xwindows½çÃæµÄ¾Í²»ËµÁË.
¡¡¡¡£¨1£©ÔÚÖÕ¶ËÀï.ÆäʵֻÐèÒª²é¿´ /etc/passwdÎļþ¾ÍÐÐÁË.
¡¡¡¡£¨2£©¿´µÚÈý¸ö²ÎÊý:500ÒÔÉϵÄ,¾ÍÊǺóÃ潨µÄÓû§ÁË.ÆäËüÔòΪϵͳµÄÓû§.
¡¡¡¡»òÕßÓÃcat /etc/passwd |cut -f ......
³ö´¦:http://ericxiao.cublog.cn/
Ò»£ºÇ°ÑÔ
ÔÚ¼üÅÌÇý¶¯´úÂë·ÖÎöµÄ±Ê¼ÇÖУ¬½Ó´¥µ½ÁËinput×Óϵͳ.¼üÅÌÇý¶¯£¬¼üÅÌÇý¶¯½«¼ì²âµ½µÄËùÓа´¼ü¶¼Éϱ¨¸øÁËinput×Óϵͳ¡£Input×ÓϵͳÊÇËùÓÐI/OÉ豸Çý¶¯µÄÖмä²ã£¬ÎªÉϲãÌṩÁËÒ»¸öͳһµÄ½çÃæ¡£ÀýÈ磬ÔÚÖÕ¶ËϵͳÖУ¬ÎÒÃDz»ÐèҪȥ¹ÜÓжàÉÙ¸ö¼üÅÌ£¬¶àÉÙ¸öÊó±ê¡£ËüÖ»Òª´Óinput×ÓϵͳÖÐÈ¥È ......