Install Chinese fonts support for Unbuntu
- [Ubuntu] - Linux for human beings
- 软件仓库分类:universe
- 安装包文件名:xfonts-wqy
- 安装方法:sudo apt-get install xfonts-wqy
- 对应WQY版本:0.6.0
- 维护人:Carlos Liu (carlosliu # users_sourceforge_net)
+++++仿佛轻云应笑我--相携水岸弄朝霞--此生只为听天籁--坐拥书城看落花+++++
FvwmButtons, also known as GoodStuff, is sometimes overlooked by new
fvwm users, despite being the most powerful software for creating
desktop panels available today.
I've written this guide to introduce FvwmButtons to new users, and
take anyone interested step by step through creating a simple panel.
Hopefully this will help get you started a little quicker than the man
page alone :).
This is the panel I am going to create.
http://dev.gentoo.org/~taviso/goodstuff1.png
It's very simple, has a set of nine buttons that can be bound to
applications or window controls. It also has an xclock along the top.
Of course, FvwmButtons has many, many features I havn't mentioned
here, but this should be enough to get started :)
Step 1: Planning
Fvwm uses a flat text based configuration, which is not an intuitive
method for designing user interfaces. The solution is to use a
graphics package to create a template to work from. You can use any
package you like, The GIMP, xpaint, dia, or even xfig.
Here is a screenshot of me planning this panel in dia..
http://dev.gentoo.org/~taviso/goodstuff2.png
As you can see I have an outline and the approximate layout of the
buttons all plotted in dia. Don't worry about this template being
perfect, we are just going to use it to estimate the dimensions in the
next step.
Step 2: Dimensions
Now that you have a template to work from, you can calculate what the
minimum grid size you will need in order to contain your buttons.
This is a lot simpler than it sounds, we just need to know how many
rows and columns we should split our panel into. Each button can take
up any whole number of grid squares, so we just have to make sure we
have enough.
http://dev.gentoo.org/~taviso/goodstuff3.png
As you can see, we need a minimum grid of 7 rows and 3 columns so that
each button occupies a whole number of grid squares. The top button
requires one row and 3 columns, the other buttons need 2 rows and 1
columns.
Step 3: Create Buttons
Now that we have the dimensions needed, we can make an absolute
minimum FvwmButtons configuration to test the dimensions.
You can tweak the button geometries and grid size until everything looks right.
代码:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
As you can see, each configuration line for our panel starts with an
asterisk, then the panel alias. Lines that dont use brackets are
settings, lines that do are button definitons. The buttons defined
here only have one setting, how many rows and columns they need.
You can enter this in your fvwm2rc and restart, or paste it into an
FvwmConsole. I've used DestroyModuleConfig so that if you paste the
configuration into FvwmConsole twice, fvwm knows that you are not
trying to continue the same configuration.
Now lets try starting the panel, enter the following into your FvwmConsole
代码:
Module FvwmButtons -g 178x207 LaunchTime
The -g specifies the Geometry, it tells FvwmButtons how big you want
the panel to be (and also where you want it to appear).
Hopefully, you should see a window like this
http://dev.gentoo.org/~taviso/goodstuff4.png
Not very exciting yet, but don't worry, move on to the next step where
we will configure the buttons and add the bindings.
Step 4: Fill in the blanks
Swallowing is what FvwmButtons calls Reparenting, it basically means
any application window can be used as a button on your panel. So lets
use this concept to swallow an xclock into our new panel.
First lets find a command line for xclock that looks suitable for our panel.
代码:
xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11'
-strftime '%a, %d %b %Y %H:%M'
This is what I have used. Now lets tell our panel how to start the clock.
代码:
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg
white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
The first setting is the Rows and Columns we want, then the Swallow
command. the next argument is the name of the window FvwmButtons
should look out for, followed by the Fvwm command needed to start the
window.
Here is our new Panel:
代码:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg
white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
Enter the configuration into your FvwmConsole, and start the panel to
make sure everything has worked, hopefully you will see a window like
this:
http://dev.gentoo.org/~taviso/goodstuff5.png
Now for the next button, Let's make it a launcher for The GIMP.
代码:
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png)
As you can see, we have the dimensions, a Title and an Icon. All we
need now is to define an Action. Actions are responses to Clicks, so
lets say we want the first mouse button to start the gimp.
代码:
Action(Mouse 1) `Exec gimp`
Lets enter this into the button definition.
代码:
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png,
Action(Mouse 1) `Exec gimp`)
The configuration should now look like this:
代码:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg
white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png,
Action(Mouse 1) `Exec gimp`)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
Test out the panel, if everything looks okay fill in the rest of the buttons.
代码:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1, Center, Swallow "xclock" `Exec xclock -bg '#31658c'
-fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png,
Action(Mouse 1) `Exec gimp`)
*LaunchTime: (1x2, Title "xmag", Icon telescope.png, Action(Mouse 1)
`Exec xmag`)
*LaunchTime: (1x2, Title "xcalc", Icon calculator.png, Action(Mouse 1)
`Exec xcalc`)
*LaunchTime: (1x2, Title "mozilla", Icon browser_ship-wheel.png,
Action(Mouse 1) `Exec mozilla`)
*LaunchTime: (1x2, Title "run", Icon gears.png, Action(Mouse 1) `Exec gmrun`)
*LaunchTime: (1x2, Title "gvim", Icon gvim.png, Action(Mouse 1) `Exec gvim`)
*LaunchTime: (1x2, Title "move", Icon hardware_mouse.png, Action(Mouse
1) `Pick Move`)
*LaunchTime: (1x2, Title "close", Icon bomb.png, Action(Mouse 1) `Pick Close`)
*LaunchTime: (1x2, Title "shade", Icon window.png, Action(Mouse 1)
`Pick WindowShade True`)
Start the panel and you should see something like:
http://dev.gentoo.org/~taviso/goodstuff6.png
Step 5: Finalise Panel
Test all your buttons, make sure everything is working, Hopefully it
is and you can setup Colorsets, Fonts, Frames, Padding and any other
setting you want!
代码:
Colorset 30 fg black, bg #c6c3c6, RootTransparent buffer, Tint #efebef 65
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: Font "xft:Bitstream Vera Sans Mono:style=Roman:size=8"
*LaunchTime: Colorset 30
*LaunchTime: Frame 1
*LaunchTime: (3x1, Center, Swallow "xclock" `Exec xclock -bg '#31658c'
-fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png,
Action(Mouse 1) `Exec gimp`)
*LaunchTime: (1x2, Title "xmag", Icon telescope.png, Action(Mouse 1)
`Exec xmag`)
*LaunchTime: (1x2, Title "xcalc", Icon calculator.png, Action(Mouse 1)
`Exec xcalc`)
*LaunchTime: (1x2, Title "mozilla", Icon browser_ship-wheel.png,
Action(Mouse 1) `Exec mozilla`)
*LaunchTime: (1x2, Title "run", Icon gears.png, Action(Mouse 1) `Exec gmrun`)
*LaunchTime: (1x2, Title "gvim", Icon gvim.png, Action(Mouse 1) `Exec
"gvim" gvim`)
*LaunchTime: (1x2, Title "move", Icon hardware_mouse.png, Action(Mouse
1) `Pick Move`)
*LaunchTime: (1x2, Title "close", Icon bomb.png, Action(Mouse 1) `Pick Close`)
*LaunchTime: (1x2, Title "shade", Icon window.png, Action(Mouse 1)
`Pick WindowShade True`)
Try out the new Panel!
代码:
Module FvwmButtons -g 178x207 LaunchTime
Hopefully you should see something similar to this:
http://dev.gentoo.org/~taviso/goodstuff7.png
Now all you have to do is set any Style options you want, and decide
how to start your panel. Did you notice the extra argument to Exec on
the gvim button? Try pressing it, notice the button will stay down
until a window called gvim appears! You can do this for all the
buttons, if you like it.
Maybe you would like LaunchTime to always be visible?
代码:
Style LaunchTime StaysOnTop
And lets start it everytime we login
代码:
AddToFunc StartFunction
+ I Module FvwmButtons -g 178x207 LaunchTime
And finally, lets add it to a menu:
代码:
AddToMenu MyRootMenu
+ "Start LaunchTime" Module FvwmButtons -g 178x207 LaunchTime
edit: 21/05/2004 changed wording of planning section, using dia instead.
内核洋文用 kernel,我刚才翻了一下词典,kernel 中文意思是内核、核心、中心、精髓的意思;也是果仁、果核的意思。从字面理解,kernel 是一事物的中心,植物的果实最重要的也是果仁和果核;:) 由此我们可以推断内核是操作系统的中心。
我们知道Linus Torvalds 开发了Linux ,其实他开发的就是内核,按内核官方主页的理解,这个内核就是Linux ;其它的扩展和应用都是围绕内核而展开的。所有Linux应用程序都会和内核发生直接或者间接的接触;比如硬件需要内核支持,网络的通信也需要内核支持; 文件系统更需要内核支持... ...
直言我的能力的不行,如果您想了解和学习解操作系统,我写的教程只是初级应用,理论性的东西不是一言两语能说的清楚的,更不是应用者能说的清楚的。
二、为什么需要编译内核和管理内核
硬件是需要内核支持才行,有些硬件的支持没有被编入内核,这也需要我们重编内核;内核的包含的不仅仅是设备的驱动,还有其它的内容,比如网络协议的支持, 防火墙的支持... ... 比如iptables的实现,有些功能是需要内核支持的,如果内核与iptables相关的内容没有被编入,iptables 相关的功能就无法实现;
三、内核编译方法
请参考:《编译内核操作流程 ──为新手指南》
四、管理内核模块的相关命令
1、lsmod 列加以挂载的内核模块;
lsmod 是列出目前系统中已加载的模块的名称及大小等;另外我们还可以查看 /proc/modules ,我们一样可以知道系统已经加载的模块;
[root@localhost beinan]# lsmod
2、modinfo 查看模块信息;
modinfo 可以查看模块的信息,通过查看模块信息来判定这个模块的用途;
[root@localhost beinan]# moinfo 模块名
举例:
[root@localhost beinan]# modinfo ne2k-pci
filename: /lib/modules/2.6.11-1.1369_FC4/kernel/drivers/net/ne2k-pci.ko
author: Donald Becker / Paul Gortmaker
description: PCI NE2000 clone driver
license: GPL
parmtype: debug:int
parmtype: options:array of int
parmtype: full_duplex:array of int
parm: debug:debug level (1-2)
parm: options:Bit 5: full duplex
parm: full_duplex:full duplex setting(s) (1)
vermagic: 2.6.11-1.1369_FC4 686 REGPARM 4KSTACKS gcc-4.0
depends: 8390
alias: pci:v000010ECd00008029sv*sd*bc*sc*i*
alias: pci:v00001050d00000940sv*sd*bc*sc*i*
alias: pci:v000011F6d00001401sv*sd*bc*sc*i*
alias: pci:v00008E2Ed00003000sv*sd*bc*sc*i*
alias: pci:v00004A14d00005000sv*sd*bc*sc*i*
alias: pci:v00001106d00000926sv*sd*bc*sc*i*
alias: pci:v000010BDd00000E34sv*sd*bc*sc*i*
alias: pci:v00001050d00005A5Asv*sd*bc*sc*i*
alias: pci:v000012C3d00000058sv*sd*bc*sc*i*
alias: pci:v000012C3d00005598sv*sd*bc*sc*i*
alias: pci:v00008C4Ad00001980sv*sd*bc*sc*i*
srcversion: 6ACE95F441CD26DF9DC31C2
上面的例子是我们查看 ne2k-pci 这个模块的信息,通过查看,我们知道ne2k-pci 模块是8029网卡(PCI NE2000 clone driver)的驱动;模块是位于 /lib/modules/2.6.11-1.1369_FC4/kernel/drivers/net/ 中ne2k-pci.ko
我们现在常用的网卡也有8139的,8139网卡所用的驱动是 8139too ;查查看?
[root@localhost beinan]# modinfo 8139too
我们再查查vfat 和ntfs 的模块信息;
[root@localhost beinan]# modinfo vfat
[root@localhost beinan]# modinfo ntfs
自己尝试一下;
注意: 模块名是不能带有后缀的,我们通过modprobe -l 所看到的模块,都是带有.ko 或.o后缀;
3、modprobe 挂载新模块以及新模块相依赖的模块
modprobe 我们常用的功能就是挂载模块,在挂载某个内核模块的同时,这个模块所依赖的模块也被同时挂载;当然modprobe 也有列出内核所有模块,还有移除模块的功能;下在我们举个例子说一说咱们常用的功能和参数;
modprobe [-v] [-V] [-C config-file] [-n] [-i] [-q] [-o ] [parameters...]
modprobe -r [-n] [-i] [-v] ...
modprobe -l -t [ -a ...]
上面是modprobe 的用法,具体更为详细的帮助,我们可以查看 man modprobe ;
[root@localhost beinan]# modprobe -c
modprobe -c 可以查看modules 的配置文件,比如模块的别名是什么等;
[root@localhost beinan]# modprobe -l
modprobe -l 是列出内核中所有的模块,包括已挂载和未挂载的;通过modprobe -l ,我们能查看到我们所需要的模块,然后根据我们的需要来挂载;其实modprobe -l 读取的模块列表就位于 /lib/modules/'uname -r' 目录中;其中uname -r 是内核的版本;
[root@localhost beinan]# uname -r
2.6.11-1.1369_FC4
[root@localhost beinan]# ls /lib/modules/2.6.11-1.1369_FC4/
通过上面的命令,自己试试看?
[root@localhost beinan]# modprobe 模块名 注:挂载一个模块;
举例:
[root@localhost beinan]# modprobe ne2k-pci 注:挂载 ne2k-pci 模块;
[root@localhost beinan]# modprobe vfat 注:挂载vfat 模块
[root@localhost beinan]# modprobe ntfs 注:挂载ntfs 模块
[root@localhost beinan]# lsmod 注:列出已挂载模块, 我们会看到ne2k-pci ,vfat ,ntfs的模块 ;
注意: 模块名是不能带有后缀的,我们通过modprobe -l 所看到的模块,都是带有.ko 或.o后缀;
[root@localhost beinan]# modprobe -r 模块名 注:移除已加载的模块,和rmmod 功能相同;
注意: 模块名是不能带有后缀的,我们通过modprobe -l 所看到的模块,都是带有.ko 或.o后缀;
[root@localhost beinan]# modprobe -r 模块名
举例:
[root@localhost beinan]# modprobe -r ne2k-pci
就说这么多吧,更为详细的还是用 man modprobe 来查看和尝试;
4、rmmod 移除已挂载模块;
命令格式:
rmmod 模块名
注意: 模块名是不能带有后缀的,我们通过modprobe -l 所看到的模块,都是带有.ko 或.o后缀;
举例:
[root@localhost beinan]# rmmod vfat 注:移除已挂载的模块vfat
5、depmod 创建模块依赖关系的列表
这个模块管理工具是创建模块依赖关系的列表,有几个参数我们注意一下就行了,目前的的Linux 发行版所用的内核是2.6x版本,是自动解决依赖关系,所以这个命令知道就行了;模块之前也有依赖关系,比如我们想驱动USB 移动硬盘,目前有两种驱动,一种是udev ,在内核中有,但目前不太稳定;另一种办法是用usb-storage驱动,而usb-storage 依赖的模块是scsi 模块,所以我们要用usb-storage 的模块,也得把scsi 编译安装;
再举个例子:sata的硬盘,在Linux中的设备表示的是/dev/sd* ,比如 /dev/sda,/dev/sdb 等... 系统要驱动 sata硬盘,则需要把sata在内核中选中,或编译成模块,或内置于内核之中,在此同时,还需要在内核中选中ide ,scsi 的支持等;
depmod 工具的洋文原意:depmod ― program to generate modules.dep and map files.(我译的:为modules.dep 文件或映射文件创建依赖关系)
[root@localhost beinan]# depmod -a 注:为所有列在/etc/modprobe.conf 或/etc/modules.conf 中的所有模块创建依赖关系,并且写入到modules.dep文件;
[root@localhost beinan]# depmod -e 注:列出已挂载但不可用的模块;
[root@localhost beinan]# depmod -n 注:列出所有模块的依赖关系,但仅仅是输出出来 (Write the dependency file on stdout only)
注:modules.dep 位于 /lib/modules/内核版本 目录
比如 Fedora Core 4.0 中,系统默认的内核:
[root@localhost beinan]# ls /lib/modules/2.6.11-1.1369_FC4/modules.dep
/lib/modules/2.6.11-1.1369_FC4/modules.dep
6、insmod 挂载模块;
insmod 这个工具,和modprobe 有点类似,但功能上没有modprobe 强,modprobe 在挂载模块是不用指定模块文件的路径,也不用带文件的后缀.o 或.ko ;而insmod 需要的是模块的所在目录的绝对路径,并且一定要带有模块文件名后缀的(modulefile.o 或modulesfile.ko );
对于这个工具,我们只是介绍一下, 并不推荐使用。因为模块有依赖关系,对于新手来说,可能不知道这个模块依赖和哪个模块依赖;
举例:
[root@localhost beinan]# insmod /lib/modules/2.6.11-1.1369_FC4/kernel/drivers/net/tg3.ko
我们要到 /lib/modules/内核版本 uname -r 的命令输出/kernel/drivers 中找相对应的模块才行,要有绝对路径,而且必须要用到文件名的全称,不能把文件名的后缀省略;
五、与内核模块加载相关的配置文件;
1、模块的配置文件 modules.conf 或 modprobe.conf
内核模块的开机自动挂载模块一般是位于一个配置文件,一般的Linux发行版本都有 /etc/modules.conf 或 /etc/modprobe.conf 。比如Fedora Core 4.0 内核模块开机自动加载文件是 /etc/modprobe.conf ;在这个文件中,一般是写入模块的加载命令或模块的别名的定义等;比如我们在modules.conf 中可能会发行类似的一行 ;
alias eth0 8139too
而8029的网卡应该是
alias eth0 ne2k-pci
这样系统启动的时候,首先会modprobe 8139too ,然后再为8139too 指定别名为 eth0,然后我们在登录的时候,用 ifconfig 就会查看到网卡的IP 等情况,当然您得为网卡设置IP 才行;
一般的情况下,modproe.conf 或modules.conf的内容 是我们用相应的硬件配置工具而生成的;如果您的硬件驱动是没有被内核支持,您自己到硬件的厂商下载而来的驱动。一般的情况下都有安装和帮助文件。他们的驱 动在配置时,他会写入硬件的支持到modules.conf 或modprobe.conf 文件中。
再比如我们的声卡在modules.conf 或modprobe.conf 中也有相应的内容,这是由alsaconf 配置工具生成的,明白了吧;同理网卡在modprobe.conf 或modules.conf中的内容也是由网卡的配置工具而来的。
有些硬件是以内核模块的方式驱动的,模块一旦加载上就能用,也没有什么配置工具,比如vfat 和ntfs 的支持;如果是硬件驱动不以模块的方式支持,而是直接编入内核,也不会用在modprobe.conf 或 modules.conf 中加入什么内容;
如果您有些模块不能开机加载,您想让一些模块加机自动加载,就可以把modprobe 模块 直接写入配置文件;
2、内核模块其它配置文件
内核模块的其它配置文件还是需要了解的,比如 /lib/modules/内核版本目录下的几个文件;了解一下就行;比如:
[root@localhost beinan]# uname -r
2.6.11-1.1369_FC4
[root@localhost beinan]# ls /lib/modules/2.6.11-1.1369_FC4/
build misc modules.ccwmap modules.ieee1394map modules.isapnpmap modules.symbols source
kernel modules.alias modules.dep modules.inputmap modules.pcimap modules.usbmap
六、硬件驱动在系统中的目录;
硬件驱动在内核中以模块支持的目录;
硬件驱动是必须由内核支持的,无论是我们自己安装驱动,还是内核自带的驱动都是如此。硬件驱动如果是以内核模块支持的,驱动目录位于: /lib/modules/内核版本/kernel/目录 或 /lib/modules/内核版本/kernel/drivers 目录中;
[root@localhost beinan]# uname -r
2.6.11-1.1369_FC4
[root@localhost beinan]# ls /lib/modules/2.6.11-1.1369_FC4/kernel
arch crypto drivers fs lib net sound
注:只有驱动在内核中以模块的方法支持,驱动才位于 /lib/modules/相应的目录;如果是直接置入内核的,不会出现在/lib/modules驱动相关的目录;
七、自己编译驱动的办法;
如果是硬件厂商或者开源社区提供的驱动(没有集成在内核源码中的),编译驱动过程一般是./configure ;make;make install ,有时程序不提供./configure ,我们可以make或make install ,或者执行make;make install ;如果不能make install ,则需要我们自己复制.o或者.ko文件到 /lib/modules/内核版本/kernel/目录 或 /lib/modules/内核版本/kernel/drivers 目录中相应的驱动目录;
这个还是自己尝试吧,说也说不清楚,遇到问题后就知道怎么弄了;具体的还是驱动的REAME和INSTALL为准;
现在大多驱动都是在编译安装时,都自动复制.o或.ko 文件到内核模块目录,大多不用我们自己动手复制过去。如果您尝试编译安装声卡驱动 alsa-drivers 就会明白我所说的意思;
如果是我们通过重编内核来解决驱动问题,可以查看/usr/src/目录中的内核源码目录中的 Documentation 的REAME ;所有的帮助文件都在那里;
后记:
内核编译对新手来说是有点困难,我写过类似的文档也有好多篇,但是不是新手弟兄从中能学到点什么,我不太知道;毕竟我写的文档在内核文件告诉一些基本的流程和注意的事项;内核的配置只有多实践才能学会,在配置内核时,要多看看帮助;
内核模块管理方面我在本文中已经写了一些,大体上就这些,如果想要知道更为详细的,只能是自己看man 和--help了,我写文档也无非是查看这些东西,然后实践再写给大家;我能写出来,我想您的能力并不一定比我差,应该超出我才对;
原文:[http://www.xxlinux.com/linux/article/development/kernel/20051228/775_2.html ]
Linux内核主要由五个子系统组成:进程调度,内存管理,虚拟文件系统,网络接口,进程间通信。
1. 进程调度(SCHED):控制进程对CPU的访问。当需要选择下一个进程运行时,由调度程序选择最值得运行的进程。可运行进程实际上是仅等待CPU资源的 进程,如果某个进程在等待其它资源,则该进程是不可运行进程。Linux使用了比较简单的基于优先级的进程调度算法选择新的进程。
2. 内存管理(MM)允许多个进程安全的共享主内存区域。Linux的内存管理支持虚拟内存,即在计算机中运行的程序,其代码,数据,堆栈的总量可以超过实际 内存的大小,操作系统只是把当前使用的程序块保留在内存中,其余的程序块则保留在磁盘中。必要时,操作系统负责在磁盘和内存间交换程序块。内存管理从逻辑 上分为硬件无关部分和硬件有关部分。硬件无关部分提供了进程的映射和逻辑内存的对换;硬件相关的部分为内存管理硬件提供了虚拟接口。
3. 虚拟文件系统(VirtualFileSystem,VFS)隐藏了各种硬件的具体细节,为所有的设备提供了统一的接口,VFS提供了多达数十种不同的文 件系统。虚拟文件系统可以分为逻辑文件系统和设备驱动程序。逻辑文件系统指Linux所支持的文件系统,如ext2,fat等,设备驱动程序指为每一种硬 件控制器所编写的设备驱动程序模块。
4.网络接口(NET)提供了对各种网络标准的存取和各种网络硬件的支持。网络接口可分为网络协议和网络驱动程序。网络协议部分负责实现每一种可能的网络传输协议。网络设备驱动程序负责与硬件设备通讯,每一种可能的硬件设备都有相应的设备驱动程序。
5.进程间通讯(IPC) 支持进程间各种通信机制。
处于中心位置的进程调度,所有其它的子系统都依赖它,因为每个子系统都需要挂起或恢复进程。一般情况下,当一个进程等待硬件操作完成时,它被挂起;当操作 真正完成时,进程被恢复执行。例如,当一个进程通过网络发送一条消息时,网络接口需要挂起发送进程,直到硬件成功地完成消息的发送,当消息被成功的发送出 去以后,网络接口给进程返回一个代码,表示操作的成功或失败。其他子系统以相似的理由依赖于进程调度。
各个子系统之间的依赖关系如下:
进程调度与内存管理之间的关系:这两个子系统互相依赖。在多道程序环境下,程序要运行必须为之创建进程,而创建进程的第一件事情,就是将程序和数据装入内存。
进程间通信与内存管理的关系:进程间通信子系统要依赖内存管理支持共享内存通信机制,这种机制允许两个进程除了拥有自己的私有空间,还可以存取共同的内存区域。
虚拟文件系统与网络接口之间的关系:虚拟文件系统利用网络接口支持网络文件系统(NFS),也利用内存管理支持RAMDISK设备。
内存管理与虚拟文件系统之间的关系:内存管理利用虚拟文件系统支持交换,交换进程(swapd)定期由调度程序调度,这也是内存管理依赖于进程调度的唯一原因。当一个进程存取的内存映射被换出时,内存管理向文件系统发出请求,同时,挂起当前正在运行的进程。
除了这些依赖关系外,内核中的所有子系统还要依赖于一些共同的资源。这些资源包括所有子系统都用到的过程。例如:分配和释放内存空间的过程,打印警告或错误信息的过程,还有系统的调试例程等等。
系统数据结构
在linux的内核的实现中,有一些数据结构使用频度较高,他们是:
task_struct.
Linux 内核利用一个数据结构(task_struct)代表一个进程,代表进程的数据结构指针形成了一个task数组(Linux中,任务和进程是相同的术 语),这种指针数组有时也称为指针向量。这个数组的大小由NR_TASKS(默认为512),表明Linux系统中最多能同时运行的进程数目。当建立新进 程的时候,Linux为新进程分配一个task_struct结构,然后将指针保存在task数组中。调度程序一直维护着一个current指针,他指向 当前正在运行的进程。
Mm_struct
每个进程的虚拟内存由一个mm_struct结构来代表,该结构实际上包含了当前执行映像的有关信息,并且包含了一组指向vm_area_struct结构的指针,vm_area_struct结构描述了虚拟内存的一个区域。
Inode
虚拟文件系统(VFS)中的文件、目录等均由对应的索引节点(inode)代表。每个VFS索引节点中的内容由文件系统专属的例程提供。VFS索引节点只 存在于内核内存中,实际保存于VFS的索引节点高速缓存中。如果两个进程用相同的进程打开,则可以共享inade的数据结构,这种共享是通过两个进程中数 据块指向相同的inode完成。
Linux的具体结构
所谓具体结构是指系统实现的结构。
Linux的具体结构类似于抽象结构,这种对应性是因为抽象结构来源于具体结构,我们的划分没有严格依照源代码的目录结构,且和子系统的分组也不完全匹配,但是,它很接近源代码的目录结构。
尽管前面的讨论的抽象结构显示了各个子系统之间只有很少的依赖关系,但是具体结构的5个子系统之间有高度的依赖关系。我们可以看出,具体结构中的很多依赖关系并没有在抽象结构中出现。
Linux内核源代码
目前,较新而又稳定的内核版本是2.0.x和2.2.x,因为版本不同稍有差别,因此如果你想让一个新的驱动程序既支持2.0.x,又支持2.2.x,就 需要根据内核版本进行条件编译,要作到这一点,就要支持宏LINUX_VERSION_CODE,假如内核的版本用a.b.c来表示,这个宏的值就是 216a+28b+c。要用到指定内核版本的值,我们可以用KERNEL_VERSION宏,我们也可以自己去定义它。
对内核的修改用补丁文件的方式发布的。Patch实用程序用来用来对内核源文件进行一系列的修改。例如:你有2.2.9的源代码,但想移到2.2.10。就可以获得2.2.10的补丁文件,应用patch来修改2.2.9源文件。例如:
$ cd /usr/src/linux
$ patch �Cpl < patch-2.2.10
Linux 内核源代码的结构
Linux内核源代码位于/usr/src/linux目录下。
/include子目录包含了建立内核代码时所需的大部分包含文件,这个模块利用其他模块重建内核。
/init 子目录包含了内核的初始化代码,这是内核工作的开始的起点。
/arch子目录包含了所有硬件结构特定的内核代码。如:i386,alpha
/drivers子目录包含了内核中所有的设备驱动程序,如块设备和SCSI设备。
/fs子目录包含了所有的文件系统的代码。如:ext2,vfat等。
/net子目录包含了内核的连网代码。
/mm子目录包含了所有内存管理代码。
/ipc子目录包含了进程间通信代码。
/kernel子目录包含了主内核代码。
从何处开始阅读源代码?
摘要:
几乎所有工业领域的设备都是通过网络控制的。 用户界面作为一个简单的终端程序运行在与主控程序不同的硬件上, 通过网络接收和发送数据, 并且对时间不是很敏感(比方说:初始化参数和显示测量结果)。 在下面的示意图中使用绿色的箭头显示:![[gui frontend]](http://www.linuxfocus.org/common/images2/article350/frontend_en.png)
#######################################
# .fvwm2rc
# changed by shanlimin 2005-10-20
#######################################
## ==================================================================
## 图示路径设定
ImagePath +:/usr/share/icons/Bluecurve
ImagePath +:/usr/share/icons/Bluecurve/16x16/apps
ImagePath +:/usr/share/icons/Bluecurve/32x32/apps
ImagePath +:/usr/share/icons/kdeclassic
ImagePath +:/usr/share/icons/kdeclassic/16x16/apps
ImagePath +:/usr/share/icons/kdeclassic/48x48/apps
ImagePath +:/usr/share/icons/kids
ImagePath +:/usr/share/icons
ImagePath +:/usr/local/share/ icons/
ImagePath +:/usr/local/share/icons/16x16
ImagePath +:/usr/share/pixmaps
ImagePath +:/usr/share/icons/hicolor/48x48/apps
ImagePath +:/usr/local/share/fvwm/icons
ImagePath +:$HOME/.fvwm/xp/xpm/
ImagePath +:$HOME/.fvwm/xp/window /
ImagePath +:$HOME/.fvwm/xp/myicons/
## ==================================================================
##环境变量
SetEnv fvwm_wallpaper_dir $[HOME]/background
SetEnv fvwm_wallpaper $[fvwm_wallpaper_dir]/bg0.jpg
SetEnv fvwm_icon_size 128
## ==================================================================
## 桌面设定
#EdgeResistance 250 10
EdgeScroll 100 100
ClickTime 300
DeskTopSize 2x1
## ==================================================================
## 初始化设定
DestroyFunc InitFunction
AddToFunc InitFunction
+ I Exec exec xscreensaver -no-splash
+ I exec fcitx &
#+ I Exec exec gkrellm
+ I Exec exec konsole --nomenubar --noscrollbar --tn xterm
#+ I Wait "konsole"
+ I All ("konsole") State 0
## ^^^^^^^ 载入中文输入法,启动屏幕保护程序,该函数只在第一次运行fvwm时调用,
## fvwm重启时不在调用,fvwm重启时调用的是ReStartFunction。
## 而启动和重启时都调用StartFunction
## ==================================================================
## 基本鼠标设定
## I = Immediate 即刻生效
## M = On Mouse Motion 鼠标动时
## C = On Click 按一下
## D = On Double Click 按两下
## H = On Button Held Down 按下不放
##关闭窗口---------------------------
DestroyFunc DestroyOnHold
AddToFunc DestroyOnHold I Raise
+ C Schedule 100 Close
#+ H Destroy
+ H Beep
+ I Next Raise
+ I $0 FlipFocus
AddToFunc Move-or-Raise-or-Shade
+ H Move
+ M Move
#+ C Raise
#用C感觉有延迟,用I就很好了
+ I Raise
+ D WindowShade
AddToFunc Maximize-Func
+ M Maximize 80 0
+ C Maximize 100 96
+ D Maximize 100 100
AddToFunc Move-or-Raise-or-Iconify
+ I Raise
+ M Move
+ D Iconify
AddToFunc Resize-or-Raise-or-Shade
+ H Resize
+ M Resize
#+ C Raise
+ I Raise
+ D WindowShade
AddToFunc Resize-or-Raise2
+ M Raise
+ M Resize
+ C RaiseLower
AddToFunc Iconify-and-Raise
+ I Iconify
+ I Raise
#------增加移动图标功能----------
DestroyFunc Move-or-DeIconify
AddToFunc Move-or-DeIconify I Raise
+ "M" Move
+ "D" Iconify
##
AddToFunc FuncFvwmSetTitleBindings
+ I Mouse 1 $0 A Move-or-Raise-or-Shade
AddToFunc FuncFvwmUnsetTitleBindings
+ I Mouse 1 $0 A -FuncFvwmSetTitleBindings TSF
Mouse 1 SF A Resize-or-Raise-or-Shade
## ^^^^^^^ 以上设定可使窗口缩起来。 参看了 fvwm-themes 包里面的设定方
## 法。
## 颜色设定
Colorset 0 Transparent, bg blue, fg white
## ^^^^^^^ 如果要用透明背色,就用上面的设定。
Style * MiniIcon xapp_mini.png
Style * Icon xapp_36x36.png, Color #2B5E78/#E7E7EF
## ^^^^^^^ 非使用窗口的图示及色彩。
Style * HilightFore black, HilightBack #E7E7EF
## ^^^^^^^ 使用窗口的色彩。
好久没有更新Blog了,最近沉迷于Linux,Blog荒于打理,实在不该,由今天开始,我们将开始"挣脱Windows的枷锁"系列文章的书写,主要的目的是帮助大家在Linux下搭建一个完整的,替代windows并好于windows的linux桌面环境。
很多人不使用linux桌面,其中一个很大的原因就是离不开Windows下的软件,其实linux的开源社区里有得的好用的工具,关键是看您会不会用而已,所以就有了我们的这个"挣脱Windows的枷锁"这一系列文章的开始。
网络上,linux的资料非常的丰富,我们这系列的文章基本上在网络上都可以找到类似的文章,我们基本做的就是将这些散落网络各处的文章收集整理的工作而已,应了一句活,世界上不缺少美,只是缺少发现美的眼睛而已,linux的桌面应用也是如此。
一直都想看《霍元甲》,但直到前几天才下载了部,所以,今天,我们现来从Linux下的电影播放来开始我们"挣脱"之旅。
相信对于Windows下的电影播放软件,用得最多、最方便的就是暴风影音(包括其他基于MPC的实现)了,那么在Linux下是否也有类似的软件的,答案就是 MPlayer。
MPlayer是Linux下最优秀的多媒体播放器之一,播放速度是最快的,支持的文件格式也是最多的。 一下是官方的介绍:
MPlayer是Linux 上的电影播放器(也能跑在许多其它Unices上,甚至非x86CPU上,参见移植部分)。它能使用众多的本地的,XAnim,RealPlayer,和 Win32 DLL编解码器,播放大多数MPEG,VOB,AVI,OGG,VIVO,ASF/WMV,QT/MOV,FLI,RM,NuppelVideo, yuv4mpeg,FILM,RoQ文件。你还能观看VideoCD,SVCD,DVD,3ivx,RealMedia,和DivX格式的电影(你根本不 需要avifile库)。mplayer的另一个大的特色是广泛的输出设备支持。它可以在X11,Xv,DGA, OpenGL,SVGAlib,fbdev,AAlib,DirectFB下工作,而且你也能使用GGI和SDL(由此可以使用他们支持的各种驱动模式) 和一些低级的硬件相关的驱动模式(比如Matrox,3Dfx和Radeon,Mach64,Permedia3)!他们大多数支持软件或者硬件缩放,因 此你能在全屏下观赏电影。MPlayer还支持通过硬件MPEG解码卡显示,诸如DVB 和DXR3与Hollywood+。可以使用European/ISO 8859-1,2(匈牙利语,英语,捷克语等等),西里尔语,韩语的字体的清晰放大并且反锯齿的字幕(支持10种格式),和on screen display(OSD)你又觉得如何?
这个播放器能够稳如泰山的播放被破坏的MPEG文件(对一些VCD有用),而它能播放著名的windows media player 都打不开的的坏的AVI文件。甚至,没有索引部分的AVI文件可播放,你能暂时由重建他们的索引-idx选择,或者用MEncoder永久重建,使你能够 在影片中搜索!如你所见,稳定和质量是最重要的事情,而且他的速度是也惊人的。
是否已经动心了,废话少说,我们现在开始安装,和linux下的其他软件一样,MPlayer有两种安装方式,一种是直接的二进制rpm包的安装方式,另外的就是通过源码自己编译了。
二进制rpm包的安装方式很简单,直接到这里下载Suse Mplayer RPM安装包: MPlayer-1.0pre7try3-1.i586.rpm,使用rpm -ivf MPlayer-1.0pre7try3-1.i586.rpm安装就可以了。
我们今天的重点是源代码编译安装的方式,二进制RPM安装的方式比较方便,但是因为是通用的安装,所以并没有特殊的优化,而源代码编译安装的方式可以根据我们自己的PC配置进行相应的优化,对于电影播放器来说,特定的优化来实现性能的提高是非常有益的。
首先到这里下载MPlayer的源代码:
$wget http://www4.mplayerhq.hu/MPlayer/releases/MPlayer-1.0pre7try2.tar.bz2
$bzip2 -d MPlayer-1.0pre7try2.tar.bz2
$tar xvf MPlayer-1.0pre7try2.tar
$cd MPlayer-1.0pre7try2
##添加中文支持##
MPlayer-1.0pre7try2$echo "gb18030"> help/help_mp-zh_CN.h.charset
因为MPlayer的源代码要求的Gcc环境还是gcc-2.95.3,不支持现在高版本的Gcc-4.X,所以我们需要对源代码打个Gcc-4x的补丁: mplayer-1.0_pre7-gcc4.patch,将该文件保存在MPlayer-1.0pre7try2目录下,然后使用一下命令打补丁:
MPlayer-1.0pre7try2$patch -p1 < mplayer-1.0_pre7-gcc4.patch
另外,为了免除字体安装的麻烦,我们再打一个Gtk2的补丁,让mplayer使用Gtk2,这样就支持utf-8的编码了。到这里下载补丁: mplayer-1.0_pre7-gtk2.patch,同样保存到MPlayer-1.0pre7try2目录下,执行一下命令:
MPlayer-1.0pre7try2$patch -p1 < mplayer-1.0_pre7-gtk2.patch
最后我们在编译前,我们需要现下载MPlayer解码器,到这里下载: all-20050412.tar.bz2
MPlayer-1.0pre7try2$wget http://www4.mplayerhq.hu/MPlayer/releases/codecs/all-20050412.tar.bz2
MPlayer-1.0pre7try2$ bzip2 -d all-20050412.tar.bz2
MPlayer-1.0pre7try2$tar xvf all-20050412.tar
创建一个目录用来存放,我们的编码器,目录位置及名称任意。
MPlayer-1.0pre7try2$mv all-20050412 /usr/lib/codecs
OK,准备工作做完,可以开始编译了。
配置,带GUI界面的MPlayer,解码器存放位置/usr/lib/codecs,支持zh_CN和en语言,utf-8编码,mplayer将安装在/opt/feiy/player/MPlayer1.0下:
MPlayer-1.0pre7try2$./configure --enable-gui with-codecsdir=/usr/lib/codecs \MPlayer-1.0pre7try2$make MPlayer-1.0pre7try2$make install
--with-win32libdir=/usr/lib/codecs with-reallibdir=/usr/lib/codecs \
--with-xanimlibdir=/usr/lib/codecs disable-inet6 --language=zh_CN,en \
--prefix=/opt/feiy/player/MPlayer1.0 charset=utf8
因为我们是从源代码安装的,源码中并没有带MPlayer皮肤,所以我们还需要安装一下MPlayer的皮肤,到这里下载MPlayer皮肤,官方提供好多款皮肤下载,我们这里下载默认的皮肤 Blue Skin
$wget http://www1.mplayerhq.hu/MPlayer/Skin/Blue-1.5.tar.bz2
$bzip -d Blue-1.5.tar.bz2
$tar xvf Blue-1.5.tar
$mv Blue $MPlayer1.0_install_path/share/mplayer/Skin/default/skin
然后将其移动到,MPlayer安装目录下的share/mplayer/Skin/default/skin 以上就安装好了MPlayer,在/opt/feiy/player/MPlayer1.0/bin目录下,就可以看到我们的mplayer,其中 mplayer是命令行方式的MPlayer播放器,gmplayer是GUI方式的MPlayer播放器,而mencoder是解码器。
MPlayer用法:
用法: mplayer [options] [url|path/]filename
基本选项: (包括所有选项的详细列表参见manpage!)
-vo 选择视频输出模式和设备(用'-vo help'查看列表)
-ao 选择音频输出模式和设备(用'-ao help'查看列表)
vcd:// 从设备而不是普通文件上播放VCD(video cd)track
dvd:// 从设备而不是普通文件上播放DVD title/track
-alang/-slang 选择DVD音轨/字幕的语言(使用两位的国家代码)
-ss 寻找指定的(多少秒或hh:mm:ss)位置
-nosound 不播放声音