2010年9月5日

Preparing the environment for the study of writing an OS (2008-01-06)

There is a book (《自己动手写操作系统》) introduces how to write an OS by ASM and C programming language. Before testing the examples in the book, it need to build an environment first. My laptop is Compaq nc6400 and the OS is Windows2000 SP4, so I choose the following software to build the environment:

1 Virtual PC 2004 SP1 (Virtual PC 2004 SP1.zip)

  We can download it from Microsoft’s website. The additions is in the directory C:/Program Files/Microsoft Virtual PC/Virtual Machine Additions after the software be installed.

2 DOS 6.22 (622c.zip)

  Just Download it from: http://www.bootdisk.com/bootdisk.htm, and choose the

Non-Windows Based Image Files W/ImageApp

DOS 6.22 | Mirror |

3 NASM (nsm09839.zip)

  The 16-bit binaries can be run correctly in the former DOS. It can be download form http://sourceforge.net/projects/nasm

4 Linux (Fedora Core 5 DVD)

  Red hat Linux 9 can not be found easily now, and Fedora Core 3 has some problem in the virtual machine, so I choose FC5.

  If the graphic interface can not show correctly, press Ctrl+Alt+F1 to enter text interface and modify following files:

  /etc/inittab: change id:5:… to id:3:…, so that next reboot can use text interface directly

  /etc/X11/xorg.conf: change DefaultDepth 24 to 16 and try.

  If 'initx' can not work try to use 'startx'.

The next thing is testing the Boot Sector, Protecte Mode, Loader, and Kernel.

 

A simple makefile for building applications with ACE 5.6 (2008-04-11)

The example makefile in the book "ACE Programmer's Guide" does not work very well in ACE 5.6, here is a simple makefile which is modified:

BIN = hello_ace

FILES = main.cpp/

OBJS   = $(foreach var, $(addsuffix .$(OBJEXT), $(basename $(FILES)) $(RESOURCES)), $(if $(findstring ../,$(var)),$(notdir $(var)),$(var)))
SRC    = $(FILES)

LDLIBS = -lACE

include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
include $(ACE_ROOT)/include/makeinclude/macros.GNU
include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
include $(ACE_ROOT)/include/makeinclude/rules.local.GNU

$(BIN): $(addprefix $(VDIR), $(OBJS)) $(DEPLIBS)
$(LINK.cc) $(LDFLAGS) $(CC_OUTPUT_FLAG) $@ $^ $(VLDLIBS) $(POSTLINK)

__prebuild__:
@-:

 

Arguments parsing function (2008-04-26)

ACE_Get_Opt is ACE's primary class for cmmand line argument processing. It is a C++ wrapper facade for the standard POSIX getopt() function. Maybe these functions are no use for graphic programming or beginner, but every programmer should know these functions.

I can not understand the chapter 4 of "The ACE Programmer's Guide", until I have learned these functions from the book "Linux Programming by Example". I think it will spend less time on reading a book as the more knowledge I have learned.

 

How to run cl.exe in command line (2008-05-16)

The Microsoft compliers are invoked using the command cl, but we need first run the batch file vsvars32.bat in the C:/Program Files/Microsoft Visual Studio/VC98/Bin. Here are some notes for using this tool:

1. Check the command in the batch file, the file path may be not correct.

2. The environment variables have effect only in current command window, so we need run the batch every time we need it (I have copied the batch file into a path which in the %path%, so I can run it directly).

3. We can also edit our environment variables in the System Properties, but it will make the environment variables complex, and I prefer the former manner.

Learned from <C++ Cookbook> and <Core Java 2, volume II>.

 

Local static object is dangerous in multithreaded system (2010-08-30)

No matter an object is const or not, if it is a local static object, it should never be used in multiple threads. For example:

void func()
{
    const static string x = "Hello world!";
    cout << x << endl;
}

Even this simple function can crash your process. Because two threads may create the local static object at the same time! If one thread is accessing the static object which is resetting by another thread unfortunately, a crash will happen.

 

Training - JBoss for Java developer (2008-12-06)

The course is provided by Redhat, because JBoss is a division of Redhat now. It is simple but refere to many fields, such as JSP, survlet, JSF, JPA and EJB, and also makes me familiar with eclipse and mysql tools. And one more important thing is give me more confidence for next transfer.

 

A Software Engineer Prepares (2009-05-29)

This is a book which chinese name is "程序员的自我修养 -- 链接、装载与库". I have a desire to buy it when I first saw it. But the main reason is its book name. Stephen Chou have a book "An Actor Prepares" in his movie "King of Comedy", it is very impressive. So as a software enineer, I think I should have a book which is called "A Software Engineer Prepares" also, no matter what it has writen. But luckily, I think it is a good book writed by Chinese, After reading it today. Only after reading a few pages, I have learnd a lot. Such as northbridge and southbridge. And a very important thing is I learned a logion: "Any problem in computer science can be solved by another layer of indirection." It's true, for example, the operating system, the virtual memory, the thread and process, the programing language, the distribution, and so on. There are many layers in our products also, such as bric core and front bric, may be we could add another layer when we meet another problem in the future:)

 

编译Linux内核2.6.34 (2010-06-15)

之前仅仅在Windows里面下载了源代码,前几天突然想编译并运行一下,跌跌撞撞到现在终于在虚拟机里面成功了大半。另外的一小半暂时不搞了,编译内核实在太费电了。

编译之前需要配置,如果用make config手工配置,大概需要一个工作日的时间,那么多yes,no要选,而且一旦选错还不能退回去改。用make menuconfig简单很多,但是需要下载安装另外的工具才能用。

配置好了就可以make了,不知道是虚拟机的缘故,还是配置得比较多,断断续续花了一天时间才编完,用make defconfig配置的编起来好像很快。

之后还要make install,make modules_install等,还要生成一个initrd文件。

最后就是修改grub启动,让新的内核生效。

虽然重启后有个FATAL Error,但可以进入系统,用uname -r已经看到了2.6.34的新版本。

总得来说,内核的细节问题还是不懂,但总是有个感性认识了,以后的什么时候再拿出来研究吧。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值