Archive for 10月, 2008

Latex中文配置

星期一, 10月 20th, 2008
  • Linux

从源里面安装Texlive2007(apt就是好啊),之后下载YueWang zhfonts 。解压到$HOME下的.texmf-config.texmf-var文件。
搞定。

  • Windows

还是用CTEX套装吧,别瞎折腾了。

参考
http://forum.ubuntu.org.cn/viewtopic.php?f=35&t=84013

Powered by ScribeFire.

Buffered I/O and non-buffered I/O

星期日, 10月 12th, 2008

实验需要对Flash Disk做无系统缓冲的I/O操作,顺便了解了一下Linux下的I/O.

Linux上的块设备的操作可以分为两类:

  • 第一类是使用C标准库中的fopen/fread/fwrite 系列的函数,我们可以称其为 buffered I/O。

具体的I/O path如下

Application<->Library Buffer<->Operation System Cache<->File System/Volume Manager<->Device

library buffer是标准库提供的用户空间的buffer,可以通过setvbuf改变其大小。

  • 第二类是使用Linux的系统调用的open/read/write 系列的函数,我们可以称其为 non-buffered I/O。

I/O Path

Application<-> Operation System Cache <->File System/Volume Manager<->Device

此外,我们可以通过设置open的O_DIRECT标志来实现Direct I/O(或者叫Raw I/O),即绕过OS Cache,直接读取Device ( that’s what we want^o^ ), 等于将OS cache换成自己管理的cache。不过,Linus在邮件列表中建议不这么做,而是使用posix_fadvice, madvice。[2]中表明Direct I/O比buffered I/O的性能高很多。

在使用O_DIRECT的注意buffer的address必须是block alignment的(i.e. 初始地址必须是boundary), 可以用posix_memalign()函数分配内存以得到这样的buffer。至于为什么要这样,与实现的mmap有关,参见[5].

参考:

  1. Linux: Accessing Files With O_DIRECT http://kerneltrap.org/node/7563
  2. Andrea Arcangeli , O_DIRECT Whitepaper http://www.ukuug.org/events/linux2001/papers/html/AArcangeli-o_direct.html
  3. A Trip Down the Data Path: I/O and Performance http://articles.directorym.net/_A_Trip_Down_the_Data_Path_IO_and_Performance-a894569.html
  4. Operating Systems System Calls and I/O http://articles.directorym.net/Operating_Systems_System_Calls_and_IO-a894576.html
  5. Linux Device Drivers, 2nd Edition, Chapter 13 mmap and DMA http://www.xml.com/ldd/chapter/book/ch13.html
  6. http://topic.csdn.net/u/20080806/10/cdb1faa1-0146-4e96-8b12-26ba60acdbb5.html
  7. http://lists.alioth.debian.org/pipermail/parted-devel/2007-July/thread.html#1855
  8. Read系统调用剖析, http://www.ibm.com/developerworks/cn/linux/l-cn-read/

Powered by ScribeFire.

dhcp与静态ip切换

星期六, 10月 11th, 2008

实验室用的是dhcp,寝室用的是静态ip地址,每次切换起来比较烦人,于是上网搜了一下写了个脚本。

  • Windows

寝室设置[静态ip地址]

netsh interface ip set address “本地连接” static IP 地址 子网 网关 跃点数(一般为1)
netsh interface ip set dns “本地连接”
dns地址

实验室[动态IP地址]

netsh interface ip set address “本地连接”  dhcp
netsh interface ip set address “本地连接”  dhcp

参考:

  1. 如何使用 Netsh.exe 工具和命令行开关 http://support.microsoft.com/kb/242468
  2. 如何使用 NETSH 命令在 Windows 2000 中将静态 IP 地址更改为 DHCP 地址 http://support.microsoft.com/kb/257748
  • Linux
  • 等用了再说

Technorati 标签: , , ,

git

星期六, 10月 4th, 2008

git是一种分布式的版本控制软件。前段时间完成GSoC的时候用过一段时间,非常强悍!下面是一些资源以及一些常用的命令。

 

Resources

  • 中文教程

http://www.bitsun.com/documents/gittutorcn.htm

  • gitHub上的guide (强列推荐)基本上你想问的问题都有了

http://github.com/guides/Home

  • 上面的精简版

http://www.sourcemage.org/Git_Guide

  • Kernel Hackers’ Guide to git

http://linux.yyz.us/git-howto.html 最后,最重要的还有官方文档。

 

Useful Commands

Day of GIT

    $ git clone http://xxx
    $ git branch gsoc           # new branch
    $ git log #浏览历史
    $ git show 12798172e98f1    #显示相应的版本
    $ git-tag old 12798172e98f1 #为版本命名
    $ git diff a..old a..gsoc   #比较两个版本

 

Revert

回到上次的commit状态(撤除现有的所有修改) $ git reset –hard 回到某个commit状态 $ git revert $id

 

Merge

合并两个branch $ git merge $id

 

remote

push一个branch [code]$ git push origin branch-name[/code]

删除一个branch [code]$ git push origin :branch-name[/code]

Misc

这样一个场景

        repos in web
        /               \
repos1          repos2
 |
 branch-my

现在要把原来在branch-my移到repos2下,可以通过patch来完成。

To Be Continued…