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

linuxÇý¶¯¿ª·¢Ñ§Ï°±Ê¼Ç£¨¶þ£©

                    scull×Ö·ûÇý¶¯Ñ§Ï°±Ê¼Ç
Ŀ¼
1 scullÇý¶¯¼ò½é
2 Ö÷´Î±àºÅ
3 scullÔ´Âë·ÖÎö
-------------------------
|  1 scullÇý¶¯¼ò½é      |
-------------------------
  scullÊÇÒ»¸ö×Ö·ûÇý¶¯£¬ÎÒÃDzÙ×÷Ò»¿éÄÚ´æÇøºÃÏñËüÊÇÒ»¸öÉ豸¡£scullÊÇÓ²¼þÉ豸¹ØÁª²»´ó£¬ ËùÒÔËüÊÇͨÓÿÉÒÆÖ²µÄ¡£
-----------------------
|   2 Ö÷´Î±àºÅ        |
----------------------
2.1
  Ëæ±ãÌáÌáÖ÷´Î±àºÅ°É£¡
  ×Ö·ûÉ豸ͨ¹ýÎļþϵͳÖеÄÃû×ÖÀ´´æÈ¡£¬Ò²¾ÍÊdz£ËµµÄÉ豸Îļþ¡£ÎÒÃDz鿴/devĿ¼ÏµÄÎļþ£¬»á²é¿´µ½ÏµÍ³ÏÂËùÓÐÉ豸Îļþ¡£
  Ö÷±àºÅ±êʶÉ豸ÏàÁ¬µÄÇý¶¯¡£´Î±àºÅÓÃÀ´¾ö¶¨ÒýÓÃÄĸöÉ豸£¬ÒÀ¾ÝÄãµÄÇý¶¯ÊÇÈçºÎ±àдµÄ£¬ Äã¿ÉÒÔ´ÓÄں˵õ½Ò»¸öÄãµÄÉ豸µÄÖ±½ÓÖ¸Õë¡£ÄÚºËÔÊÐí¶à¸öÇý¶¯¹²ÏíÖ÷±àºÅ¡£
2.2
  һЩÖ÷É豸±àºÅÊǾ²Ì¬·Ö¸ø×îÆÕͨµÄÉ豸µÄ£¬¶ÔÓÚÐÂÇý¶¯£¬´ó¶àÊýÇé¿öÏÂʹÓö¯Ì¬·ÖÅäÀ´»ñÈ¡ÄãµÄÖ÷É豸ºÅ¡£
  ¶¯Ì¬·ÖÅäÖ÷É豸ºÅº¯Êý
  alloc_chrdev_region
  ¶¯Ì¬·ÖÅäµÄȱµãÊÇÄãÎÞ·¨ÌáÇ°´´½¨É豸½Úµã, ÒòΪ·ÖÅä¸øÄãµÄÄ£¿éµÄÖ÷±àºÅ»á±ä»¯. ¶ÔÓÚÇý¶¯µÄÕý³£Ê¹ÓÃ, Õâ²»ÊÇÎÊÌâ, ÒòΪһµ©±àºÅ·ÖÅäÁË, Äã¿É´Ó /proc/devices ÖжÁÈ¡Ëü¡£ÎªÊ¹Óö¯Ì¬Ö÷±àºÅÀ´¼ÓÔØÒ»¸öÇý¶¯, Òò´Ë, ¿ÉʹÓÃÒ»¸ö¼òµ¥µÄ½Å±¾À´´úÌæµ÷Óà insmod, ÔÚµ÷ÓÃinsmod ºó, ¶ÁÈ¡ /proc/devices À´´´½¨ÌØÊâÎļþ.
  ÔÚscullÔ´ÂëÖлñÈ¡Ö÷±àºÅµÄ´úÂë
if (scull_major) {
    dev = MKDEV(scull_major, scull_minor);
    result = register_chrdev_region(dev, scull_nr_devs, "scull");
} else {
    result = alloc_chrdev_region(&dev, scull_minor, scull_nr_devs, "scull");
    scull_major = MAJOR(dev);
}
if (result < 0) {
    printk(KERN_WARNING "scull: can't get major %d\n", scull_major);
    return result;
}
-------------------
| 3 scullÔ´Âë·ÖÎö |
-------------------
scull É豸½á¹¹Ìå
struct scull_dev {
    struct scull_qset *data;  /* Pointer to first quantum se


Ïà¹ØÎĵµ£º

ǶÈëʽLinux¿ª·¢ÐèÒªµÄ²Î¿¼×ÊÁÏ

Òýµ¼£º
ÈçÐè»ñµÃ¶Ô vmlinux ºÍ zimage Ö®¼äÇø±ðµÄ¼«ºÃ½âÊÍ£¬ÇëÔÚ Alessandro Rubini ±àдµÄ“Kernel Configuration: dealing with the unexpected£¨Linux Magazine£©µÄÒ»ÎÄÖÐÕÒµ½“Booting your kernel”Ò»½Ú¡£
ÓйØÄںˡ¢Ó³ÏñºÍÒýµ¼¹ý³ÌµÄ¸ü¶àÐÅÏ¢£¬ÇëÔĶÁÖÐÑëÀ¥Ê¿À¼´óѧ£¨Central Queensland Universit ......

linux ulimit max open files

ÓÐʱºòÔÚ³ÌÐòÀïÃæÐèÒª´ò¿ª¶à¸öÎļþ£¬½øÐзÖÎö£¬ÏµÍ³Ò»°ãĬÈÏÊýÁ¿ÊÇ1024£¬£¨ÓÃulimit -a¿ÉÒÔ¿´µ½£©¶ÔÓÚÕý³£Ê¹ÓÃÊǹ»ÁË£¬µ«ÊǶÔÓÚ³ÌÐòÀ´½²£¬¾ÍÌ«ÉÙÁË¡£
Ð޸İ취£º
ÖØÆô¾ÍOK
ÐÞ¸Ä2¸öÎļþ¡£
1./etc/security/limits.conf
vi /etc/security/limits.conf
¼ÓÉÏ£º
* soft nofile 8192
* hard nofile 20480
2./etc/pam.d/l ......

linuxϵĶ˿ÚɨÃè¼¼Êõ£¡

Õâ¸öÊÇÎÒÔÚÒ»±¾ÊéÉÏ¿´µ½µÄ£¬ÆäÖеÄһЩ´úÂëÎÒÓÐËù¸Ä±ä£¬Ð´¸ø¸÷λºÃÓѹ²Ïíһϣ¡
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h&g ......

Linux»·¾³½ø³Ì¼äͨÐÅ£¨Î壩——¹²ÏíÄÚ´æ

http://www.ibm.com/developerworks/cn/linux/l-ipc/part5/index1.html
¹²ÏíÄÚ´æ¿ÉÒÔ˵ÊÇ×îÓÐÓõĽø³Ì¼äͨÐÅ·½Ê½£¬Ò²ÊÇ×î¿ìµÄIPCÐÎʽ¡£Á½¸ö²»Í¬½ø³ÌA¡¢B¹²ÏíÄÚ´æµÄÒâ˼ÊÇ£¬Í¬Ò»¿éÎïÀíÄÚ´æ±»Ó³Éäµ½
½ø³ÌA¡¢B¸÷×ԵĽø³ÌµØÖ·¿Õ¼ä¡£½ø³ÌA¿ÉÒÔ¼´Ê±¿´µ½½ø³ÌB¶Ô¹²ÏíÄÚ´æÖÐÊý¾ÝµÄ¸üУ¬·´Ö®ÒàÈ»¡£ÓÉÓÚ¶à¸ö½ø³Ì¹²Ïíͬһ¿éÄÚ´æÇøÓò£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ