Ó²ÅÌÊý¾Ý»Ö¸´µ¼º½
RAIDÊý¾Ý»Ö¸´µ¼º½
 | ÍøÕ¾Ê×Ò³ | Êý¾Ý»Ö¸´×ÊÁÏ | Êý¾Ý»Ö¸´Èí¼þ | ×ÉѯÁôÑÔ | Êý¾Ý»Ö¸´²©¿Í | Êý¾Ý»Ö¸´ÂÛ̳ | 
Êý¾Ý»Ö¸´Èí¼þÏÂÔØ
¹«Ë¾¼ò½é Êý¾Ý»Ö¸´³É¹¦°¸Àý Êý¾Ý»Ö¸´±¨¼Û Êý¾Ý»Ö¸´Åàѵ Êý¾Ý»Ö¸´¼¼ÊõÎÄÕ Êý¾Ý»Ö¸´¿Í·þÖÐÐÄ Êý¾Ý»Ö¸´·þÎñÁªÏµ·½Ê½
ÄúÏÖÔÚµÄλÖ㺠±±ÑÇÊý¾Ý»Ö¸´¼¼ÊõÕ¾ >> Êý¾Ý»Ö¸´×ÊÁÏ >> Êý¾Ý»Ö¸´³£Ê¶ >> ÎÄÕÂÕýÎÄ
LinuxÊý¾Ý´«Êä¼¼ÊõRelayµÄÔ­Àí¼°ÊµÀý £¨2£©            ¡¾×ÖÌ壺С ´ó¡¿
LinuxÊý¾Ý´«Êä¼¼ÊõRelayµÄÔ­Àí¼°ÊµÀý £¨2£©
×÷ÕߣºÎ´Öª    ÎÄÕÂÀ´Ô´£ºÍøÂç    µã»÷Êý£º    ¸üÐÂʱ¼ä£º2009-4-20

ÃæÏòÄں˿ռäµÄ API

ÕâЩAPI½Ó¿ÚÏòλÓÚÄں˿ռäµÄÓû§ÌṩÁ˹ÜÀírelayͨµÀ¡¢Êý¾ÝдÈëµÈ¹¦ÄÜ¡£ÏÂÃæ½éÉÜÆäÖÐÖ÷ÒªµÄ²¿·Ö£¬ÍêÕûµÄAPI½Ó¿ÚÁбíÇë²Î¼ûÕâÀï¡£

¡ñrelay_open() - ´´½¨Ò»¸örelayͨµÀ£¬°üÀ¨´´½¨Ã¿¸öCPU¶ÔÓ¦µÄrelay»º³åÇø¡£

¡ñrelay_close() - ¹Ø±ÕÒ»¸örelayͨµÀ£¬°üÀ¨ÊÍ·ÅËùÓеÄrelay»º³åÇø£¬ÔÚ´Ë֮ǰ»áµ÷ÓÃrelay_switch()À´´¦ÀíÕâЩrelay»º³åÇøÒÔ±£Ö¤ÒѶÁÈ¡µ«ÊÇδÂúµÄÊý¾Ý²»»á¶ªÊ§

¡ñrelay_write() - ½«Êý¾ÝдÈëµ½µ±Ç°CPU¶ÔÓ¦µÄrelay»º³åÇøÄÚ¡£ÓÉÓÚËüʹÓÃÁËlocal_irqsave()±£»¤£¬Òò´ËÒ²¿ÉÒÔÔÚÖжÏÉÏÏÂÎÄÖÐʹÓá£

¡ñrelay_reserve() - ÔÚrelayͨµÀÖб£ÁôÒ»¿éÁ¬ÐøµÄÇøÓòÀ´Áô¸øδÀ´µÄдÈë²Ù×÷¡£Õâͨ³£ÓÃÓÚÄÇЩϣÍûÖ±½ÓдÈëµ½relay»º³åÇøµÄÓû§¡£¿¼Âǵ½ÐÔÄÜ»òÕßÆäËüÒòËØ£¬ÕâЩÓû§²»Ï£ÍûÏÈ°ÑÊý¾Ýдµ½Ò»¸öÁÙʱ»º³åÇøÖУ¬È»ºóÔÙͨ¹ýrelay_write()½øÐÐдÈë¡£

RelayµÄÀý×Ó

ÎÒÃÇÓÃÒ»¸ö×î¼òµ¥µÄÀý×ÓÀ´½éÉÜÔõôʹÓÃRelay¡£Õâ¸öÀý×ÓÓÉÁ½²¿·Ö×é³É£ºÒ»²¿·ÖÊÇλÓÚÄں˿ռ佫Êý¾ÝдÈërelayÎļþµÄ³ÌÐò£¬Ê¹ÓÃʱÐèÒª×÷Ϊһ¸öÄÚºËÄ£¿é±»¼ÓÔØ£»ÁíÒ»²¿·ÖÊÇλÓÚÓû§¿Õ¼ä´ÓrelayÎļþÖжÁÈ¡Êý¾ÝµÄ³ÌÐò£¬Ê¹ÓÃʱ×÷ΪÆÕͨÓû§Ì¬³ÌÐòÔËÐС£

Äں˿ռäµÄ³ÌÐòÖ÷Òª²Ù×÷ÊÇ£º

¼ÓÔØÄ£¿éʱ£¬´ò¿ªÒ»¸örelayͨµÀ£¬²¢ÇÒÍù´ò¿ªµÄrelayͨµÀÖÐдÈëÏûÏ¢£»

жÔØÄ£¿éʱ£¬¹Ø±ÕrelayͨµÀ¡£

³ÌÐòÄÚÈÝ£º

 

 


/*
 * hello-mod.c
 * a kernel-space client example of relayfs filesystem
 */
#include
#include
static struct rchan *hello_rchan;
int init_module(void)
{
        const char *msg="Hello world\n";
        hello_rchan = relay_open("cpu", NULL, 8192, 2, NULL);
        if(!hello_rchan){
                printk("relay_open() failed.\n");
                return -ENOMEM;
        }
        relay_write(hello_rchan, msg, strlen(msg));
        return 0;
}
void cleanup_module(void)
{
        if(hello_rchan) {
                relay_close(hello_rchan);
                hello_rchan = NULL;
        }
        return;
}
MODULE_LICENSE ("GPL");
MODULE_DESCRIPTION ("Simple example of Relay");


 


Óû§¿Õ¼äµÄº¯ÊýÖ÷Òª²Ù×÷ÊÇ£º

¡ñÈç¹ûrelayfsÎļþϵͳ»¹Ã»Óб»mount£¬Ôò½«Æämountµ½Ä¿Â¼/mnt/relayÉÏ£»

¡ñ±éÀúÿһ¸öCPU¶ÔÓ¦µÄ»º³åÎļþ£»

¡ñ´ò¿ªÎļþ£»

¡ñ¶ÁÈ¡ËùÓÐÎļþÄÚÈÝ£»

¡ñ¹Ø±ÕÎļþ£»

¡ñ×îºó£¬umountµôrelayÎļþϵͳ¡£

³ÌÐòÄÚÈÝ£º

 

/*
 * audience.c
 * a user-space client example of relayfs filesystem
 */
#include
#include
#include
#include
#include
#include
#include
#define MAX_BUFLEN 256
const char filename_base[]="/mnt/relay/cpu";
// implement your own get_cputotal() before compilation
static int get_cputotal(void);
int main(void)
{
        char filename[128]={0};

ÎÄÕ¼È룺a    ÔðÈα༭£ºa 
  • ÉÏһƪÎÄÕ£º

  • ÏÂһƪÎÄÕ£º
  • ¡¾·¢±íÆÀÂÛ¡¿¡¾¼ÓÈëÊղء¿¡¾¸æËߺÃÓÑ¡¿¡¾´òÓ¡´ËÎÄ¡¿¡¾¹Ø±Õ´°¿Ú¡¿
    ÍøÓÑÆÀÂÛ£º£¨Ö»ÏÔʾ×îÐÂ10Ìõ¡£ÆÀÂÛÄÚÈÝÖ»´ú±íÍøÓѹ۵㣬Óë±¾Õ¾Á¢³¡Î޹أ¡£©
    ¹ØÓÚÎÒÃÇ | RAIDÊý¾Ý»Ö¸´ | ÓÑÇéÁ´½Ó | RSSÉú³É | XMLÉú³É | ÎÄÕÂHTMLµØͼ | ÏÂÔØHTMLµØͼ

    °æȨËùÓÐ ±±ÑÇÊý¾Ý»Ö¸´ÖÐÐÄ
    È«¹úͳһ¿Í·þµç»°:4006-505-808
    ±±¾©Êк£µíÇøÓÀ·á»ùµØ·á»ÛÖз7ºÅвÄÁÏ´´Òµ´óÏÃB×ù205ÊÒ
    ¾©ICP±¸05011939
    ¬b;