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

Linux TTY Çý¶¯

Ïà¹ØÁ´½Ó£º
http://blog.csdn.net/dongliqiang2006/archive/2009/09/05/4523563.aspx
 
×Ö·ûÉ豸
1£¬×Ö·ûÉ豸²ã
ÔÚLinuxÖÐÊÇ×÷Ϊһ¸öÎļþÀ´³öÏֵģ¬ËùÓжÔ×Ö·ûÉ豸µÄ²Ù×÷¶¼ÊÇͨ¹ýfile_operations½Ó¿ÚÀ´½øÐеģº
struct cdev {
struct kobject kobj;
struct module *owner;
const struct file_operations *ops;
struct list_head list;
dev_t dev;
unsigned int count;
};
void cdev_init(struct cdev *, const struct file_operations *);
Õâ¸öº¯Êý³õʼ»¯Ö¸¶¨µÄcdev½á¹¹£ºÆäÖÐ×îÖØÒªµÄ²½Öè¾ÍÊÇÉèÖÃops
static struct kobj_map *cdev_map;
int cdev_add(struct cdev *, dev_t, unsigned);
cdev_mapÓ¦¸ÃÊÇËùÓÐcdevµÄÒ»¸ö¼¯ºÏ£¬cdev_addº¯Êý¸ºÔð°ÑÖ¸¶¨µÄcdev¼ÓÈëµ½Õâ¸ö¼¯ºÏÖУ¬ÒÔ±ãÒÔºóµÄ²éѯ
2£¬line_discipline²ã£¨Ïß·¹æ³Ì£©
ÕâÒ»²ãͨ¹ýtty_structµÄldisc³ÉԱʵÏÖ²»Í¬µÄÏß·¹æ³Ì£¬¸ºÔðÁ¬½ÓÉϲãµÄÎļþ²Ù×÷ºÍϲãµÄtty²Ù×÷£¬²¢ÇÒ¼ÓÈëÏß·¹æ³Ì²ãµÄ´¦ÀíÂß¼­£»ÀýÈçtty_writeÊǵ¼³ö¸øÉϲãÎļþµÄд²Ù×÷º¯Êý£¬Õâ¸öº¯ÊýÒ»°ã»áµ÷ÓÃÏß·¹æ³Ì³ÉÔ±ldiscµÄwriteº¯Êý£¬ÔÙÓɺóÕßµ÷ÓÃttyÇý¶¯£¨ÀýÈçn_ttyÖоÍÊǵ÷ÓÃwrite_chanµÄ£©£¬È«²¿µÄµ¼³öº¯ÊýÈçÏ£º
static const struct file_operations tty_fops = {
.llseek = no_llseek,
.read = tty_read,
.write = tty_write,
.poll = tty_poll,
.ioctl = tty_ioctl,
.open = tty_open,//tty_openÊǸö±È½ÏÖØÒªµÄº¯Êý£¬ÒòΪÕâ¸öº¯Êý»áµ÷ÓÃinit_dev£¬ºóÕß»á³õʼ»¯ÖØÒªµÄ½á¹¹tty_struct£¬²¢ÇÒÉèÖÃfileµÄprivate_dataΪtty_structʵÀý
.release = tty_release,
.fasync = tty_fasync,
};
3£¬tty²ã
½éÓÚÏß·¹æ³Ì²ãºÍÓ²¼þÇý¶¯Ö®¼ä£¬ÏòÉÏΪÏß·¹æ³ÌÌṩ½Ó¿Ú£¨tty_driver£©£¬ÏòÏÂÔòÌṩӲ¼þ¹ÜÀí£¨ÀýÈçtty_operations.start£©£»Ð´²Ù×÷£¨ÀýÈçtty_operations.write£©ÏòÏß·¹æ³Ì²ãÌṩ£¨ÒòΪЩ²Ù×÷Ò»°ã¶¼ÊÇÏß·¹æ³Ì²ãÖ÷¶¯·¢Æ𣬶ø¶Á²Ù×÷ÔòÊÇÓ²¼þ²ãÖ÷¶¯·¢Æ𣩣¬ËùÓеÄд²Ù×÷Êý¾Ý¶¼ÊǽøÈëµ½tty²ãµÄÒ»¸öcircle bufferÖУ¬tty²ã»áÔÚÊʵ±µÄʱºòµ÷ÓÃÓ²¼þ²ãµÄд²Ù×÷À´Êä³öÕâЩÊý¾Ý£»¶ø¶Á²Ù×÷£¨ÀýÈçtty_insert_flip_string£©ÔòÏòÓ²¼þ²ãÌṩ£¬ËùÓжÁÈëÊý¾Ý¶¼´æ·ÅÔÚttyµÄread bufferÖУ¬ÔÚÊʵ±µÄʱºòread bufferÖеÄÊý¾Ý»áͨ¹ýflush_to_ldiscº¯ÊýÍÆË͵½Ïß·¹æ³Ì²ã£¨¾ßÌåµÄÓ²¼þÇý¶¯ÔÚÍê³ÉÊý¾Ý½ÓÊÕºó£¬ÐèÒªµ÷ÓÃtty_flip_buffer_pushº¯ÊýÀ´ÍÆËÍÊý¾Ý£©
×¢£ºtty_bufhead½á¹¹ÖÐÓÐÒ»¸öwork_struct½á¹¹£¬Õâ¸ö½á¹¹¸ºÔð


Ïà¹ØÎĵµ£º

linuxϵͳѧϰС½á£¨1£©

´ÇÖ°Ö®ºóһֱûÓÐÕÒ¹¤×÷£¬²»ÊÇÕÒ²»µ½£¬Ö»ÊDz»ÂúÒâ´ýÓöÎÊÌâ¡£ÔÚ´òÁËÒ»¸öÔÂÓÎÏ·Ö®ºóÓÚ×òÌ쿪ʼ½Ó´¥linuxϵͳ¡£
ÎÒÓõÄÊÇubuntu£¬¾ßÌå°²×°µÄʱºòûÓÐ×ÐϸµÄ·ÖÇø£¬Ö÷ÒªÊÇ/boot·ÖÁË256M£»¹ÒÔص㣨swap)·ÖÁË1GB£»/·ÖÁËËùÓеġ£
ÔÚ°²×°Ö®ºóÓöµ½µÄµÚÒ»¸öÎÊÌâÊÇÒÔÇ°windowsϵÄrar²»Äܽâѹ£¬ËæºóÕÒÁËһЩÍøÂçÏà¹ØµÄÎļþ¡£¾ßÌå·½·¨Ê ......

LinuxÈçºÎ×ß½øѧУ´óÃÅ£¿

     Èç½ñ£¬ÖÐСѧÀïÃ漸ºõÈ«ÊÇXPѧÉú£¬±Ä±ÄÌøÌø£¬Linux£¨¼·£©½øѧУ¼¸ºõÎÞÃÅ¡£ÄÇô£¬ÎÒÃǸÃÔõô°ìÄØ£¿ÄÜ·ñ²»ÆƶøÁ¢£¿
      ×òÌìÉÏÎ磬ÎÒÈ¥±±¾©ÊÐÓйز¿ÃżûһλÀÏÅóÓÑ£¬Ïë̸̸Õâ¸öÎÊÌâ¡£µ±Ç°£¬ÔÚÎÒ¹úÖÐСѧ£¬Linux²»Èë½Ìѧ´ó¸Ù£¬µ«ÊÇ£¬×÷Ϊ¿ÎÍâ»î¶¯ÄÚÈÝ»¹ÊÇ¿ÉÒԵġ£Linux½ ......

LINUX¾²Ì¬Á´½Ó¿â˳ÐòÎÊÌâ

×òÌìÔÚ±àдһ¸ö³ÌÐòµÄʱºò·¢ÏÖÐèÒªÁ´½ÓµÄ¾²Ì¬¿â¶¼È·¶¨´æÔÚ£¬Ö¸¶¨µÄ·¾¶Ò²Ã»ÓÐÎÊÌ⣬µ«ÊDZàÒë×ÜÊdzöÏÖÁ´½ÓÎÊÌ⣬ÕÒ²»µ½ÊµÏÖ£¬²Å·¢ÏÖÔ­À´Èç¹ûͬʱÁ´½Ó¶à¸ö¾²Ì¬¿â£¬²¢ÇÒÈç¹ûÕâЩ¾²Ì¬¿âÖ®¼ä´æÔÚÏ໥ÒÀÀµ¹ØϵµÄ»°£¬ÐèÒª°´Ò»¶¨µÄ˳Ðò½øÐÐÁ´½Ó£¬ÀýÈ磺Èç¹ûlibb.aÒÀÀµliba.a£¬ÄÇô±àÒë²ÎÊýÓ¦¸Ãд³ÉÕâÑù£º -lb -la ......

Linux 2.6ÄÚºËϱàÒë¿ÉÒÔ¼ÓÔصÄÄÚºËÄ£¿é

1. Ôھɵİ汾Ï£¨Èçlinux 2.4£©linuxÄÚºËÄ£¿éµÄ±àÒëÖ»ÐèÒªÓÐÄں˵ÄÍ·Îļþ¾ÍÐÐÁË£¬¾Í¿ÉÒÔͨ¹ýºÍ±àÒëÆäËû³ÌÐòÒ»ÑùµÄ·½·¨±àÒë³Éfilename.oÎļþ£¬Õâ¸ö.oÎļþÊÇÖ±½Ó ¿ÉÒÔ¼ÓÔصÀÄÚºËÖеģ¬¼ÓÔØÖ®ºó¾Í¿ÉÒÔÓÃÁË¡£È»¶øÔÚ2.6ϾͽØÈ»²»Í¬ÁË£¬ÔÚlinux 2.6ÏÂÄں˵ıàÒëÒªÓÐϵͳÄÚºËÊ÷µÄÖ§³Ö£¬ÏÂÃæ½éÉÜÒ»ÏÂÕâ¸ö“ÄÚºËÊ÷”ÊÇÈç ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ