Principle of System Software Answers by OURA
Principle of System Software Answers by OURA
Characteristics of Software
· Performance: Refers to how well the software operates and executes tasks efficiently.
· Portability: Indicates the ability of the software to be transferred from one platform to another.
· Functionality: Describes the range of tasks the software can perform effectively.
Software Hierarchy
Application Software:
Utility Software:
System Software:
· Low level languages are close to machine code and include machine language and assembly
language.
· Machine language is written in binary codes and can be executed directly by the computer.
· High level languages are more user-friendly and include procedure-oriented and problem-oriented
languages.
· Fifth Generation Language (5GL) and Fourth Generation Language (4GL) are examples of advanced
high-level languages.
· Lexical analyzer generator LEX and parser generator YACC are widely used tools for developing
language processors.
· These tools help in specifying lexical and syntactic constructs of a programming language and
defining semantic actions.
· Language processing activities bridge the semantic gap between source language and target
language.
· Program generation activities aim at automatically generating programs, while program execution
involves running the generated programs.
5. Define and discuss the different steps of software development life cycle
(SDLC) with diagram.
Ans:
Preliminary Investigation: This step identifies the problems to be solved by the software and determines the
best approach to solve them.
System Analysis: In this stage, the problem is analyzed on a large scale, and all necessary information is
gathered, including interfaces and execution environment requirements.
System Design: The blueprint of the system software is created, specifying how it will look and function.
System Tool Acquisition: Decisions are made on the software tools needed to develop the system software.
Implementation: The software is built using the chosen tools, ensuring functionality, interfaces, and support
for execution.
System Maintenance: After the software is ready, it is installed and maintained through timely updates.
Diagram: The diagram for the Software Development Life Cycle (SDLC) includes the steps of Preliminary
Investigation, System Analysis, System Design, System Tool Acquisition, Implementation, and System
Maintenance in a sequential flow.
Edit Time:
Compile Time:
· Source code is translated into machine code by a compiler, checking for errors and inconsistencies.
Distribution Time:
· Program is sent from creator to user, usually in the form of executable files.
Installation Time:
Link Time:
Load Time:
Run Time:
Semantic gap: The semantic gap represents the difference between the meanings of two domains. It
signifies the disparity in understanding or interpretation between two different contexts or systems.
Execution domain: The execution domain refers to the realm where the ideas of a designer are
implemented in terms related to the computer system's execution. It involves translating the design
concepts into executable actions within the computer environment.
Specification gap: The specification gap is the difference between the application domain and the
programming language domain. It is also known as the specification and design gap, representing the
semantic difference between two specifications of the same task.
Execution gap: The execution gap denotes the difference in semantics between programs written in
different programming languages. It highlights the discrepancy in interpretation or execution when
transitioning between diverse programming language environments.
Language Processor: A language processor is a software tool that processes every statement in a source
program to perform language processing functions. It bridges the semantic gap between the source
language and the target language by analyzing and synthesizing the source code.
Language Translator: A language translator is a tool that translates source code from one programming
language to another. It converts the source program into an equivalent target program in a different
language, enabling the execution of the program on a different platform.
Pre-processor: A pre-processor is a software tool that handles tasks such as macro processing, symbol
resolution, and call explanations before sending the program to language translators like assemblers. It is a
preprocessing step that prepares the source program for further translation activities.
Interpreter: An interpreter is a program that reads and executes source code line by line. It analyzes each
statement, determines its meaning, performs the computation specified, and executes the instructions
directly without the need for a separate compilation step.
9. What is language processing activity?
Ans:
Language processing activity involves two main types of activities that bridge the semantic gap between
the source language and the target language.
· Lexical Analysis (Scanning): Identifies lexical units and classifies them into different classes.
· Syntax Analysis (Parsing): Determines the grammatical structure of the token string and builds an
intermediate code.
· Semantic Analysis: Determines the meaning of statements by applying semantic rules to the
structure.
Stack vs Heap
Stack Allocation:
Heap Allocation:
· Heap is a non-linear data structure allowing random allocation and deallocation of entities.
· Entities in the heap must maintain a pointer to the allocated memory area.
12.Write down different types search techniques.
Ans:
Search Techniques
· In this technique, all active entries in the table have an equal probability of being accessed during
the search for a symbol.
· If the search is unsuccessful, the symbol can be added to the table using an 'add' operation.
· Tables using binary search organization assume an ordering relation among their entries.
· The probability of successful search in a table with 'f' occupied entries is log 2 f, and for an
unsuccessful search, it is also log 2 f.
· A hash table, also known as a hash map, maps keys to values using a hash function.
· It efficiently implements associative arrays and symbol tables, outperforming other data structures
by performing 'm' accesses on 'n' names.
· Linked lists and tree structures are used to organize symbol tables efficiently.
· Self-organizing lists prioritize frequently referenced variables, while search trees efficiently handle
searching operations.
Hash Table
Definition: A hash table, also known as a hash map, is a data structure that utilizes a hash function to map
keys to their corresponding values efficiently.
Components:
· Hash Function: Used to determine the slot where a key's value belongs in the hash table.
· Array of Pointers: Contains 'm' pointers to storage table entries.
· Linked Lists: Organized into separate buckets to store storage table entries efficiently.
Functionality:
· Mapping: Hash function maps key values to specific slots in the hash table.
· Efficiency: Enables quick access and manipulation of data, outperforming other data structures in
certain scenarios.
· Mnemonic Operation Codes: These are easier-to-remember codes for machine instructions,
making programming simpler and enabling the assembler to detect invalid operation codes.
· Symbolic Operands: Programmers can use symbolic names to represent data or instructions,
freeing them from dealing with numeric addresses directly in assembly statements.
· Data Declarations: Data can be declared using various notations, including decimal, to avoid
manually specifying constants in computer-understandable representations.
Imperative Statement:
An imperative statement indicates an action to be performed during the execution of the assembled
statement. Each imperative statement typically translates into one machine instruction. Examples include
MOVER BREG,X and STOP.
Declaration Statement:
Declaration statements are used for reserving memory for variables. The syntax includes DS <constant>
and DC ‘<value>’. For example, A DS 10 reserves 10 words of memory for variable A.
Assembler Directive:
Assembler directives instruct the assembler to perform certain actions during the assembly program.
Examples include START <Constant> which indicates the first word of the machine to be placed in memory
at a specific address.
Analysis Phase: The analysis phase of the assembler involves building the symbol table by determining the
address of symbolic names. It uses a data structure called the location counter (LC) to implement memory
allocation. The tasks of the analysis phase include isolating label, mnemonic opcode, and operand fields,
entering symbols into the symbol table, checking the validity of mnemonics opcode, and performing LC
processing.
Synthesis Phase: In the synthesis phase, the assembler converts assembly statements into machine
instructions. For example, to synthesize the machine instruction corresponding to an assembly statement
like "MOVER BREG, ONE," the assembler needs specific information obtained during the analysis phase. This
information includes the mnemonic opcode, operands, and any necessary processing done during the
analysis phase.
Data Structures: The two main data structures used in the assembler are the Mnemonics Table (MOT) and
the Symbol Table (SYMTAB). The Mnemonics Table contains fields such as mnemonic opcode, machine
opcode, alignment/format info, and routine id. On the other hand, the Symbol Table holds information
about symbols defined and used in the source program, including the owner segment, type, and other
relevant details.
Single Pass Assembler for Intel x86 Design: In the design of a single-pass assembler for Intel x86, the
algorithm differs from the first pass of a two-pass assembler in terms of memory allocation units. The
assembler aligns memory addresses on specific boundaries and performs LC alignment before allocating
memory for statements. This design ensures efficient processing of declarations and imperative statements
in the assembly program.
· Requires only one scan of the source program to generate machine code.
· Handles forward references using back patching technique.
· Can report certain errors during the first pass but not all.
ORIGIN Directive:
· The ORIGIN directive instructs the assembler to put the address specified by the <address
specification> in the location counter.
· Syntax: ORIGIN <address specification>
LTORG Directive:
· The LTORG directive, standing for 'origin for literals', allows specifying where literals should be
placed in memory.
· It ensures that all references to literals are forward references and allocates memory to literals at
specific points during assembly.
EQU Directive:
· The EQU statement associates the name <symbol> with the address specified by <address
specification>, without affecting the address in the location counter.
· Syntax: EQU <symbol> <address specification>
OPTAB
SYMTAB
· Description: SYMTAB is a symbol table storing symbol attributes used in the source program.
· Attributes: Each entry in SYMTAB contains the symbol name, field address, and length.
· Operations: It supports operations like adding, locating, deleting, and accessing symbol entries.
LITTAB
POOLTAB
Overview:
A single pass assembler for Intel x86 processes the source code in one go, generating machine code
directly without the need for a second pass.
Address Allocation:
In this assembler, memory allocation is done on a byte basis, with specific entities requiring alignment on
certain boundaries in the address space.
LC Processing:
During assembly, the assembler aligns the address contained in the LC on the appropriate boundary before
allocating memory for a statement.
Data Structures:
The assembler utilizes data structures like the Mnemonics Table (MOT) and Symbol Table (Symtab) to
handle opcode information and symbol definitions in the source program.
Error Reporting:
Error reporting in this single pass assembler is efficient, with easy error indication due to the availability of
data structures like SYMTAB during pass II.
Macro Processor
A macro processor is a program that processes input data to produce output used as input for another
program. It can exist independently or be part of an assembler implementation. The output of a macro
processor is an assembly program that serves as input for the assembler.
Macro processors identify macro definitions and calls in a program, determine formal parameters and their
values, and handle expansion time control flow. They also perform the expansion of model statements and
maintain values of expansion time variables.
23.Differentiate between macro and subroutine.
Ans:
Macro:
Subroutine:
· Subroutines are called during runtime execution based on a call statement in the program.
· Hardware executes subroutines, and they are completely handled at runtime.
· Subroutines are not expanded like macros; instead, they are executed directly during program
execution.
· Positional Parameters: These parameters are specified without any <parameter kind> in the
syntax rule. They are written as &<parameter name>. The value of a positional formal parameter is
determined by the rule of positional association based on the ordinal position in the list of formal
parameters.
· Keyword Parameters: For keyword parameters, the specification <parameter kind> is the string
'=' in the syntax rule. The <actual parameter specification> is written as <formal parameter
name> = <ordinary string>. The value of a formal parameter is determined by the rule of keyword
association based on the actual parameter specification.
Macro Definition: A macro definition consists of a name, formal parameters, and a body of codes. It is
enclosed between a MACRO and MEND directive. The formal structure includes a prototype statement,
model statements, and a macro preprocessor statement.
Macro Call: A macro is called by writing its name in the mnemonic field of the assembly language. The
syntax includes the macro name followed by actual parameter specifications. The MACRO directive marks
the start of the macro definition, while the MEND directive signifies the end.
Macro Expansion: When a macro is called in a program, it leads to macro expansion. During expansion,
the name of the macro is replaced by the sequence of assembly language statements defined in the macro
body. The expansion process involves substituting actual parameters for formal parameters and generating
the corresponding assembly code.
Explanation:
MY_MACRO
&PARAM1
and
&PARAM2
MACRO
and
MEND
directives.
· To call the macro, use the macro name followed by actual parameter values.
Macro Preprocessor Overview: A macro preprocessor is crucial for handling programs with macro
definitions and calls. It acts as an intermediary step between the source program and the assembler or
compiler. The preprocessor takes input with macros and generates an expanded program without any
macro definitions or calls.
Tasks Performed by Macro Preprocessor: The macro preprocessor performs key tasks such as identifying
macro definitions and calls in the program, determining formal parameters and their values, and keeping
track of expansion time variables and sequencing symbols. It ensures that the source program is processed
effectively before being passed on to the assembler or compiler for further translation.
Design Considerations: When designing a macro preprocessor, it is essential to consider factors like
recognizing macro calls, managing formal parameters, maintaining expansion time variables, and
organizing control flow during macro expansion. Flexible data structures and databases play a vital role in
tracking program information effectively. Attributes of macro arguments, default arguments, and numeric
values also influence the design of the preprocessor.
· A macro assembler is functionally independent of the assembler and its output becomes part of
the assembler's input.
· The integration of macro processor and assembler is known as a macro assembler, eliminating the
need for creating intermediate files.
· The macro processor is typically implemented within pass 1 of the assembler to avoid duplicate
work and improve efficiency.
29. Write down the functions of macro processor.
Ans:
Identifies macro definitions and calls in the program: The macro processor scans the program to recognize
where macros are defined and where they are invoked.
Determines formal parameters and their values: It keeps track of the parameters specified in the macro
definition and assigns values to them during expansion.
Keeps track of the values of expansion time variables and sequencing symbols: The macro processor manages
variables and symbols used during the expansion process to ensure correct substitution and sequencing.
· A macro assembler maintains tables like Macro Name Table (MNT) and Macro Definition Table
(MDT) for handling macro definitions.
· It starts with a MACRO directive, saves the definition in MDT, and continues until the MEND
directive is found.
· Macro expansion involves substituting macro calls with their definitions in the program.
· The assembler switches to a special macro expansion mode to perform this task efficiently.
One-pass macro processors are a design option for macro processing that require the definition of a
macro to be strictly provided before its use in the program. These processors do not involve multiple
passes over the source code for macro expansion. Instead, they expand macros in a single pass while
processing the program sequentially.
32. Write down the differences between linker and loader.
Ans:
Linker:
· Function: Linker is a system program that links together various object modules to produce a
single executable binary program.
· Time of Operation: Linking is done during the compile time.
· Output: Produces a single executable binary program by linking object modules.
· Tasks: Resolves symbolic references, links necessary library functions, and produces a single
executable program.
Loader:
· Function: Loader is a system program that loads the executable binary program into the main
memory for execution.
· Time of Operation: Loading is done during the execution time.
· Output: Loads the executable binary program into the main memory.
· Tasks: Performs relocation, loads the program into memory, and transfers control to the program
for execution.
Design of a Linker
· The design of a linker is divided into two main parts: Relocation and Linking.
· Relocation: The linker uses a work area in memory to construct the binary program, loads the
machine language program from object modules, and relocates address-sensitive instructions
based on the RELOCTAB entries.
· Linking: The linker gathers various object modules, links them together to produce a single
executable binary program, and loads them into memory for execution.
· Memory Efficiency: Linking loaders save memory space by combining object programs and
replacing the assembler with a smaller loader component.
· Ease of Execution: Linking loaders eliminate the need for reassembly of the program before
execution, allowing direct loading and execution of object files.
Disadvantages of Linking Scheme:
· Complexity: Linking loaders are more complicated as they need to manage multiple object files
and handle symbolic references.
· Secondary Storage Requirement: Object files need to be stored in secondary storage before
being loaded into memory, adding an extra step to the process.
Static Linking:
· Static linking involves linking all modules of a program before execution, creating a binary
program without unresolved external references.
· Each program using the same module from a library gets a private copy, potentially leading to
multiple copies in memory if many programs are running simultaneously.
Dynamic Linking:
· Dynamic linking occurs during program execution, linking external references when encountered.
· It offers benefits in terms of use, sharing, and updating of library modules, allowing multiple
programs to share the same module in memory, thus saving memory space.
· Compile-and-Go Loaders:
· Assembler loads in memory and assembles the program directly into their designated
memory locations.
· After loading, the control is transferred to the starting instruction of the loaded program.
· Absolute Loaders:
· Load binary programs into memory for execution.
· Header record specifies load origin, length, and execution start address; binary image
records contain program code.
· General Loader Schemes:
· Improve compile/assemble-and-go scheme by translating different source
programs/modules into object programs separately.
· Object codes stored in secondary storage, loaded by a loader into memory, replacing the
assembler.
· Relocating Loaders:
· Load program in a designated memory area, relocate it for correct execution, and pass
control for execution.
· Efficiently utilize memory and resources, especially in dynamic runtime environments.
· Relocating Linking Loaders:
· Combine relocating and linking capabilities for a robust loading scheme.
· Eliminate the need for separate programs for linking and loading, efficient in dynamic
runtime environments.
· Loader schemes save memory space by using smaller loaders compared to assemblers.
· They eliminate the need for reprocessing the code every time it is run, allowing direct loading and
execution of object programs.
· Loader schemes can be more complicated, especially when managing multiple object files.
· They require secondary storage to store object files before loading them into memory.
· Terminal Symbol: These are symbols in the alphabet of a language, such as letters and
punctuation marks.
· Alphabet: It is the collection of graphic symbols used in a language, denoted by the Greek symbol
Σ.
· String: A finite sequence of symbols denoted by Greek symbols α, β, etc.
· Nonterminal Symbol: Represents the syntax category of a language, like noun or verb, and is
written as a single capital letter or enclosed between < ... >.
· Production: Also known as a rewriting rule, it is a rule of grammar defining the relationship
between nonterminal and terminal symbols.
· Grammar: Defined by a quadruple (Σ, SNT, S, P) where Σ is the alphabet, SNT is the set of
nonterminal symbols, S is the start symbol, and P is the set of productions.
Parsing is the process of analyzing a string of symbols according to the rules of a formal grammar. It
involves breaking down the input into smaller components and checking if it conforms to the grammar
rules.
A parse tree is a graphical representation of the syntactic structure of a string according to the rules of a
formal grammar. It shows how the input string can be derived from the start symbol of the grammar
through a series of productions.
Classification of Grammar
Type-0 grammars:
Type-0 grammars are known as phrase structure grammars. Their productions are of the form α → β where
both α and β can be strings of terminal and nonterminal symbols. These grammars permit arbitrary
substitution of strings during derivation or reduction.
Type-1 grammars:
Productions of Type-1 grammars specify that derivation or reduction of strings can take place only in
specific contexts. These grammars are also known as context sensitive grammars. A production of a Type -1
grammar has the form αAβ → απβ.
Type-2 grammars:
Type-2 grammars, also known as context free grammars (CFG), do not impose any context requirements on
derivations or reductions. A typical Type -2 production is of the form A → π which can be applied
independent of its context.
Type-3 grammars:
Type-3 grammars are characterized by productions of the form A → tB|t or A → Bt|t. These grammars are
also known as linear grammars or regular grammars and are used for specifying lexical units like identifiers,
constants, labels, etc.
Top-Down Parsing:
· Top-down parsing is a parsing technique where the parser starts from the root of the parse tree
and works its way down to the leaves.
· It begins with the start symbol and tries to rewrite it to the input string.
Bottom-Up Parsing:
· Bottom-up parsing is a parsing technique where the parser starts from the input symbols and
works its way up to the start symbol.
· It identifies the constituents of the input string and combines them to form the start symbol.
42. What is LEX and YACC?
Ans:
LEX is a tool used for generating scanners. It takes as input a specification of lexical units in the form of
regular expressions and semantic actions to build an intermediate representation.
YACC is a parser generator tool that generates LALR(1) parsers. It processes translation rules resembling
grammar productions to build an intermediate representation or target code.
Regular Expressions
Regular expressions are sequences of characters used to define search patterns for pattern matching
operations. They are commonly used for tasks like finding and replacing strings in text.
For example, a regular expression to match any string containing the word "apple" would be "apple".
Regular expressions provide a powerful and flexible way to search and manipulate text efficiently.