Latex tip - don't forget to run bibtex

If you compile your .tex file and end up seeing an error ".bbl could not be located", after you open the .dvi file generated, you will notice that the reference section is missing. This is because in the first run LaTeX created the .aux file which needs to be fed to Bibtex which will generate the .bbl file.

So,

#1 $ latex source.tex
#2 $ bibtex source.aux (generated in Step #1)
#3 $ latex source.tex


Kile does this in one shot, it is able to figure out that bibtex needs to be run in the middle.

Q: Is there any another way to do this in one shot from the command line?

Sqlite

SQLite is a C library that implements an SQL database engine. Programs that link with the SQLite library can have SQL database access without running a separate RDBMS process. (src: aptitude show sqlite)

To install sqlite on Ubuntu

$ sudo aptitude install sqlite3

Help
SQLite documentation,
SQLite in 5 minutes or less,
Using SQLite for simple database storage
C\C++ API reference

Ubuntu 9.10 is here



Ubuntu 9.10 Karmic Koala is here. Download now or upgrade from existing installation.

Check the upgrade notes before going for an upgrade.

[Source: Upgrading to Ubuntu 9.10]

  1. Start System/Administration/Update Manager
  2. Click the Check button to check for new updates
  3. If there are any updates to install, use the Install Updates button to install them, and press Check again after that is complete
  4. A message will appear informing you of the availability of the new release
  5. Click Upgrade
  6. Follow the on-screen instructions
On the blog-sphere

Latex Math symbols


A good online reference to the different Math symbols in LaTeX. The file A.tex has all the symbols for ready reference.

Download the file
$ latex A.tex

Open DVI file in Evince or Okular.

Tools

You would need to install latex(TeX-Live). Also, KBibTex, Kile and Lyx are highly recommended tools

sudo aptitude install texlive-full kile kbibtex lyx

Ubuntu LaTeX help guide

Shared libraries

Remember

gcc -shared -Wl,-soname,your_soname -o library_name file_list library_list

Which means, if you have a.c and b.c

gcc -fPIC -g -c -Wall a.c
gcc -fPIC -g -c -Wall b.c
gcc -shared -Wl,-soname,libmystuff.so.1 \
-o libmystuff.so.1.0.1 a.o b.o -lc


Then create the symbolic links to libmystuff.so and libmystuff.so.1 from libmystuff.so.1.0.1 and don't forget to add the libraries to the standard path /usr/local/lib OR add the path to LD_LIBRARY_PATH before executing.

More details: Creating shared libraries
Very good How-To: Link

pthread

A very good one-shot tutorial to the POSIX thread libraries (pthread). Talks all about threading, synchronization and scheduling with example code.

Deadline scheduling for Linux kernel

A new scheduler class has been proposed for including deadline based scheduling algorithms like EDF
The public git repository is available on gitorious
git clone git://gitorious.org/sched_deadline/linux-deadline.git

Generating patches without cleaning code

Instead of generating a patch from two pristine copies of the code (one with your changes and both not compiled), it is useful to create a exclude-list of all the files that you want to ignore.

 .*
 *.lds
 *.o
 *.o.*
 *.a
 *.s
 *.ko
 *.so
 *.so.dbg
 *.mod.c
 *.i
 *.lst
 *.symtypes
 *.order
 *.elf
 *.bin
 *.gz
 *.lzma
 *.patch
 *.gcno
 tags
 TAGS
 bzImage
 vmlinux
 System.map
 Module.markers
 Module.symvers
 !.gitignore
 !.mailmap
 patches-*
 patches
 series
 exclude-list
 filefortag
 filelist
 cscope.*
 ncscope.*
 GPATH
 GRTAGS
 GSYMS
 GTAGS
 *.orig
 *~


Then create the patch

diff --exclude-from /path/to/exclude-list -urNd linux-2.6.24-hunterwala linux-2.6.24 > patch_file

Each line in exclude-list is a pattern which diff would match and ignore the files. I am having trouble excluding following directories.

include/asm
include/asm-*/asm-offsets.h
include/config
include/linux/autoconf.h
include/linux/compile.h
include/linux/version.h
include/linux/utsrelease.h
include/linux/bounds.h
include/generated


So, the -N passed to diff would treat these as new files and include them in the patch. :(

TODO: Update post once I find a better way to handle directories.

[The exclude list above has been taken from .gitignore]

Threading and parallelism

Another good series of articles found on www.embedded.com on threading and parallelism

Part 1: Parallelism and threading primer
Part 2: The threading development cycle
Part 3: Debuging and tuning multi-threaded code

Linux performance analysis for embedded system

Nice series of articles found on www.embedded.com

Part 1: Available tools
Part 2: Profiling/analysis methods and techniques

fscanf

Did not know this until yesterday.

fscanf (fptr, "%*s");
               ^^^
This reads the line from the file but does not store it in any local variable, as compared to this,

fscanf (fptr, "%s", buffer);

Handy '*' :)

Find executables

To find all the executables files

find . -type f -executable -name "whatever*"

Kernel debugging tools

While working inside the kernel you are prone to crashes, oops and complete kernel freeze. Some of these tools\methods help

1. lockdep
http://www.mjmwired.net/kernel/Documentation/lockdep-design.txt

2. netconsole
http://www.mjmwired.net/kernel/Documentation/networking/netconsole.txt

Using netconsole inside Ubuntu
https://wiki.ubuntu.com/KernelTeam/Netconsole

Another netconsole tutorial
http://www.cyberciti.biz/tips/linux-netconsole-log-management-tutorial.html

3. Debugging kernel Oops
https://wiki.ubuntu.com/DebuggingKernelOops

4. Using the built-in kernel debugger
http://oss.sgi.com/projects/kdb/
IBM tutorial (http://www.ibm.com/developerworks/linux/library/l-kdbug/) .. looks dated .. not sure if this works with 2.6.24+ kernels

5. Nice article on Kernel_Debugging_Tips

6. Another brilliant article on Kernel oops

Update: I recently posted a piece on how to use KGDB over the serial null modem cable

Print the IP of the machine at login

Wanted to know the IP address of the test machine the moment I log in. include the following in your .bashrc file.

echo "Welcome to" `hostname` "("`ifconfig eth0 | grep "inet addr:" | awk -F: '{print($2)}' | sed "s/ /:/g" | awk -F: '{print($1)}' `")"

Not very efficient use of sed and awk :(