Tuesday, March 01, 2005

What is Linux? and a bit of Linux kernel hacking

What is Linux?

Linux Kernel
At the lowest level, every Linux system is based on the Linux kernel — the very low-level software that manages your computer hardware, multi-tasks many programs that are running at any given time, and other such essential things. These low-level functions are used by other programs, so their authors can focus on the specific functionality they want to provide. Without the kernel, your computer is a very expensive doorstop. It has all of the features of a modern operating system: true multitasking, threads, virtual memory, shared libraries, demand loading, shared, copy-on-write executables, proper memory management, loadable device driver modules, video frame buffering, and TCP/IP networking.


Linux OS
Most often, the name "Linux" is used to refer to the Linux Operating System. An OS includes the kernel, but also adds various utilities — the kinds of programs you need to get anything done. For example, it includes a shell (the program that provides a command prompt and lets you run programs), a program to copy files, a program to delete files, and many other odds and ends. Some people honor the request of Richard Stallman and the GNU Project, and call the Linux OS GNU/Linux, because a good number of these utility programs were written by the GNU folks.


Distributions of Linux
Finally, software companies (and sometimes volunteer groups) add on lots of extra software, like the XFree86 X Window System, Gnome, KDE, games and many other applications. These software compilations which are based on the Linux OS are called Linux distributions.

cth-

Debian Linux
Red Hat Linux
Slackware Linux
Mandrake Linux
Suse Linux


/*Sekarang Jom kita godek Linux lebih mendalam*/

Linux Kernel Module
What exactly is a kernel module? Modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system. For example, one type of module is the device driver, which allows the kernel to access hardware connected to the system. Without modules, we would have to build monolithic kernels and add new functionality directly into the kernel image. Besides having larger kernels, this has the disadvantage of requiring us to rebuild and reboot the kernel every time we want new functionality.


/*
* hello-1.c - Modul teras paling senang.
*/
#include /* Diperlukan untuk semua modul */
#include /* Diperlukan untuk KERN_ALERT */

int init_module(void)
{
printk("<1>Hello world 1.\n");

/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}

void cleanup_module(void)
{
printk(KERN_ALERT "Selamat tinggal dunia 1.\n");
}



Modul di atas tiada lain hanyalah fungsi kosong. Tidak membawa apa-apa kesan kepada kernel.Ini adalah percubaan samada modul ini berjaya dimasukkan ke dalam kernel atau tidak. Ada banyak yang perlu diterangkan dalam coding di atas. Mengapa 'printk' dan tidak 'printf'? Apa itu KERN_ALERT? Jumpa lagi.InsyaAllah.Oh ya, dalam #include tu ada 2 header yg sepatutnya ada. linux/module.h dan linux/kernel.h



Dipetik daripada

- The Linux Kernel Module Programming Guide
Peter Jay Salzman
Michael Burian
Ori Pomerantz

- The Linux FAQ
David C. Merrill
david -AT- lupercalia.net
2003-09-19
http://en.tldp.org/FAQ/Linux-FAQ/index.html

Wallahu'alam.

p/s Entry ini didedikasikan kepada kawan2 FIST - Faris aka Putra, Shah, Yus, Daus, Bobo.

3 comments:

Al-Farisi said...

ehehe.. agak terharu sebab entry ni ditujukan untuk member2 FIST Aben. Putra rase saudara Aben ni dah samapai tahap Mahaguru Linux dah ni. hidup Linux!!! ehehe...

Putra sebenarnye dah lame pindah rumah baru. ekekeke... jemputlah ke http://putraloneheart.blogspot.com

Anonymous said...

i've tried so hard.....
huhuhuhuh....
unfortunately, i'm not ur FIST frenz...

-AuR-

Stridz said...

Eh..apa pulak Putra, saya ni baru berjinak-jinak dgn Linux...byk lagi tak tahu dan kena belajar.

AuR, nk jadi kawan FIST sy kenalah tukar fakulti.Hehe