Skip to main content

Sponsors

Linux

Edit Compilation Flags When using CPAN

Posted in

Edit /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Config_heavy.pl

Look for:

  • -Doptimize
  • lddlflags=
  • optimize=

The default flag -mtune=generic doesnt work with my GCC compiler, hence I change all of these to -mtune=athlon64.

Publish GIT Repository using GITWEB

Posted in

# Setup gitweb

$ tar jxvf git-1.5.1.2.tar.bz2  # Extract git source
$ cd git-1.5.1.2
$ make GITWEB_PROJECTROOT="/absolute/path/to/git/repository/container" \
        GITWEB_CSS="/gitweb/gitweb.css" \
        GITWEB_LOGO="/gitweb/git-logo.png" \
        GITWEB_FAVICON="/gitweb/git-favicon.png" \
        bindir=/usr/local/bin \
        gitweb/gitweb.cgi
Edit $GIT in gitweb.cgi to point to git.
[Optional] Edit $site_name in gitweb.cgi.
[Optional] Create a project list file and edit $projects_list in gitweb.cgi.
$ mkdir /var/www/cgi-bin/gitweb
$ cp -fv gitweb/gitweb.cgi /var/www/cgi-bin/gitweb
$ mkdir /var/www/html/gitweb
$ cp -fv gitweb/gitweb.{cgi,css} gitweb/git-{favicon,logo}.png /var/www/html/gitweb

# Setup Apache Web Server
Add if they do not exist in the httpd.conf file:

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
    Options Indexes FollowSymlinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Access Project Site at: http://host/cgi-bin/gitweb/gitweb.cgi

Code Version Control: svn vs git

Posted in

Get svn
Get git

Pros of svn:

  • Good GUI tortisesvn for running svn commands.
  • Partial checkout: Choose any sub-dir to checkout as a working copy.
  • Centralized server: Save space by maintaining single global repository.
  • Portable to Windows and Linux/Unix.
  • File-based tracking: More detailed tracking of files.

Cons of svn:

  • Centralized server:
    • When the server/network is down or damaged, you cant access your repository, or loss your repository forever.
    • Potential access conflicts to shared files. Frankly, I dont like people manipulating my repository.
    • Flat checkout: Checkout from remote repository transfers file by file, which can be quite slow through the network, especially dealing with many small files.
  • Limited move/rename file: You'll need to commit moved/renamed files before manipulating them.
  • No good mechanism for pulling or pushing updates to other repositories.
  • .svn folders are everywhere in a working copy. Hate this when I want to copy a folder to somewhere.
  • File-based tracking: More overhead in tracking.

Pros of git:

  • Good GUIs qgit, citool available for visualizing branches and histories.
  • Decentralized: If a server is gone, you have nothing to loss in your local copy.
  • Space efficient: Single git repository is typically much smaller than a svn repository.
  • Compressed checkout: Checkout from remote repository transfers data in compressed format, hence more network friendly.
  • Better ways of file moving/renaming/deleting, but this is subjective.
  • Simple branch & merge mechanism, for both local and remote repositories.
  • Easy branch switching: Short command to switch a working copy from a branch to another branch (with little CPU), requires no folder duplications too. Compared to svn, you need to know which folder to look for for a particular branch. To create a branch in svn, you basically duplicate entire branching folder.
  • Requires no user account. Simply publicize your repository, and it's up to anyone to pull your updates. Not really a feature, but git mode of working supports this well.
  • Tree-based tracking: For low tracking overhead.

Cons of git:

  • Full checkout: Must checkout entire working copy, as well as the entire repository (including all history).
  • Multiple repositories: A full repository for each checkout.
  • Lonely merging: I have to resolve conflicts by myself when pulling updates from remote repositories. (In svn, the one causing the conflicts will fix the problems.) You can settle conflicts with the authors if you can command them :).
  • Use Linux/Unix File System specific features such as hard link in some cases, arguably a pro feature for space efficiency, but trading off portability. Needs Cygwin for Windows, which results in poor performance.
  • Missing file-based tracking: Doesn't track file copy operations. We may not know the source copy of a file. It probably takes more time to obtain file specific information, e.g. history of a file.

Compiling Yafray on AMD64 Running FC6

Posted in

After reading some documents and hacking on the scons .py codes. I found an easy way to compile Yafray in AMD64 FC6.

In the file SConstruct, merely edit the following line

common_env=Environment(ENV=os.environ, CXXFLAGS = config.cxxflags);

to

common_env=Environment(ENV=os.environ, CXXFLAGS = config.cxxflags, SHLINK = "g++", LINK = "g++");

The compilation will then use g++ as the linker with shared library.

If the compilation cannot find the 64bit OpenEXR library, edit the line in file linux-settings.py

def get_libpath(args): return [ exr.PATH + "/lib" ]

to

def get_libpath(args): return [ exr.PATH + "/lib64" ]

Then compile as usual: scons -j 2


Obsolete

Given yafray-0.0.9.tgz:

# Install scons as needed by yafray. Yafray no longer uses GNU make.
$ yum install scons
$ tar zxvf yafray-0.0.9.tgz
$ cd yafray

# Start compilations
$ scons
ld -shared -no_archive -o src/yafraycore/libyafraycore.so src/yafraycore/bound.os src/yafraycore/buffer.os src/yafraycore/yafsystem.os src/yafraycore/tools.os src/yafraycore/camera.os src/yafraycore/color.os src/yafraycore/filter.os src/yafraycore/matrix4.os src/yafraycore/object3d.os src/yafraycore/triangletools.os src/yafraycore/mesh.os src/yafraycore/kdtree.os src/yafraycore/triclip.os src/yafraycore/reference.os src/yafraycore/renderblock.os src/yafraycore/scene.os src/yafraycore/forkedscene.os src/yafraycore/threadedscene.os src/yafraycore/ipc.os src/yafraycore/ccthreads.os src/yafraycore/noise.os src/yafraycore/background.os src/yafraycore/sphere.os src/yafraycore/texture.os src/yafraycore/metashader.os src/yafraycore/targaIO.os src/yafraycore/triangle.os src/yafraycore/vector3d.os src/yafraycore/photon.os src/yafraycore/params.os src/yafraycore/HDR_io.os src/yafraycore/spectrum.os -lpthread
ld: /usr/lib64/libpthread.a(pthread_create.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib64/libpthread.a: could not read symbols: Bad value
scons: *** [src/yafraycore/libyafraycore.so] Error 1
scons: building terminated because of errors.

I recompile yafray with -fPIC does not help at all. Replace 'ld' by 'g++' solves the linking problem. But I dont know how to do that using scons! Even if I create libyafraycore.so manually, running scons will still try to ld!

Out of no choice, I use a quick and dirty workaround. Generate the list of commands with dry run option. Replace the 'ld' commands with 'g++'. Then execute the list of commands.

$ scons -n > run
$$ Edit run, replace 'ld ' by 'g++ '. Using vi, run ':%s/ld /g++ '
$$ Remove scons outputs and -no_archive in run if you dont like to see warning outputs.
$ chmod +x run
$ ./run
$ ls src/yafray

I got the 'yafray' executable file created. Installation is not done yet. We still have to install yafray .so library.

# You can install the .so into /usr/lib or /usr/local/lib.
$ mkdir /usr/local/lib/yafray
$ cp src/backgrounds/*.so src/lights/*.so src/shaders/*.so  /usr/local/lib/yafray/
$ cp src/yafraycore/*.so src/interface/*.so /usr/local/lib/
# Remember to add /usr/local/lib into ld.so.conf.d/
$ ldconfig
# You can install yafray into /usr/bin or /usr/local/bin
$ cp src/yafray /usr/local/bin

DONE!!! scons disappointed me.

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.

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
Syndicate content