Disclaimer - Thanks to Love Babbar for this list of important terms that are required to be known in OS.
- Compiler
- Loader
- Assembler
- Interpreter
- System Calls
- API (Application Programming Interface)
- Kernel
- Shell
- JVM
- Booting
In this article, we will go through the first 4 parts of the list and then will complete the rest in the next article.
Compiler-
A compiler is a program that translates a source program written in some high-level programming language (such as Java) into machine code for some computer architecture (such as the Intel Pentium architecture). The generated machine code can be later executed many times against different data each time.
Interpreter -
An interpreter reads an executable source program written in a high-level programming language as well as data for this program, and it runs the program against the data to produce some results. One example is the Unix shell interpreter, which runs operating system commands interactively.
To clear some doubts the below context is taken from:- "Compilers, Principles, Techniques, & Tools", Aho, Lam, Sethi, Ullman, (Pearson International Edition, 2007), pages 1, 2
The two basic mechanisms for processing a program are compilation and interpretation.
Compilation takes as input a source program in a given language and outputs a target program in a target language.
source program --> | compiler | --> target program
If the target language is machine code, it can be executed directly on some processor:
input --> | target program | --> output
A compilation involves scanning and translating the entire input program (or module) and does not involve executing it.Interpretation takes as input the source program and its input and produces the source program's output
source program, input --> | interpreter | --> output
Interpretation usually involves processing (analyzing and executing) the program one statement at a time.In practice, many language processors use a mix of the two approaches. E.g., Java programs are first translated (compiled) into an intermediate program (byte code):
source program --> | translator | --> intermediate program
the output of this step is then executed (interpreted) by a virtual machine:
intermediate program + input --> | virtual machine | --> output
To complicate things even further, the JVM can perform just-in-time compilation at runtime to convert byte code into another format, which is then executed.Also, even when you compile to machine language, there is an interpreter running your binary file which is implemented by the underlying processor. Therefore, even in this case, you are using a hybrid of compilation + interpretation.
So, real systems use a mix of the two so it is difficult to say whether a given language processor is a compiler or an interpreter, because it will probably use both mechanisms at different stages of its processing. In this case, it would probably more appropriate to use another, more neutral term.
Loader-
A loader is a major component of an operating system that ensures all necessary programs and libraries are loaded, which is essential during the startup phase of running a program. It places the libraries and programs into the main memory in order to prepare them for execution. Loading involves reading the contents of the executable file that contains the instructions of the program and then doing other preparatory tasks that are required in order to prepare the executable for running, all of which takes anywhere from a few seconds to minutes depending on the size of the program that needs to run.
Not all code and libraries are loaded at program startup, only the ones required for actually running the program. Other libraries are loaded as the program runs, or only as required. This is especially true for applications such as games that only need assets loaded for the current level or location that the player is in.
Responsibilities of Loader:-
- Validate the program for memory requirements, permissions, etc.
- Copy necessary files, such as the program image or required libraries, from the disk into the memory
- Copy required command-line arguments into the stack
- Link the starting point of the program and link any other required library
- Initialize the registers
- Jump to the program starting point in memory
Assembler-
Source
An assembler is a program that converts assembly language source code into an executable program.
This is comparable to a high-level computer language compiler. A compiler converts code into a program.
However, assembly language is different because each line of code corresponds to a single low-level CPU OpCode.
Top comments (0)