切换虚拟终端简介40484.docx





《切换虚拟终端简介40484.docx》由会员分享,可在线阅读,更多相关《切换虚拟终端简介40484.docx(17页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、切换虚拟终端概述linux使用用虚拟终端,这这些虚拟终端端对应/dev/tty1/dev/tty8,它们由系统统初始化时打打开。这个过过程也在键盘盘的中断服务务程序中完成成。用户用ALT+11.8或ALT+箭头来切换换终端。每个个虚拟终端对对应一个tty_sstructt和一个termiios结构。Termiios结构存储输输入输出及控控制模式,一一些底层参数数。Tty_sstructt 和终端的关关系如同task_struuct 和进程的关关系。一个tty被打开,就就对应一个tty_sstractt,对终端的一一切处理都围围绕tty_sstrct 进行。Termiios也被tty_sttru
2、ct的一个指针针指向。当然然,tty_sstructt 和 termmios 结构相对独独立,tty被完全关闭闭时,tty_sstructt也就不在存存在,而termiios 依然存在。另:1与虚拟终端相相对的是实终终端。它对应应/dev/tty0 或/dev/consoole 二者设备号号均为4,0(2035)系统初始时tty的初始化分分早期和晚期期。早期初始始化支持实终终端,晚期初始化支支持虚拟终端端。此时/dev/ttty0 或/dev/consoole 对应当前终终端。2 伪终端正如如其名,与控控制台终端除除了最高层的的输入输出功功能类似外,底底层的实现大大相径庭。终端切换的流程程:K
3、eyboard_interruptKey_handler(do_cons)Set_conslewant_coonsolee = nrr;mark_bbh(CONNSOLE_BH);Console_bhChange_consolecomplete_change_consoleUpdate_screenstatic void keybooard_iinterrrupt(iint irrq, vooid *ddev_idd, strruct ppt_reggs *regs)handdle_sccancodde(scaancodee);(*key_hhandleertyppe)(kkeysymm &
4、0xxff, uup_flaag);k_hand key_hhandleerkeyboarrd.c键盘特殊输入的的特殊处理函函数数组。static k_hannd keyy_handdler116 = do_sellf, doo_fn, do_sppec, ddo_padd, do_dead, do_ccons, do_cuur, doo_shifft,do_metta, doo_asciii, do_loock, ddo_lowwercasse, doo_slocck,do_ignnore, do_iggnore, do_iignoree;do_conss()改变终端的最上上层函数keybo
5、arrd.cstatic void do_coons(unnsigneed chaar vallue, cchar uup_flaag)if (upp_flagg)returrn;set_coonsolee(valuue);set_connsole()设置want_consoole 为欲切换到到的终端。设设置consoole的bottom hhalf 标志。kbd_kerrn.hextern inlinne voiid sett_conssole(iint nrr)want_cconsolle = nnr;mark_bbh(CONNSOLE_BH);consolee_bh()consolee.
6、cstatic void consoole_bhh(voidd)是否要切换coonsoleeif (waant_coonsolee = 00) if (wwant_cconsolle != fg_coonsolee) channge_coonsolee(want_consoole);/* wwe onlly chaanged when the cconsolle hadd alreeady bbeen aallocaated - a neew connsole is noot creeated iin an interrrupt routiine */want_consoole = -1;if
7、 (doo_pokee_blannked_cconsolle) /* doo not unblaank foor a LLED chhange */do_pooke_bllankedd_conssole = 0;poke_blankked_coonsolee();change_consoole()tty_io.c切换终端的实际际动作。void chhange_consoole(unnsigneed intt new_consoole)if (new_consoole = fg_cconsolle) | (vt_dont_switcch) rreturnn; if (!vc_ccons_aall
8、ocaated(nnew_coonsolee)returrn;/*If thiss vt iis in proceess moode, tthen wwe neeed to handsshake with什什么模式?在此模式下下,不能直接接切换,要等等待! * thatt proccess bbeforee swittchingg. Esssentiaally, we sttore wwhere that * vt wantss to sswitchh to aand waait foor it to teell uss whenn itss donee * (viia VT_RELDIISP
9、 iooctl). * * We also checkk to ssee iff the contrrollinng proocess stilll exissts. 控制进程 * If it dooesntt, we resett thiss vt tto autto modde andd conttinue. 什么模式? * Thiis is a cheeap waay to trackk proccess ccontrool. Thhe worrst thhing * thaat cann happeen is: we ssend aa signnal too a prrocesss,
10、it dies, and * thee swittch geets llost waitiing foor a rresponnse; hhopefuully, the * useer willl tryy agaiin, weell ddetectt the proceess iss gonee (unlless * thee userr waitts jusst thee righht amoount oof timme :-) and reverrt thee * vt to auuto coontroll. */VT_PROCCESS模式式的处理。在在此模式下,不不能直接切换换,要等待
11、!if (vtt_conssfg_cconsolle-vvt_modde.modde = VT_PRROCESSS)/* * Seend thhe siggnal aas priivilegged - kill_proc() willl * teell uss if tthe prrocesss has gone or soomethiing ellse * iss awryy */if (kkill_pproc(vvt_connsfg_consoole-vt_piid, vt_consfg_coonsolee-vtt_modee.relssig, 1) = 0)/* * IIt worrke
12、d. Mark the vvt to switcch to and * rreturnn. Thee proccess nneeds to seend uss a * VVT_RELLDISP ioctll to ccompleete thhe swiitch. */vt_cconsffg_connsole-vt_newvtt = neew_connsole;retuurn;/* * Thhe conntrollling pprocesss hass diedd, so we reevert back to * noormal operaation. In tthis ccase, welll
13、 alsoo channge baack * too KD_TTEXT mmode. Im nnot suure iff thiss is sstricttly coorrectt * buut it savess the agonyy whenn the X serrver ddies aand thhe scrreen * reemainss blannked ddue too KD_GGRAPHIICS! IIt wouuld bee nicee to ddo * thhis ouutsidee of VVT_PROOCESS but tthere is noo singgle prro
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 切换 虚拟 终端 简介 40484

限制150内