Skip to main content

Sponsors

xman的纪念册

Posted in

我们的纪念册

Posted in
追忆。。。。。。中学毕业时总会有人写纪念册。 八年后的今天,你的纪念册还在吗? 它是否让你勾起丝丝的回忆?

Compiling Blender in FC6

Posted in

Pre-requisite:

  • freealut
  • freealut-devel
  • OpenEXR
  • OpenEXR-devel
  • gettext
  • gettext-devel
$ yum install freealut freealut-devel OpenEXR OpenEXR-devel gettext gettext-devel
$ tar zxvf blender-2.42a.tar.gz
$ cd blender-2.42a
Edit compilation flags in config/linux2-config.py
$ scons -j 2  # Uses 2 processors.

My Reversi is Memory Leak Free: Certified by Valgrind

When we write programs, we spend lots of time in managing memory. Improper memory management can lead to memory leak, therefore reserving memory that will never be used. Memory leak problems can be serious especially when an application needs to run for a long time. No matter how much memory you have, regular memory leaks can make you run out of memory eventually.

I run "valgrind" to check if my Reversi in C++ has memory leak problems.

$ time valgrind --tool=memcheck ./reversi
==4305== Memcheck, a memory error detector.
==4305== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==4305== Using LibVEX rev 1658, a library for dynamic binary translation.
==4305== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==4305== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==4305== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==4305== For more details, rerun with: -v
==4305==

(0,0): 9999990
7 1 1 1 1 1 1 1 1
6 1 1 0 0 0 0 1 1
5 1 1 1 0 1 1 0 1
4 1 1 0 1 1 0 0 1
3 1 1 0 0 1 1 0 1
2 1 0 1 0 0 1 0 1
1 1 1 0 0 0 0 1 1
0 1 1 1 1 1 1 1 1
  0 1 2 3 4 5 6 7

White: 44 Black: 20
Recursive evaluate: 53671516
Recursive end eval: 135214583
Evaluation: 44228633

==4305==
==4305== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
==4305== malloc/free: in use at exit: 0 bytes in 0 blocks.
==4305== malloc/free: 289,208,130 allocs, 289,208,130 frees, 6,940,995,120 bytes allocated.
==4305== For counts of detected errors, rerun with: -v
==4305== All heap blocks were freed -- no leaks are possible.

real    142m53.138s
user    139m9.606s
sys     0m37.606s

Hooray!!! But a 3min run becomes 2+hours run. Can it be faster?

Connecting to Windows Share Folder using SMBFS in FC6

Posted in

My LANDISK Pro provides windows share folder service, SMB server. However, connecting to the folder using CIFS gives error:

mount error 20 = Not a directory

Old command smbmount suppose to work well with old SMB server. However, smbmount no longer comes with FC6. Hence, you'll need to compile it from source. In order to use smbmount, you'll need the kernel support for SMBFS.

# Check if SMBFS is currently enabled.
$ cat /proc/filesystems

# Enable SMBFS if it is not found.
$ modprobe smbfs

If it can't find the kernel module smbfs.ko, you'll need to look for how to include SMBFS kernel module for your kernel. Typically, I just re-compile the kernel from source with the SMBFS enabled. You may try to find smbfs.ko from somewhere else. However, the kernel version and gcc version used to compile the smbfs.ko should match exactly your own kernel version.

$ yum install fedora-rpmdevtools yum-utils cups-devel
$ rpm -Uvh samba-3.0.23c-2.src.rpm
$ cd /usr/src/redhat/SPECS
$ rpmbuild -bp --target $(uname -m) samba.spec
$ cd /usr/src/redhat/BUILD/samba-3.0.23c/source
$ ./configure --prefix='' --with-fhs --with-smbmount
$ make include/proto.h bin/smbmnt bin/smbmount bin/smbumount
$ cp bin/smbmnt bin/smbmount bin/smbumount /bin

The commands smbmount, smbumount appear in /usr/src/redhat/BUILD/samba-3.0.23c/source/bin. I can now connect to the LANDISK Pro SMB server.

# Mount
$ smbmount //SMBSERVER/SHAREFOLDER MOUNTPOINT -o fmask=600,dmask=700

# Unmount
$ smbumount MOUNTPOINT

See the details in SMBFS support for Fedora Core 5 Linux aka FC5

Chinese Input using SCIM

Posted in

GTK_IM_MODULE=scim gedit
use ctrl-space

Firewall Ports for Ganglia

Posted in

# Firewall ports for gmond
8649:udp
8649:tcp

# Firewall ports for gmetad
8652:tcp

In gmetad.conf, set "trusted_hosts 127.0.0.1 MYHOSTNAME", where MYHOSTNAME can be a hostname or IP.

Incremental Backup using Tar

Posted in
# Backup a .tgz
$ tar zcvf backup.tgz backup/
backup/
backup/main.c
backup/main.f90

# Update files.
$ touch backup/main.c

# Incremental backup.
# 2 options:
# Option 1: Backup only files newer than the specified date and time.
$ tar --newer-mtime "20060210 10:22:00" -zcvf backup-inc1.tgz backup
tar: Treating date `20060210 10:22:00' as 2006-02-10 10:22:00 + 0 nanoseconds
backup/
backup/main.c
tar: backup/main.f90: file is unchanged; not dumped

# Option 2: Backup only files newer than backup.tgz.
$ tar --newer-mtime ./backup.tgz -zcvf backup-inc1.tgz backup
backup/
backup/main.c
tar: backup/main.f90: file is unchanged; not dumped

# Restore backups.
$ tar zxvf backup.tgz
backup/
backup/main.c
backup/main.f90

$ tar zxvf backup-inc1.tgz
backup/
backup/main.c

However, these do not handle folders that have been removed.

Linux 2.6 Scheduling Algorithm Sketch

Posted in

Scheduling classes:

  • Real-time FIFO
  • Real-time RR
  • Conventional time-shared

Processes running in conventional time-shared:

  • Static priority, [Tex]sp \in [100,139] \Rightarrow[/Tex] use to compute quantum duration, [Tex]Q[/Tex].
    [Tex]
    Q = \left\{ \begin{array}{ll}
    (140 - sp) \times 20 & \mbox{if sp < 120} \\
    (140 - sp) \times 5 & \mbox{if sp \geq 120}
    \end{array} \right.
    [/Tex]
  • Dynamic prority, [Tex]dp = \max(100, \min(sp - bonus + 5, 139))[/Tex] where [Tex]bonus \in [0,10][/Tex]
    • Bonus is computed based on the process average sleep time. Effectively, a process sleeps more will get more bonus, utilizes CPU will decrease its bonus.
    • Use with static priority to determine if a task is interactive ([Tex]dp \leq 3 \times sp / 4 + 28[/Tex]).
    • Dynamic priority is looked up by scheduler to select a new process to run.
  • Active & expired processes
    • When a process uses up a quantum, if the process is active batch, it will be transferred to expired list; if the process is active interactive, it will usually remain in active list.
    • An active interactive process will be transferred to expired list if the eldest expired process waited for a long time, or has higher static priority.

Processes running in real-time:

  • Real-time priority [Tex]\in[/Tex] [1,99]
  • Always favor higher priority runnable processes.
  • Always active.
  • Time quantum depends on static priority.
  • Does not calculate dynamic priority.

Priority array:

  • Maintains active and expire priority array.
  • For each priority in a priority array, it maintains a list of associated processes.
  • When the active priority array becomes empty, the scheduler can just swap the active and expire arrays with merely pointer assignments.

Reference:

  1. Linux Kernel Development by Robert Love
  2. Understanding the Linux Kernel by Daniel P. Bovet, Marco Cesati

Last Day in a Research Institute

Posted in

Have been working in a research institute for 3 years. Today is my last day of service in the institute. Now, .... relax ~~~ :) Misc work is off. Next Monday, I'll start a new challenge working on something new, yet my knowledge is directly applicable. :)

What I learn in these 3 years:

Use the right tools to solve the right problems ... if you find the right problems. Otherwise, just enjoy your life! ;)

Syndicate content