Explain the following:- (i) Elimination of common sub expressions during code optimisation. (ii) Pure and impure interpreters. (iii) Lexical substitution during macro expansion. (iv)Overlay structured program. (v) Facilities of a debug monitor. (vi) Actions of an interrupt processing routine. (vii) Real time operating system. (viii) Fork-join.

(i) Elimination of common sub expression during code optimization

An optimizing transformation is a rule for rewriting a segment of a program to improve its execution efficiency without affecting its meaning. One of the techniques is “Common sub expression elimination”
In the expression "(a+b)-(a+b)/4", "common subexpression" refers to the duplicated "(a+b)". Compilers implementing this technique realize that "(a+b)" won't change, and as such, only calculate its value once.

(ii) Pure and impure interpreters

In a pure interpreter, the source program is retained in the source form all through its interpretation. This arrangement incurs substantial analysis overheads while interpreting a statement.An impure interpreter performs some preliminary processing of the source program to reduce the analysis overheads during interpretation. The preprocessor converts the program to an intermediate representation (IR), which is used during interpretation. This speeds up interpretation as the code component of the IR i.e the IC, can be analyzed more efficiently than the source form of the program.

(iii)Lexical substitution during macro expansion:  

Lexical substitution is used to generate an assembly statement from a model statement. A model statement consists of 3 types of strings:
1. An ordinary string, which stands for itself.
2. The name of a formal parameter which is preceded by the character ‘&’.
3. The name of a preprocessor variable, which is also preceded by the character
During lexical expansion, strings of type 1 are retained without substitution. Strings

of types 2 and 3 are replaced by the ‘values’ of the formal parameters or preprocessor variables. The value of a formal parameter is the corresponding actual parameter string.

(iv) Overlay structured program:  

A program containing overlays is referred as overlay structured program where an overlay is a part of program which has the same load origin as some other part(s) of the program. Such a program consists of
1. A permanently resident portion, called the root
2. A set of overlays
The overlay structure of a program is designed by identifying mutually exclusive modules-that is, modules that do not call each other. The basic idea is that such modules do not need to reside simultaneously in memory. Hence they are located in different overlays with the same load origin.
(v) Facilities of a debug monitor are as follows:
a. Setting breakpoints in the program
b. Initiating a debug conversation when control reaches a breakpoint
c. Displaying values of variables
d. Assigning new values to variables
e. Testing user defined assertions and predicates involving program variables.
(vi) Action of an interrupt processing routine are as follows:
1. Save contents of CPU registers. This action is not necessary if the CPU registers are saved by the interrupt action itself.
2. Process the interrupt and take appropriate actions. The interrupt code field of saved PSW information unit corresponding to this interrupt contains useful information for this purpose.
3. Return from interrupt processing.
(vii) Real time operating System
A real-time operating system has well-defined, fixed time constraints. Processing must be done within the defined constraints, or the system will fail. A real time system is considered to function correctly only if it returns the correct result within any time constraints. So the following features are desirable in a real-time operating system:
1. Multi-tasking within an application
2. Ability to define the priorities of tasks
3. Priority driven or deadline oriented scheduling
4. Programmer defined interrupts.
(viii) fork-join are primitives in a higher level programming language for implementing interacting processes. The syntax is as follows:
fork <label>;
join <var>;
where <label> is a label associated with some program statement, and <var> is a variable. A statement fork label1 causes creation of a new process that starts executing at the statement with the label label1. This process is concurrent with the process which executed the statement fork label1.A join statement synchronizes the birth of a process with the termination of one or more processes.
Fork-Join provide a functionally complete facility for control synchronization.


Feel free to contact the admin for any suggestions and help.