Wednesday, October 6, 2010

Understanding execution environment (Introduction) - I

If you have read 'C' standards, you would have come across two different execution environments

1. Hosted Environment
2. Freestanding Environment

You are well aware of what is meant by "Environment" eh? If not you could better consult an "Environmentalist" ;-) All right lets assume you know enough of 'Environment', now let us see what it means to a programmer or a system Engineer. Just like how you get whatever you need to live from the environment that surrounds you, your program also gets support from the environment that surrounds it. Understanding that will help you to write better programs, debug problems quickly etc. Let us try to map our environments to the real environment we live in.

Have you ever thought of what are the basic things that the environment that we live in provides? Below is a small list which comes from your environment, although we are not very much aware of it our life depends on it
  • Air you breathe
  • Light and Heat
  • A ground to stand (Gravity to hold :-D)
  • Water and Food
  • People around you (Drivers, Gas station assistants, tailors, farmers etc.)
  • Vehicles and Tools (Cars, buses, computers, etc.)
  • Houses, Shops and other support infra-structure
and many more...

In the above list the first 4 items are considered as essential requirements, without which life is not possible, all those items are provided by the planet and the universe you live in, rest of the items are optional but they are required to make your life incredibly easy. Just like how "you" (analogous to program) "live your life"(analogous to program execution), doing things you do, with the support from your environment; your program uses the environment provided by the system to do its tasks. It is quite suitable to think yourself as the program and the universe you live in as the system at which your program executes.

In computer, programs are provided with an environment comparable to our living environment, a quick list would be
  • Hardware Units (Memory, Input, Processing, Output, Network etc.)
  • Operating System
  • Shells (See shells chapter)
  • Support software (Libraries, BIOS routines etc)
  • Support applications

This case is similar to our own environment, the first item is essential requirement, of course without the correct hardware the program stands useless; the rest of all are optional yet it makes the program's development and execution incredibly easier. Having understood something about environment let us come to our "Hosted/Freestanding" environment.

Hosted Environment -- Is nothing but the current environment that you live in, you got everything to make your life possible as well as easy, when it comes to a program it gets all essential and luxury items for its execution. Say for example if you want to drive from place X to Y you can simply hop inside a car (Hire a driver if you want to) go to the gas station get your tank filled by the assistant and use the road to reach Y!

Freestanding Environment -- When you are given only the essential environment items and no or little optional items, then you are in a freestanding environment!!! (Have you seen the movie "I am Legend"?) Unlike hosted environment you will have almost million or more possibilities here, like you might get just Essential items + Vehicles + gas stations (You might have to fill in the gas yourself and drive the car yourself, repair yourself). Worst case you might be given only the essential environment items only, in that case you might have to build your own vehicle and make your own road to reach Y from X, you have to grow your own food etc.!!

(Continued in next part...)

No comments: