Posted in System Programming

Linux kernel development – part 2

IA – 32 Condensed

In this part of the tutorial , we will look at  IA -32 system architecture in brief . I would recommend anyone reading this blog to read the IA-32 system programmers manual . But I am planning to provide some links for quick reference .  I should not reproduce work that others have done very well. So here are the links

That’s all for now. I may edit this some time later 🙂

Posted in System Programming

Linux kernel development – part 1

I will provide a hands on guide on dissecting and learning the Linux kernel . But I am busy with work and so forth and It may not be able to post in regular way. I however will not spoon feed and I will just be providing general guidelines. Also I will covering the linux kernel specific to the ia-32 platform .

Getting Started — Compiling the Linux Kernel

Download the newest linux kernel from sure that you have newer version of gcc. To find out the current gcc version ,type
gcc --version.
To extract do ,
tar -xvf linux-2.6xx.tar

and make your choices and save and exit.

If do not have ncurses library installed
make config

if present type
make menuconfig

For a qt based utility type
make xconfig

for gtk based type
make gconfig

if(kernel series is 2.4 )
make depend

Now finally build the kernel
make modules (for building modules)

Thus your kernel is made.Installation of newer kernel is bootloader specific grub has a different way,lilo has a different way.But the basic idea is same.For older kernel’s 2.2 vesrions etc we can put this kernel image directly into floppy for testing

Files and Directories to peek at

After extracting and compiling the kernel code, it’s time to peek at the different directories.
Lets discuss them
1)arch -Architecture dependent code
2)cryto -crypto API
4)fs -The Virtual File System Implementation
5)init -the boot process and initialization
6)ipc-Inter process Communication
7)lib -Routines..
8)kernel -core systems
9)mm-Memory management

Brief on gcc inline assembly

The basic gcc inline assembly format is as follows

asm  (
<IA 32 instructions >:
<output > :
<input >:

you can search the net in detail on how to use inline assembly with gcc.

Frequently used data structures in kernel

  • Linked Lists   :-  See  /include/linux/list.h.The C language does not enforce type safety, Linux kernel provides set of macros for CRUD operations on a linked list
  • Trees             :-    Linux kernel uses balanced trees  ( RED BLACK TREE) in memory management . We will see this later

In Part2 we will focus more on the x86 architecture

Posted in General Programming

GUI toolkits compared

GUI Toolkits Compared

I have worked with few UI libraries during my college days (late night hackwork !). Although It has months since i really coded something in C/C++ . Here is my opinion on most of the UI frameworks ( choices available  :)   ) .

(a) Win32 API , GDI (user32.dll)
This was the most difficult to work with initially . I initially found it more difficult to work with than X , with strange typedef’s and cumbersome hungarian Notation etc . But once you get the hang of it , its quite easy . But getting the hang of it may take some time . You may look at Charles Petzold programming Windows for more information.(Works only on Windows AFAIK , or may be Wine and ReactOS )

(b) MFC
MFC is quite friendly . You can make ui’s pretty quickly and easily . But if you follow one of those ”
teach yourself MFC in xx days ” , you might get stuck at some point of time . You should start from the ground up without using the wizards provided and then later switch to wizards after you get more advanced . It also provides many features (Document View Architecture , to name a few ) and most developers usually do not properly utilize them :(  . Works only on Windows AKIK , or may be Wine and ReactOS )

The Gimp”s toolkit . It was initially made for the development of the GNU Image manipulation program or the GIMP . Its very easy to write ui’s in GIMP and now you have glade available . The gimp website provides sufficent documentation and its pretty cool ! . The downside of gtk is that , its strong only in *nix platforms . The ui elements may look a touch different depending upon the platform .

Its yet another cool framework which i have worked with. Its pretty impressive , ui elements look the same in all platforms . But the downside of fox is that it has a slightly steeper learning curve compared to Gtk , and it somewhat mimics MFC in its API .

QT is the best i guess in terms of quality and portability , but qt has a confusing license . Other than that its awesome .It competes with MFC in ease of use and beats it completely in portability   . It boasts of a signal — connect sort of thing , but there is nothing novel in it .

its pretty good as well . its easy to use , but need root privilleges ,its quite buggy as well

Easy to use multiplatform gaming framework

(h)SDL- Simple DirectMedia Layer
Same as Allegro

Honestly its initially easier to learn Xlib , than Win32 API . But it only provides barebones functionality . There is an autoritative X book by main authours themselfves. I havent coded in Xlib for the past 3 years , so forgot most of it . Also if you have experience programming Windows , programming X should not be too difficult .

There are others as well , but I will stop for the time being …….