Compiling a kernel source code and use it as the kernel of your linux OS.

get latest kernel source:

cd /tmp wget

extract .tar file:

# tar -xjvf linux-2.6.37.tar.bz2 -C /usr/src
# cd /usr/src

Configure kernel respected to your computer:

# make menuconfig

Compile Kernel:

make</code>Compile Kernel modules:<code> make modules

Install the kernel modules as a root user:

$su -
#make modules_install

Install kernel:

#make install

Create initrd image for Grup program for using at boot time initialization:

#cd /boot
#mkinitrd -o initrd.img-2.6.37 2.6.37

Modify Grup config. file:

# update-grup

Reboot computer:

That’s all:)


"grep" Tool.

It is a new tool that I discover and I guess it is also really beneficial for you (The CS’ers). It is to search a String pattern in all kind of documents and the tool gives you the all matching documents and the line numbers of matchings of these documents.
Here is the basic structure of the usage;

grep [options] pattern filieTypes

[options] side to activate some extra functionalities. You can see the documentation in terminal by typing “grep –help”

Here also an example which search “sys_getpid” string in the all file types in directories with subdirectories.

erogol@ubuntu:~/Desktop/linux-2.6.37$ grep -Hrni sys_getPid *
arch/microblaze/kernel/syscall_table.S:27: .long sys_getpid /* 20 */
arch/mips/kernel/scall64-o32.S:227: PTR sys_getpid /* 4020 */
arch/mips/kernel/scall64-64.S:168: PTR sys_getpid
arch/mips/kernel/scall64-n32.S:163: PTR sys_getpid
arch/mips/kernel/scall32-o32.S:259: sys sys_getpid 0 /* 4020 */
arch/avr32/kernel/syscall_table.S:36: .long sys_getpid /* 20 */
arch/xtensa/include/asm/unistd.h:281:__SYSCALL(120, sys_getpid, 0)
arch/xtensa/platforms/iss/include/platform/simcall.h:39:#define SYS_getpid 20
arch/s390/kernel/syscalls.S:31:SYSCALL(sys_getpid,sys_getpid,sys_getpid) /* 20 */
arch/sparc/kernel/systbls_64.S:25:/*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid16, sys_getuid16
arch/sparc/kernel/systbls_64.S:101:/*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid, sys_getuid
arch/sparc/kernel/systbls_32.S:23:/*20*/ .long sys_getpid, sys_capget, sys_capset, sys_setuid16, sys_getuid16
arch/frv/kernel/entry.S:1212: .long sys_getpid /* 20 */
arch/x86/include/asm/unistd_64.h:98:__SYSCALL(__NR_getpid, sys_getpid)
Binary file arch/x86/kernel/syscall_64.o matches
arch/x86/kernel/syscall_table_32.S:22: .long sys_getpid /* 20 */
Binary file arch/x86/kernel/built-in.o matches
Binary file arch/x86/built-in.o matches
arch/x86/ia32/ia32entry.S:533: .quad sys_getpid /* 20 */
Binary file arch/x86/ia32/built-in.o matches
Binary file arch/x86/ia32/ia32entry.o matches
arch/m68k/kernel/entry.S:451: .long sys_getpid /* 20 */
arch/parisc/hpux/entry_hpux.S:51: ENTRY_NAME(sys_getpid) /* 20 */
arch/sh/kernel/syscalls_32.S:39: .long sys_getpid /* 20 */
arch/sh/kernel/syscalls_64.S:43: .long sys_getpid /* 20 */
arch/cris/arch-v10/kernel/entry.S:625: .long sys_getpid /* 20 */
arch/cris/arch-v32/kernel/entry.S:568: .long sys_getpid /* 20 */
arch/h8300/kernel/syscalls.S:37: .long SYMBOL_NAME(sys_getpid) /* 20 */
arch/ia64/kernel/fsys.S:782: data8 fsys_getpid // getpid
arch/ia64/kernel/entry.S:1489: data8 sys_getpid
arch/m32r/kernel/syscall_table.S:22: .long sys_getpid /* 20 */
arch/mn10300/kernel/entry.S:460: .long sys_getpid /* 20 */
arch/blackfin/mach-common/entry.S:1386: .long _sys_getpid /* 20 */
arch/arm/kernel/calls.S:32:/* 20 */ CALL(sys_getpid)
arch/m68knommu/kernel/syscalltable.S:41: .long sys_getpid /* 20 */

Using "strace" to see the Sys. calls executed with your written code.

“strace” is really effective utility for system administrators and coders to see the system calls that your program makes. It is really easy to use, just write to your terminal “strace programName” exp. “strace ./a.out” like ordinary compiled C code. It give output something like this; (I have interesting name of directory “01-um-getpid" includes the a.out file. Do not be confused!) <pre style="overflow: scroll;">erogol@ubuntu:~/Desktop/01-um-getpid strace ./a.out
execve(“./a.out”, [“./a.out”], [/* 39 vars */]) = 0
brk(0) = 0x186e000
access(“/etc/”, F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3c3d4d8000
access(“/etc/”, R_OK) = -1 ENOENT (No such file or directory)
open(“/etc/”, O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=123841, …}) = 0
mmap(NULL, 123841, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f3c3d4b9000
close(3) = 0
access(“/etc/”, F_OK) = -1 ENOENT (No such file or directory)
open(“/lib/”, O_RDONLY) = 3
read(3, “177ELF2113>12403561”…, 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1572232, …}) = 0
mmap(NULL, 3680296, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f3c3cf37000
mprotect(0x7f3c3d0b1000, 2093056, PROT_NONE) = 0
mmap(0x7f3c3d2b0000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x179000) = 0x7f3c3d2b0000
mmap(0x7f3c3d2b5000, 18472, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f3c3d2b5000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3c3d4b8000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3c3d4b7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3c3d4b6000
arch_prctl(ARCH_SET_FS, 0x7f3c3d4b7700) = 0
mprotect(0x7f3c3d2b0000, 16384, PROT_READ) = 0
mprotect(0x600000, 4096, PROT_READ) = 0
mprotect(0x7f3c3d4da000, 4096, PROT_READ) = 0
munmap(0x7f3c3d4b9000, 123841) = 0
getpid() = 9376
exit_group(0) = ?

The numbers that are at the end of the lines are the System Call numbers and the beginning of the lines are the sys. call names. That is all…


Here is a basic process on GDB to see the Sys. Assemble codes executed with your C Program's "main" func..

There are the input strings to your terminal in sequence. Follow the order;

gcc demo.c // it compiles and gives a.out.
gdb a.out //it starts the debugger gdb.
break main //it puts a break point to your code's main function.
run //it runs the program up to main func.
disassemble //it gives the system assemble codes.

Here is the process overview from my terminal.

erogol@ubuntu:~/Desktop/01-um-getpidgcc demo.cerogol@ubuntu:~/Desktop/01-um-getpid gdb a.out
GNU gdb (GDB) 7.2-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /home/erogol/Desktop/01-um-getpid/a.out...(no debugging symbols found)...done.
(gdb) break main
Breakpoint 1 at 0x4004f8
(gdb) run
Starting program: /home/erogol/Desktop/01-um-getpid/a.out

Breakpoint 1, 0x00000000004004f8 in main ()
(gdb) disassemble
Dump of assembler code for function main:
0x00000000004004f4 <+0>: push %rbp
0x00000000004004f5 <+1>: mov %rsp,%rbp
=> 0x00000000004004f8 <+4>: mov 0x0,%eax   0x00000000004004fd <+9>: callq  0x400400 <getpid>   0x0000000000400502 <+14>: mov0x0,%eax
0x0000000000400507 <+19>: leaveq
0x0000000000400508 <+20>: retq
End of assembler dump.
(gdb) ^CQuit

About OS!!!!

I just start a new course about Operating Systems concept so after a long time there will be some useful content in the blog about OS for sure!!! Keep up with me


Contemporary Design Issues in Programming Languages

Engineers have developed variety of programming languages until the invention of computer based technologies. At the beginning there were binary code languages then they’ve started to code higher level of languages that are more easy to have abstraction of real time actions. In addition, still engineers continue to develop new languages respected to their needs in computer field. Thus, what is the reason behind designing new languages instead of using existing ones and what are the issues behind developing modern programming languages.


1- Development on hardware technologies;
Since the developing hardware technologies, programmers are able to give some new instructions to the machines to do more complicated processes in faster ways.
For example, with the development on the multi core systems, programmers want to be able to share program actions on different cores so new programming languages gives new tools to be used on multi core systems. Java threating and C/C++ libraries are good example that support multi core processes. Joint Java also another language that was developed from Java to have concurrency support. However these popular languages are not sufficient to cover all advantages of multi-core processing. Erlang and occam-π are also good examples with different syntaxes to support multi-core. Erlang is good in this area by its nature of being functional language. Occam-pi also is a imperative language.

As can be seen one or two programming language is not enough to have fully capable language that uses all advantages of hardware so according to your priorities you have different languages or you can create your own.

2- Simplicity and performance trade off.
There are also two concepts, simplicity and performance in design of language that are conflicted. Simpler language means slower processing and more detailed languages are faster but more tricky to be used. Thus, the programs that are coded with assembly languages or directly binary codes are really fast programs but they have millions of lines codes so there are also variety of languages that goes lower level to higher level. For example C programming language is like the bridge between assembly and high level languages, thus it is used commonly in OS’s designs, compiler designs and hardware drivers. However, we sometimes do not need such complicated languages to code a basic calculator for instance so we have more simpler languages like Java or there are some languages that are called script languages (Ruby Python, Lua, Perl) to have the ability code complicated tasks with really simple codes and attach these codes to host languages such as c++, Java. Ruby is popular script language to have web applications that have database systems, Python also a popular language in web field and also it is used in executable programs, Perl purposes to give easy manipulation on text files and it is used in server side programming language in web applications. These script languages aims to support your main language with huge libraries and they generally have the interpreter systems instead of compilers so they make our tasks simple but slower since the dynamic interpretation.

3- Usage Area
There are lots of languages that supports different computer fields. For example, there are web languages such as, PHP -server side programming-, JavaScript – Browser side programming-, SQL -Database manipulation-. But most popular languages c/c++ and Java generally used for executable programs although they can be used in web by CGI programming. In addition, COBOL is a good example that is specified for data processing language especially for business application or MATLAB is designed for mathematical calculation and graphing tool, Lisp is most popular language that is functional one for AI programming.

4- Potability
Another issue to have portability in your application and sure, Java is the most common example in that way. It can be used in any environment that have Java interpreter. It can be used in web as applet, or in Linux, windows machines. It is really powerful language in that way but the problem is, Java cannot use the all power of the computer to have portable feature. Therefore, again we have the trade of between portability and performance.

5- Variety of Project’s Design Patterns
There are lots of different approaches to design a software system so there are also different languages to support such patterns. Today’s most common design approach is Object Oriented programming that is supported with popular languages; C++ (Multi-paradigm support), Java and the others; Eiffel, Smalltalk, Ruby, C#. There are also different paradigms such as Structured Programming Languages (C, ADA ,Pascal), Procedural Programming Languages (BASIC, FORTRAN), Logic Programming (LISP).

6- Safety and security
Safety and security are other concerns about programming languages. In that way the level of the language is really important since low level languages are hard to maintain and code safe codes since you need to consider detailed things so using high level ones give the developer to code more safe codes and gives more maintainable codes. For instance it is hard to code a program with C instead of Java because in C you need to deal with low level structures like pointers, addressing, garbage collection but in Java these facts are handled by the language itself. Nevertheless, again we have performance trade off. Dealing with low level language gives efficient performance.

There are lots of programming languages and there will be more of them since the requirements always change in the way of software structures and hardware structures so it is not possible to meet all these need with a single language.


Today, I was working on constructing a dynamic web page that allows user to add new paragraphs or links dynamically.

Here the basic way to add new elements to the webpage dynamically.

//we create a new paragraph element
newParag = document.createElement('p');
//we create a new text node
newText = document.createTextNode("Here the new paragraph");
//we add the text node inside the newly created paragraph element
//Assume we have a division that has id 'content' and we
//call the 'content' division and add new paragraph to it

That’s all. Have a good life… see you:)