Saturday, October 25, 2008

开始试用planner

安装了fedora9,发现菜单里自带了project management 工具planner.  于是准备试着用, 来管理工作上的项目. 当然效果要至少一星期还能出来, 到时我再来写试用心得.

虽然当项目经理已经有很长一段时间(具体多久忘了,一年左右. 问题还是不少, 也许就是因为没有使用项目管理工具的原因. 毕竟工作还是很忙的. 每天在项目管理上没法花太多的时间,造成任务布置下自己都忘了, 没有及时跟踪进度, 并且布置任务没注意设置期),希望这个工具的使用能帮助我更好的当好项目经理这个角色.

Saturday, October 18, 2008

慢性支气管炎

今早跑去海淀医院去看慢性支气管炎的问题.

人很多,干什么都要排队. 所以最好还是早点去.

拍了个肺部的X光(出片等了约一个小时),没啥问题.
医生就开了点药:
消咳喘片 X2
孟鲁司特钠片 X1
一共花了约两百块钱.

希望吃了过后能好起来,跑医院还是很烦的.

Friday, October 17, 2008

我所选的医保定点医院的等级

(这些信息可以http://www.bjld.gov.cn 上查到)
北京市海淀医院 二级甲等
北京市中关村医院 二级甲等
北京市上地医院 二级合格
北京市海淀区清河医院 一级甲等

竟然没有一个三级的,郁闷. 当时无知啊,也许是政策不允许.

Thursday, October 16, 2008

Ptherad Cancelability

Ptherad Cancelability 的标准说明见: POSIX.1 2.9.5 Thread Cancellation.

相关接口有:
int pthread_setcancelstate(int state, int *oldstate);
int pthread_setcanceltype(int type, int *oldtype);
void pthread_testcancel(void);

其中:
pthread_setcancelstate 来控制是否允许 cancel.
pthread_setcanceltype 用来控制 Ptherad Cancelability Type: 有deferred 和 asynchronous 两种. deferred 的实现方式为当调用 pthead_cancel时, 在pthread 管理结构中置上一个标志, pthread调用一些libc库函数时,会默认检测和处理这个标志, 也可以显示调用pthread_testcancel 来检测并处理这个标志. asynchronous 的实现方式为 通过 tgkill 系统调用来发送 SIGCANCEL 信号(此信号不能通过pthead_kill发送,无法通过参数检查).

Sunday, October 05, 2008

成都出差的一些照片

出差接近一个月. 没写下些什么,图省事,只放上些挑选出来的几组照片

2008_0906锦里
2008_0906锦里


2008_0914烷花溪
2008_0914烷花溪


2008_0930峨眉山
2008_0930峨眉山

Saturday, September 27, 2008

体验成都的长途客运服务

第一次来成都,就觉得这个城市还不错. 绿化挺多, 城市也还比较整结. 至少比长沙还是要好些. 前几天从成都去了趟绵阳.又体验到一次成都的好. 我是在昭觉寺坐的车. 到绵阳的车次很密集,不用怎么候车. 进站后,每台车的乘务员站在车前等候乘客. 并且乘务员统一着装. 这个我在其它长途车站没有看到过. 一下感觉这个服务品质肯定不一样. 上车后不一会车就开了. 乘务员先后用中文和英文说了一遍例行的欢迎话语. 我英语水平还没高到能去评价乘务员的英语水平,不过至少说明车站对乘务员的英语水平是有要求的. 然后乘务员给每人乘客发放一小瓶纯净水. 虽然这水可能是企业赞助的,但给人的感觉很好.
我第一次认识到:原来长途客运的服务也是可以做得这样好的.

Monday, September 15, 2008

address space resource

内核中有很多资源,但属于IO资源的有:
#define IORESOURCE_IO        0x00000100    /* Resource type */
#define IORESOURCE_MEM        0x00000200
#define IORESOURCE_IRQ        0x00000400
#define IORESOURCE_DMA        0x00000800

本文我主要研究IORESOURCE_IO IORESOURCE_MEM,及地址空间的管理,涉及的文件只有kernel/resource.c.
这两种资源本质上都是一段地址空间. 只是类型不一样
IORESOURCE_IO 指的是IO地址空间,这个空间从kernel编程上来看,只能通过专门的接口函数才能访问.硬件层面上,cpu需要用特殊指令才能访问或需要用特殊访问方 式才能访问,不能直接用指针来寻址.在PC机上,其指的就是PCI/CPU IO address space.在嵌入式中,基本上没有io address space.
IORESOURCE_MEM 指的是属于外设或者用于和设备通讯的支持直接寻址的地址空间.PC机上,主板上北桥上连的内存都是交给kernel直接管理,或者都是用于软件执行,所以 这部分内存不属于IORESOURCE_MEM, IORESOURCE_MEM主要是指PCI设备的 memory address space. 但在嵌入式上, 主板上的sdram一般是设备与cpu共享的. 故交给kernel直接管理的内存只是一部分.余下的内存以及寄存器空间都作为IORESOURCE_MEM来管理.

只所以需要管理,是 因为像PCI总路线设备的这些地址空间是设备向系统申请的,故是可配置的,并且设备并身可能热插拨或更换,故其变成一种可分配的资源. 故内核用算法来管理分配与释放操作,防止冲突和便于查询维护.但实际PC中,BIOS一般会做分配操作,内核需要是把分配结果添加进来,故提供了注册(或 者叫做添加)接口. 在嵌入式系统中,外设的地址也通常是固定的,只需要添加即可.

这两种资源,内核采用同样的管理算法--二叉树.相当于内核维护两个独立的二叉树. 按地址基地址与地址长度范围作为管理数据.可以添加,分配,释放节点.分配过程中可以避
免空间冲突,添加时可以识别空间冲突.根节点在kernel/resource.c中以全局变量方式定义.根节点用于限制地址空间的范围.

主要接口:
int insert_resource(struct resource *parent, struct resource *new)
int adjust_resource(struct resource *res, unsigned long start, unsigned long size)
int allocate_resource(struct resource *root, struct resource *new,
              unsigned long size,
              unsigned long min, unsigned long max,
              unsigned long align,
              void (*alignf)(void *, struct resource *,
                     unsigned long, unsigned long),
              void *alignf_data)
int release_resource(struct resource *old)
int request_resource(struct resource *root, struct resource *new)

上面的接口对上述4种资源类型都有效,对于IORESOURCE_IO 和 IORESOURCE_MEM这两种资源,使用这两个接口更为方便
request_region(start,n,name)
release_region(start,n)
        io space
request_mem_region(start,n,name)
release_mem_region(start,n)
        mem space

在 /proc 文件系统中,ioports和iomem分别显示系统当前这两种资源.


嵌入式设备的外设一般先作为platform device添加到platform bus上,其主要目的就是向系统注册资源,在platform_add_devices时做,
如:
/* Watchdog timer parameters */
static struct resource wdt_resource[] = {
    /* Watchdog timer only needs a register address */
    [0] = {
        .start = 0xFFC00008,
        .end = 0xFFC00010,
        .flags = IORESOURCE_MEM,
    }
};

struct platform_device wdt_device = {
    .name = "wdt",
    .id = -1,
    .num_resources = ARRAY_SIZE(wdt_resource),
    .resource = wdt_resource,
};
platform_add_devices(wdt_device,1);


故如已知设备的物理地址,并不一定需要request_mem_region,因为这个操作并没有涉及到任何硬件,与软件访问也没有任何关系..但一般还是推荐做.

I/O port 访问流程( 不用mem模拟方式):
request_region()   #在设备驱动模块加载或opn() 函数中进行,物理i/o port地址由pci bios模块分配
inb(),outb()等     #在设备驱动初始化,write(),red(),ioctl() 等函数中进行
relase_region      #在设备驱动模块卸载或release() 函数中进行

I/O port 访问流程( 用mem模拟方式):
request_region()
ioport_map         #在设备驱动模块加载或opn() 函数中进行,物理i/o port地址由pci bios模块分配
ioread8,iowrite8等 #在设备驱动初始化,write(),red(),ioctl() 等函数中进行
ioport_unmap()
relase_region      #在设备驱动模块卸载或release() 函数中进行


request_mem_region
ioremap         #在设备驱动模块加载或opn() 函数中进行,物理i/o port地址由pci bios模块分配
ioread8,iowrite8等 #在设备驱动初始化,write(),red(),ioctl() 等函数中进行
iounmap()
relase_region      #在设备驱动模块卸载或release() 函数中进行

内核如何识别root参数所指定的根文件系统设备

把内核的sysfs配置选择去掉后,发现无法mount根文件系统了. 于是,看内核是怎么识别root参数的,以及其与sysfs的关系.
 root 参数的处理在是do_mount.c的prepare_namespace函数里. 基本原理为:先munt devfs到/dev目录,然后根据root参数中指定的设备文件名字,从devfs中找到设备文件对应的dev对象,这样就可以开始mount操作了. 不过devfs文件系统已被废弃了. 相应的功能由sysfs取代. 逻辑差不多.
  另外 /dev/nfs 并不是实际设备文件,只是根代表文件系统为nfs文件系统. 故处理逻辑中不会用到devfs或sysfs. 所以去掉 sysfs 后,内核仍然能mount 上nfs根文件系统,而无法mount上flash mtd partition上的根文件系统.

(移动)硬盘安装fedora9

拿着公司的笔记本回来装fedora9,发现光驱不能用. 故重新温习了一下硬盘安装linux的操作.
以下为笔记:

是内置硬盘,还是usb移动硬盘,方法都是一样的. 故这里不加区分.

基本原理: 开机BIOS加载硬盘上的引导程序grub,gurb从硬盘上引导一个kernel和简单安装程序. 简单安装程序启动后,此时有足够的设备驱动, 再由你来选择具体安装方式: 硬盘安装(ISO)或网络安装(NFS),并进行相应的配置.

上 面提到的安装程序的kernek和简单安装程序都在ISO文件的isolinux目录下,分别叫vmlinuz和initrd.img. 我们将其解出到硬盘的某个分区上(gurb不支持NTFS文件系统). 简单安装程序不支持NTFS文件系统,所以ISO文件要存放在非NTFS分区上.

因此第一步要安装grub.由于gurb要由 BIOS引导,故gurb要安装在任何可启动的磁盘驱动器上. 如你的内置硬盘,或USB存储介质(如BIOS支持的话). 如果电脑的内置硬盘上已经安装有windows,可以在windows里进行安装gurb. 下载WINGURB,选择grub-install,设备选你的内置硬盘即可. 由于grub支持命令行编辑启动,所以无需配置,只要安装上就行. 重启后即进入到grub启动界面,按c进入命令行模式, 用root命令设定vmlinuxz以及initrd.img所在的分区为root分区. 接着用kernel命令和initrd分别选定 vmlinuxz和initrd.img. 最后输入 boot 即可启动. 配置完语言和键盘后,即选择安装方式,选硬盘安装并且指定好ISO所在分区和目录即开始常规的安装过程.

chroot初探

最初使用chroot这个命令是在 fedora 系列的救援模式下,实现根文件系统由光盘上的文件系统切换到本地硬盘上的文件系统. 最近由于开发中要用到这个命令,故好好看了看文档,加深一下了解.

  这个命令的功能描述为:Run a command with a different root directory. 即在/目录理解成其它目录的环境下运行一个命令. 而我以前将其错误的理解成整个应用环境的功换. chroot下应用执行环境与原来的环境的差别只是/目录的实际物理路径不一样(当然会造成同样的路径所访问到的实际文件不一样)

 不过实际使用中,一般都是这样用chroot:
chroot 目录
 这 种用法后面没有跟一个命令作为参数,chroot会默认执行SHELL环境变量所保存的值作为命令来执行. 由于SHELL这个程序运行起来后不会退出,且会在终端下给出命令提示符,所以整个个命令执行起来后,即陷入,同时出现新shell的提示符,给人的感觉 是切换到新的用户环境. 由于新的shell会重新载入一些环境变量以及初始化脚本,故新环境下坏境变量与原来的环境变量还是有一些差别的.

要测试的话:
新建一个目录,把/bin以及/lib目录拷贝到新目录下,然后就可以chroot到新目录,输入exit即回到原来的环境.

openoffices tip

以前一直习惯于用文本文件来作笔记. 回过头来看这些笔记的时候发现表现力还是不够,或者不够清晰. 于是开始转到openoffice来. 摸索了一阵后,终于可以应付简单的排版了. 以下为备忘:

页面横向纵向设置:
在 Format --> Page 菜单里,  对应英文为Orientation:  Portrait(纵向)  Landscape(横向)

linux用电驴

amule 和 emule 的区别在于 2.1.3的amule不支持upnp端口映射. 故需要要路由器器上去作固定端口映射,速度才上得去.

安装amule:
yum install amule.

所需要做的配置:
1,更新服务器列表
http://www.emule.org.cn/server.met
2,更新 kad 网络
http://www.emule-inside.net/nodes.dat
3,更新用户名前缀
[CHN][VeryCD] 否则连不上 VeryCD 的这个服务器(no1.eserver.emule.org.cn)这 2 个服务器对于国内
用户是相当不错的选择。



浏览器关联:
在地址栏输入 about:config
新建"布尔"
名称为:network.protocol-handler.external.ed2k
值为:true
新建"字符串"
名称为:network.protocol-handler.app.ed2k
值为:/usr/bin/ed2k

shell脚本的路径问题

从网上找到如何从得到shell script的绝对路径的方法:

#! /bin/bash
echo "Path to $(basename $0) is $(readlink -f $0)"

但这种方法只适以子shell方式执行的脚本,不适用于在当前shell中执行的脚本.

难道就没有方法了吗? 

Latex初探

    前段时间要给公司新员工培训linux方面的知识,故使用openoffice来做. 不知道是不是我的版本有问题还是什么原因,设置格式什么的不太好用.当然对于微软的office,我也不太熟悉.

    偶然间在水木上进去到latex的版块,简单了解一下后也就有了想学的冲动. 立刻找资料.但估计这个东西和emacs一样,学习曲线都会是十分陡的. 所以学习笔记先就不在这里记了. 等以后感觉学到某个阶段,再把整理好的笔记补上.

tor

firefox 使用 tor :

1. yum install tor
2. install foxyproxy add-on in firefox
2. restart system or start tor manually
3. configure the autoproxy(firefox add-on) to using tor with specify URL.
4. enjory

yum使用代理

添加 一行:proxy=http://x.x.x.x:x在/etc/yum.conf.

双系统共享邮件

由于工作需要使用linux, 而部分工作又离不开 win(主要是写烦人的文档. ). 故经常两个系统切换.  这就造成 两个问题: 邮件在一个系统下
收了,无法在另一个系统下访问到。 另外一个就是两个系统下的浏览器的bookmark需要手动去同步.

今天终于试验了一下这两者都使用跨平台的软件,分别是firefox和thunderbird. 并且把储存配置文件和数据的目录(profile)指向硬盘的同一个位置.

这里要注意两个平台下的这两个软件的版本最好一致,否则启动时老是要检果插件版本等工作,影响启动速度.

修改firefox profile 路径的方法:
Mozilla Firefox stores all your personal settings, such as bookmarks, passwords and extensions, in a profile. The profile is stored on your hard drive in a profile folder

Move an existing profile or restore a backed up profile

It's possible to move the location of a profile folder. This could be useful if you have a backed up profile folder somewhere
on your hard drive and want to tell Firefox to use that as your profile. This section explains how to do this.

   1. Shut down Firefox completely (File > Exit).
   2. Move the profile folder to the desired location. For example, on Windows XP, move the profile from C:\Documents and Settings\[username]\Application Data\Mozilla\Firefox\Profiles\xxxxxxxx.default to D:\Stuff\MyProfile. If you are reading these instructions because you want to restore a previously backed up profile, this step isn't necessary. Just note the current location of the profile you want to restore.
   3. Open up profiles.ini in a text editor. The file is located in the application data folder for Firefox:
          * On Windows Vista/XP/2000, the path is %AppData%\Mozilla\Firefox\
          * On Windows 95/98/Me, the path is usually C:\WINDOWS\Application Data\Mozilla\Firefox\
          * On Linux, the path is ~/.mozilla/firefox/
          * On Mac OS X, the path is ~/Library/Application Support/Firefox/
   4. In profiles.ini, locate the entry for the profile you've just moved. Change the Path= line to the new location. If you are using a non-relative pathname, the direction of the slashes may be relevant (this is true for Windows XP).
   5. Change IsRelative=1 to IsRelative=0.
   6. Save profiles.ini and restart Firefox.

修改tunderbird profile 的方法差不多.

用 firefox 保存网页中的 flash

http://labnol.blogspot.com./2005/11/save-flash-from-firefox-and-ie.html 里介绍可以这样做:

1. Saving Flash files from Firefox

Firefox for Newbies
a. Click Tools - Page Info
b. Click the Media Tab on the Page Info Windows
c. The media tab has a complete list (with preview) of Images, CSS Files and Shockwave Flash files that were downloaded by the Firefox browser while rendering (loading) the page.
d. Scroll down the list and locate the swf file.
e. Click the "Save As" button. Select some directory on your hard drive and save the file (No need for a third-party plug-in)

Firefox for Geeks and Power Users
a. Type about:blank in the Firefox address bar
b. Now click List cache entries or directly type about:cache?device=disk (Disk cache device)
c. Press Ctrl+F and try to location the flash file by typing some part of website URL or the flash file name or just .swf. After some hit and trial, you should be able to locate the swf file URL
d. Click the SWF URL to open the Cache Entry Information page. Right click on the link and choose "Save link as"

不过Firefox for Newbies 的方法对于我所要的保存的Flash 不管用. 而for Power Users 的方法好像有点麻烦. 有个插件可以帮忙:
cacheviewer

安装完成后,在Firefox浏览器中,点击 工具->CacheViewer,打开下面的窗口,在"搜索"(search)中填入要找的flash的文件名,双击保存就可以了。

thread

A thread may be created as a joinable thread (the default) or as a detached thread. A joinable thread, like a process, is not automatically cleaned up by GNU/Linux when it terminates. Instead, the thread's exit state hangs around in the system (kind of like a zombie process) until another thread calls pthread_join to obtain its return value. Only then are its resources released. A detached thread, in contrast, is cleaned up automatically when it terminates. Because a detached thread is immediately cleaned up, another thread may not synchronize on its completion by using pthread_join or obtain its return value.

When create thread with pthread_create, the attr argument can also be NULL, in which case default attributes are used: the created thread is joinable (not detached) and has an ordinary (not realtime) scheduling policy.

关于linux 实时性的 好文章
http://blog.tom.com/blog/read.php?bloggerid=993876&blogid=57349

compile and debug directfb

First is something about my develpment environment:
[root@localhost bin]# uname -a
Linux localhost.localdomain 2.6.20-1.2952.fc6 #1 SMP Wed May 16 18:59:18 EDT 2007 i686 i686 i386 GNU/Linux
[root@localhost bin]# rpm -qa | grep gcc
libgcc-4.1.1-30
gcc-4.1.1-30
gcc-gfortran-4.1.1-30
gcc-c++-4.1.1-30

1. Enable Frame buffer device dirver in your machine.

DirectFB version: DirectFB-1.0.0 DirectFB-examples-1.0.0
2. DirectFB:
./configure --prefix=/home/dybbuk/study/DirectFB_install/ --enable-x11 --enable-debug
make
make install

3. DirectFB-examples
./configure --prefix=/home/dybbuk/study/DirectFB_install/ DIRECTFB_CFLAGS=-I/home/dybbuk/study/DirectFB_install/include/directfb/ DIRECTFB_LIBS="-L/home/dybbuk/study/DirectFB_install/lib/ -ldirectfb"
make
make install

Test(under char mode):
export $LD_LIBRARY_PATH=/home/dybbuk/study/DirectFB_install/lib/
/home/dybbuk/study/DirectFB_install/bin/df_window

4. deubg:
add a line "system=x11"  in  the /etc/directfbrc file. 
debug directfb application under X.

For more information see the maillist below:


A copy-paste regarding X method. But I don't know a way without X, and with one machine. If u come to know, plz post it :-)
-----------

Use X

Just for the sake of development, DirectFB actually provides an X backend. In that mode, an X window is the directfb screen, and all directfb display goes to that X window. That is convenient, because
  • We can simultaneously work with whatever other X applications we want
  • Much easier to debug,
  • In situations like crashing or hanging up, you can just close the window, or in the worst case, just killall -9 program-name

Using the X backend

If you did not build directfb with --enable-x11 option, you need to rebuild it with that option(the option is given to configure script). Then, in the /etc/directfbrc file, you need to add a new line: system=x11

Then you can run the same directfb application from X

For performance analysis, and final testing, I would recommend using virtual console, and not X, because thats the way directfb will finally work...



Colin Newell wrote:
What is the best way to run a debugger to debug a directfb program?

One choice is to open an xterm into the machine supporting directfb, and
run gdb in the xterm. If you can see the screen of the directfb machine,
and the Xserver's screen you can efficiently debug.

What if you only have the directfb machine to work on?

If I run gdb on a directfb program directly on the machine with
directfb, then as soon as directfb starts up, gdb loses control of the
keyboard and screen (and then I need to actually kill the program via
an xterm). Is there a clever way to allow use of gdb directly on a
machine running directfb?

Any ideas appreciated.

Regards
Colin Newell

_______________________________________________
directfb-users mailing list
directfb-users@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users