电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

切换虚拟终端简介VIP免费

切换虚拟终端简介_第1页
1/9
切换虚拟终端简介_第2页
2/9
切换虚拟终端简介_第3页
3/9
切换虚拟终端概述linux使用虚拟终端,这些虚拟终端对应/dev/tty1~/dev/tty8,它们由系统初始化时打开。这个过程也在键盘的中断服务程序中完成。用户用ALT+1..8或ALT+箭头来切换终端。每个虚拟终端对应一个tty_struct和一个termios结构。Termios结构存储输入输出及控制模式,一些底层参数。Tty_struct和终端的关系如同task_struct和进程的关系。一个tty被打开,就对应一个tty_stract,对终端的一切处理都围绕tty_strct进行。Termios也被tty_struct的一个指针指向。当然,tty_struct和termios结构相对独立,tty被完全关闭时,tty_struct也就不在存在,而termios依然存在。另:1与虚拟终端相对的是实终端。它对应/dev/tty0或/dev/console二者设备号均为4,0(2.0.35)系统初始时tty的初始化分早期和晚期。早期初始化支持实终端,晚期初始化支持虚拟终端。此时/dev/tty0或/dev/console对应当前终端。2伪终端正如其名,与控制台终端除了最高层的输入输出功能类似外,底层的实现大相径庭。终端切换的流程:want_console=nr;mark_bh(CONSOLE_BH);staticvoidkeyboard_interrupt(intirq,void*dev_id,structpt_regs*regs)handle_scancode(scancode);(*key_handler[type])(keysym&0xff,up_flag);k_handkey_handler[]keyboard.c键盘特殊输入的特殊处理函数数组。statick_handkey_handler[16]={Keyboard_interruptKey_handler(do_cons)Set_consleConsole_bhChange_consolecomplete_change_consoleUpdate_screendo_self,do_fn,do_spec,do_pad,do_dead,do_cons,do_cur,do_shift,do_meta,do_ascii,do_lock,do_lowercase,do_slock,do_ignore,do_ignore,do_ignore};do_cons()改变终端的最上层函数keyboard.cstaticvoiddo_cons(unsignedcharvalue,charup_flag){if(up_flag)return;set_console(value);}set_console()设置want_console为欲切换到的终端。设置console的bottomhalf标志。kbd_kern.hexterninlinevoidset_console(intnr){want_console=nr;mark_bh(CONSOLE_BH);}console_bh()console.cstaticvoidconsole_bh(void){是否要切换consoleif(want_console>=0){if(want_console!=fg_console){change_console(want_console);/*weonlychangedwhentheconsolehadalreadybeenallocated-anewconsoleisnotcreatedinaninterruptroutine*/}want_console=-1;}if(do_poke_blanked_console){/*donotunblankforaLEDchange*/do_poke_blanked_console=0;poke_blanked_console();}}change_console()tty_io.c切换终端的实际动作。voidchange_console(unsignedintnew_console){if((new_console==fg_console)||(vt_dont_switch))return;if(!vc_cons_allocated(new_console))return;/*Ifthisvtisinprocessmode,thenweneedtohandshakewith~~~~~~~~~什么模式?在此模式下,不能直接切换,要等待!*thatprocessbeforeswitching.Essentially,westorewherethat*vtwantstoswitchtoandwaitforittotelluswhenit'sdone*(viaVT_RELDISPioctl).**Wealsochecktoseeifthecontrollingprocessstillexists.控制进程*Ifitdoesn't,weresetthisvttoautomodeandcontinue.^^^^^^^^^^什么模式?*Thisisacheapwaytotrackprocesscontrol.Theworstthing*thatcanhappenis:wesendasignaltoaprocess,itdies,and*theswitchgets"lost"waitingforaresponse;hopefully,the*userwilltryagain,we'lldetecttheprocessisgone(unless*theuserwaitsjusttherightamountoftime:-)andrevertthe*vttoautocontrol.*/VT_PROCESS模式的处理。在此模式下,不能直接切换,要等待!if(vt_cons[fg_console]->vt_mode.mode==VT_PROCESS){/**Sendthesignalasprivileged-kill_proc()will*tellusiftheprocesshasgoneorsomethingelse*isawry*/if(kill_proc(vt_cons[fg_console]->vt_pid,vt_cons[fg_console]->vt_mode.relsig,1)==0){/**Itworked.Markthevttoswitchtoand*return.Theprocessneedstosendusa*VT_RELDISPioctltocompletetheswitch.*/vt_cons[fg_console]->vt_newvt=new_console;return;}/**Thecontrollingprocesshasdied,sowerevertbackto*normaloperation.Inthi...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

切换虚拟终端简介

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部