Showing posts with label Loader. Show all posts
Showing posts with label Loader. Show all posts

Friday, June 17, 2011

Loaders - 2

Well, let's go into the boring facts of loader, which you need to learn even if you are unwilling.I'll try to make them interesting though



There are three main types of loaders.Their names and definetions are as follows :

Absolute Loader : As the name itself says, it does nothing other than loading

Relocating Loader : This loader, helps in the relocation of program in main memory (just in case a program needs to be moved up and down in memory)

Generally this task is performed by Assembler, but here relocating loader takes care of that



Direct Linking Loader : This loader, helps in loading the linked subroutines dynamically.It means that if a program is made from a lot of sub routines, each subroutine is treated as a separate program that needs to be loaded as and when linked or needed.

Also remember, there are four main tasks of a loader


Allocation - Allocate space in main memory for program

Linking - Join the linked subroutines to the program

Relocation - Change the mnemonics, that change with their location

Loading -Loading the program to main memory in the allocated space


Let's take a quick look of our three loaders absolute loader, relocating loader and direct linking loader respectively for the above four functions


Allocation - Programmer, Programmer, Programmer
Linking - Programmer, Programmer, Loader
Relocation - Assembler, Loader, Assembler
Loading - Loader, Loader, Loader

Let's take a look into the linkers tommorrow and from the next monday, you will be starting to learn to build system softwares

Thursday, June 16, 2011

Loader

Let's start with the definetion of loader.

"A loader is software or program that loads the compiled or assembled program into main memory and initiates the execution"

If you are a computer science student, you must have already come across Von Neumann's architecture, if not, here's the def

"The von Neumann architecture is a design model for a stored-program digital computer that uses a central processing unit (CPU) and a single separate storage structure ("memory") to hold both instructions and data " (source:Wikipedia)

For those of you who couldn't grasp it, it simply states that a program must be stored in primary memory or RAM, that is seperate from secondary memory or harddisk, inorder to be executed.



This thought revolutionarised the computer industry, and to this date, computers are built based on this architecture.Also this is an important interview question often tossed by interviewers, but the candidates are always strike out for this.So keep this thing in your memory.

Although today's computers made more complex architectures for their own purpose, the base of all these is the Von Neumann architecture.

I think you already grasped the need of a loader by now.Since the program originally is stored on hard disk and need to be transferred to RAM as per our architecture, loader helps in doing so.

Is my desk calculator a computer ?
Yes, definitely, but the important contrast between it and your computer is the architecture.Your computer uses Von Neumann architecture, while your calculator uses fixed program architecture (a program can be run from with in hard disk)

If a program can be run directly from harddisk, then you may ask, why this Von Neumann architecture, what is the need for loaders and why are you trying to teach us all these..

Well,  the answer comes from history.The first computer ever that was built is ENIAC in 1949. It used fixed program concept.Fixed program in the sense, it's harddisk is prepared in such a way, that it can run only one type of program.If you want to run a different program, you need to rewire, restructure and change the design.It took atleast three weeks gap to run two different programs in ENIAC.

That is the reason, why your computer can be both calculator and wordprocessor or browser or anything, but a calculator can only be a calculator.

Tommorrow, let's go some what deep into the loaders and learn about different types of loaders and their uses.