Follow us on facebook

Tuesday 26 February 2013

Domian Ownership

This post confirms my ownership of the site and that this site adheres to google adsense program policies and terms and conditions.

Monday 25 February 2013

Linux File System


FILE SYSTEM
File system divided into two categories:
§  User data - stores actual data contained in files
§  Metadata - stores file system structural information such as superblock, inodes, directories

Understanding UNIX / Linux file system Superblock
Let us take an example of 20 GB hard disk. The entire disk space subdivided into multiple file system blocks. And blocks used for what?

Unix / Linux filesystem blocks

The blocks used for two different purpose:
1.    Most blocks stores user data aka files (user data).
2.    Some blocks in every file system store the file system's metadata. So what the hell is a metadata?
In simple words Metadata describes the structure of the file system. Most common metadata structure are superblock, inode and directories. Following paragraphs describes each of them.

Superblock

Each file system is different and they have type like ext2, ext3 etc. Further each file system has size like 5 GB, 10 GB and status such as mount status. In short each file system has a superblock, which contains information about file system such as:
§  File system type
§  Size
§  Status
§  Information about other metadata structures

Inodes

 

The inode (index node) is a fundamental concept in the Linux and UNIX filesystem. 

 Each and every file under Linux (and UNIX) has following attributes:
=> File type (executable, block special etc)
=> Permissions (read, write etc)
=> Owner
=> Group
=> File Size
=> File access, change and modification time (remember UNIX or Linux never stores file creation time, this is favorite question asked in UNIX/Linux sys admin job interview)
=> File deletion time

 

All the above information stored in an inode. In short the inode identifies the file and its attributes (as above) . Each inode is identified by a unique inode number within the file system. Inode is also know as index number.



How do I see file inode number?

You can use ls -i command to see inode number of file
$ ls -i /etc/passwd
Sample Output
32820 /etc/passwd
You can also use stat command to find out inode number and its attribute:
$ stat /etc/passwdOutput:
File: `/etc/passwd'
Size: 1988            Blocks: 8          IO Block: 4096   regular file
Device: 341h/833d       Inode: 32820       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2005-11-10 01:26:01.000000000 +0530
Modify: 2005-10-27 13:26:56.000000000 +0530
Change: 2005-10-27 13:26:56.000000000 +0530

 

 


Tuesday 19 February 2013

Boot Loader



BOOT LOADER
A boot loader, also called a boot manager, is a small program that places the operating system (OS) of a computer into memory. When a computer is powered-up or restarted, the basic input/output system (BIOS) performs some initial tests, and then transfers control to the master boot record (MBR) where the boot loader resides. 

How does GRUB work?

 When a computer boots, the BIOS transfers control to the first boot device, which can be a hard disk, a floppy disk, a CD-ROM, or any other BIOS-recognized device. We'll concentrate on hard disks, for the sake of simplicity.
 The first sector on a hard is called the Master Boot Record (MBR). This sector is only 512 bytes long and contains a small piece of code (446 bytes) called the primary boot loader and the partition table (64 bytes) describing the primary and extended partitions.
 By default, MBR code looks for the partition marked as active and once such a partition is found, it loads its boot sector into memory and passes control to it.
GRUB replaces the default MBR with its own code.
 Furthermore, GRUB works in stages.
Stage 1 is located in the MBR and mainly points to Stage 2, since the MBR is too small to contain all of the needed data.
Stage 2 points to its configuration file, which contains all of the complex user interface and options we are normally familiar with when talking about GRUB. Stage 2 can be located anywhere on the disk. If Stage 2 cannot find its configuration table, GRUB will cease the boot sequence and present the user with a command line for manual configuration.
Stage 1.5 also exists and might be used if the boot information is small enough to fit in the area immediately after MBR.
 The Stage architecture allows GRUB to be large (~20-30K) and therefore fairly complex and highly configurable, compared to most bootloaders, which are sparse and simple to fit within the limitations of the Partition Table.
For Linux, the two most common boot loaders are known as LILO (LInux LOader) and LOADLIN (LOAD LINux). An alternative boot loader, called GRUB (GRand Unified Bootloader), is used with Red HatLinux. LILO is the most popular boot loader among computer users that employ Linux as the main, or only, operating system. The primary advantage of LILO is the fact that it allows for fast boot-up. LOADLIN is preferred by some users whose computers have multiple operating systems, and who spend relatively little time in Linux. LOADLIN is sometimes used as a backup boot loader for Linux in case LILO fails. GRUB is preferred by many users of Red Hat Linux, because it is the default boot loader for that distribution.
GRUB (GRand Unified Bootloader) is a boot loader package developed to support multiple operating systems and allow the user to select among them during boot-up.
 GRUB is a bootloader (can also be spelled boot loader) capable of loading a variety of free and proprietary operating systems. GRUB will work well with Linux, DOS, Windows, or BSD. GRUB stands for GRand Unified Bootloader.
GRUB can be run from or be installed to any device (floppy disk, hard disk, CD-ROM, USB drive, network drive) and can load operating systems from just as many locations, including network drives. It can also decompress operating system images before booting them.
What about LILO?
You may have heard about another Linux bootloader called LILO (stands for LInux LOader). While a sensible option for many Linux users, I believe that GRUB is a better choice, for several reasons:
1.      LILO supports only up to 16 different boot selections; GRUB supports an unlimited number of boot entries.
2.      LILO cannot boot from network; GRUB can.
3.      LILO must be written again every time you change the configuration file; GRUB does not.
4.      LILO does not have an interactive command interface.

PPT Linux Directory Structure with Examples


PPT Linux Directory Structure with Examples

Computer Graphics Programs in 'C'


Computer Graphics Programs in 'C'

IT companies Information for Training & Career

IT companies Information

Aptitude Perepration for CSE(All Subjects)


Aptitude Question & Answers for CSE(All Subjects)

Assembler Introduction



An assembly language is a low-level programming  language for computers, microprocessors, microcontrollers, and other programmable devices in which each statement corresponds to a single machine language instruction. An assembly language is thus specific to a certain physical (or virtual) computer architecture, in contrast to most high-level programming languages, which, ideally, are portable.
Assembly language allows the use of symbolic representation for machine operation codes(usually called mnemonics), memory locations, registers and other parts of an instruction.
A utility program called an assembler is used to translate assembly language statements into the target computer's machine code.
Many advanced assemblers offer additional mechanisms to facilitate program development, control the assembly process, and aid debugging. In particular, most modern assemblers include a macrofacility (described below), and are called macro assemblers.
Assembler
Typically a modern assembler creates object code by translating assembly instruction mnemonics into opcodes, and by resolving symbolic names for memory locations and other entities.[1] The use of symbolic references is a key feature of assemblers, saving tedious calculations and manual address updates after program modifications. Most assemblers also include macro facilities for performing textual substitution—e.g., to generate common short sequences of instructions as inline, instead of called subroutines.
Basic Assembler functions:
The assembler is responsible for translating the assembly language program into machine code. When the source language is essentially a symbolic representation for a numerical machine language, the translator is called an assembler  and the source language is called an assembly language. A pure assembly language is a language in which each statement produces exactly one machine instruction figure below show the assembler functions.
1 .  Translate mnemonic opcodes to machine language.
2 .  Convert symbolic operands to their machine addresses.
3 .  Build machine instructions in the proper format.
4 .  Convert data constants into machine representation.
5 .  Error checking is provided.
6 .  Changes can be quickly and easily incorporated with a reassembly.
7 .  Variables are represented by symbolic names, not as memory locations.

Assembly language statements are written one per line. A machine code program thus consists of sequence of assembly language statements, where each statement contains a mnemonic. Each line of an assembly language program is split into four fields, as show below:
LABEL       OPC ODE     OPERAND        COMMENTS
Label: it is an  identifier and optiona l field. Labels are used extensively in  programs to reduce reliance upon programmers remembering where data or code is located. The maximum length of label differs between assemblers. Some accept upto 32 characters   long, other only four
characters. A label when declared is suffixed by   a colon and begins with a valid character (A..Z)
For example
START: LDAA #24 H
Here, the label START is equal to the address of instruction
LDAA #24 H
An advantage of using labels is that inserting or rearranging code stat elements do not necessitate reworking actual machine instructions .
Opcode: this field contains a mnemonic. Opcode stands for operation code  i.e. a machine code instruction. The opcode may also require additional information i.e. operands.
Operand: this field consists of additional information or data that the opcode  requires. In certain types of addressing modes, the operand is used to specify
-  Constants or labels
-  Immediate data
-  Data contained in another accumulator or register .
-  An address
The figure below   shows the machine instruction format

Assembly Language Statements
It consists of three types of statements:
1 - Imperative
2 - Declaration
3 - Assembler directive
Imperative statement:   it indicates an action to be performed during the execution of the assembled program. Imperative programs focus on how to solve a problem popular imperative languages such as C and Pascal are based on side effects on memory. Each imperative statement translates into one machine instruction.  An imperative statement indicates an action to be performed during the execution of the assembled program. Each imperative statement typically translates into one machine instruction.

Declaration statement: it focus on what the problem is and leave solution mechanism  up to the language implementation. Within the declarative paradigm, most notable are the function languages such as lisp. Declarative lang uages are typically quite abstract and hence can be harder to implement efficiently.
The syntax of declaration statements is as follows:

 
The DS (short for declare storage) statement reserves areas of memory and asso­ciates names with them. Consider the following DS statements:

The first statement reserves a memory area of 1 word and associates the name A with it. The second statement reserves a block of 200 memory words. The name G is associated with the first word of the block. Other words in the block can be accessed through offsets from G, e.g. G+5 is the sixth word of the memory block, etc.
The DC (short for declare constant) statement constructs memory words contain­ing constants. The statement

associates the name ONE with a memory word containing the value ‘ 1′. The program­mer can declare constants in different forms–decimal, binary, hexadecimal, etc. The assembler converts them to the appropriate internal form.

Assembler directive: assembler directives instruct the assembler to perform certain  actions during the assembly of a program. They can be used to declare variables, create storage space for results, to declare constants. The following assembler directives are used in the program:
1 -  START-specify name and starting address for the program. START <constant>
2 -  END-indicate the end of the source program and specify the first execut able instruction in the program.  END  [ <operand spec> ]
3 -  BYTE-generate character or hexadecimal constant, occupying as many bytes as needed to represent the constant.
4 -  WORD-generate one word integer constant.
Assembler directives instruct the assembler to perform certain actions during the assembly of a program. Some assembler directives are described in the following.
START <constant>
This directive indicates that the first word of the target program generated by the assembler should be placed in the memory word with address<constant>.
END [<operand spec>]
This directive indicates .the end of the source program. The optional <operand spec> indicates the address of the instruction where the execution of the program should begin. (By default, execution begins with the first instruction of the assembled program.).


Advantages of assembly language
1 .  Reduced errors.
2 .  Faster translation times.
3 .  Changes could be made easier and faster.
Disadvantages
1 .  Many instructions are required to achieve small tasks.
2 .  Source programs tend to be large and difficult to follow.
3 .  Programmer requires knowledge of the processor architecture and instruction set.
4 .  Programs are machine dependent, requires complete rewrites if the hardware is changed.