SPOS UNIT 1 INTRODUCTION NOTES PDF

Title SPOS UNIT 1 INTRODUCTION NOTES
Author Joshua Deshmukh
Course System Programming and Operating System
Institution Savitribai Phule Pune University
Pages 108
File Size 2.8 MB
File Type PDF
Total Downloads 212
Total Views 652

Summary

INTRODUCTION TO SYSTEMS PROGRAMMING1 INTRODUCTIONSystem Software System software consists of a variety of programs that support the operation of a computer. It is a set of programs to perform a variety of system functions as file editing, resource management, I/O management and storage management. T...


Description

INTRODUCTION TO SYSTEMS PROGRAMMING 1.1 INTRODUCTION System Software •

System software consists of a variety of programs that support the operation of a computer.



It is a set of programs to perform a variety of system functions as file editing, resource management, I/O management and storage management.



The characteristic in which system software differs from application software is machine dependency.



An application program is primarily concerned with the solution of some problem, using the computer as a tool.



System programs on the other hand are intended to support the operation and use of the computer itself, rather than any particular application.



For this reason, they are usually related to the architecture of the machine on which they are run.



For example, assemblers translate mnemonic instructions into machine code. The instruction formats, addressing modes are of direct concern in assembler design.



There are some aspects of system software that do not directly depend upon the type of computing system being supported. These are known as machine-independent features.



For example, the general design and logic of an assembler is basically the same on most computers.

1.1.1 Components of System Software 1. Operating system 2. Language translators a. Compilers b. Interpreters c.

Assemblers

d. Preprocessors

UNIT I | 1.1

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)

INTRODUCTION TO SYSTEMS PROGRAMMING

3. Loaders 4. Linkers 5. Macro processors Operating System •

It is the most important system program that act as an interface between the users and the system. It makes the computer easier to use.



It provides an interface that is more user-friendly than the underlying hardware.



The functions of OS are : 1. Process management 2. Memory management 3. Resource management 4. I/O operations 5. Data management 6. Providing security to user’s job.

Language Translators It is the program that takes an input program in one language and produces an output in another language.

Fig. 1.1

Compilers •

A compiler is a language program that translates programs written in any high-level language into its equivalent machine language program.



It bridges the semantic gap between a programming language domain and the execution domain.



Two aspects of compilation are : 1. Generate code to increment meaning of a source program in the execution domain. 2. Provide diagnostics for violation of programming language, semantics in a source program.



The program instructions are taken as a whole.

Fig. 1.2 UNIT I | 1.2

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)

INTRODUCTION TO SYSTEMS PROGRAMMING

Interpreters •

It is a translator program that translates a statement of high-level language to machine language and executes it immediately. The program instructions are taken line by line.



The interpreter reads the source program and stores it in memory.



During interpretation, it takes a source statement, determines its meaning and performs actions which increments it. This includes computational and I/O actions.



Program counter (PC) indicates which statement of the source program is to be interpreted next. This statement would be subjected to the interpretation cycle.



The interpretation cycle consists of the following steps : 1. Fetch the statement. 2. Analyze the statement and determine its meaning. 3. Execute the meaning of the statement.



The following are the characteristics of interpretation : 1. The source program is retained in the source form itself, no target program exists. 2. A statement is analyzed during the interpretation.

Fig. 1.3

Assemblers •

Programmers found it difficult to write or red programs in machine language. In a quest for a convenient language, they began to use a mnemonic (symbol) for each machine instructions which would subsequently be translated into machine language.



Such a mnemonic language is called Assembly language.



Programs known as Assemblers are written to automate the translation of assembly language into machine language.

Fig. 1.4



Translating mnemonic operation codes to their machine language equivalents.



Assigning machine addresses to symbolic tables used by the programmers.

Loader •

A loader is a system software program that performs the loading function. UNIT I | 1.3

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)

INTRODUCTION TO SYSTEMS PROGRAMMING



Loading is the process of placing the program into memory for execution.



Loader is responsible for initiating the execution of the process.



Fundamental process of Loaders consists of : 1. Allocation : The space for program is allocated in the main memory, by calculating the size of the program. 2. Loading : Brings the object program into memory for execution. 3. Relocation : Modifies the object program so that it can be loaded at an address different from the location originally specified. 4. Linking : Which combines two or more separate object programs and supplies the necessary information.

Linker : In high level languages, some built in header files or libraries are stored. These libraries are predefined and these contain basic functions which are essential for executing the program. These functions are linked to the libraries by a program called Linker. If linker does not find a library of a function then it informs to compiler and then compiler generates an error. The compiler automatically invokes the linker as the last step in compiling a program. Not only built in libraries but also it links the user defined functions to the user defined libraries. Usually a longer program is divided into smaller subprograms called modules. And these modules must be combined to execute the program. The process of combining the modules is done by the linker. Macro Processors •

A macro instruction (macro) is a notational convenience for the programmer which allow the programmer to write a shorthand version of a program



A macro represents a commonly used group of statements in the source programming language.



Expanding the macros : The macro processor replaces each macro instruction with the corresponding group of source language statements.



A macro processor : 1. Essentially involve the substitution of one group of characters or lines for another. 2. Normally, it performs no analysis of the text it handles. 3. It doesn’t concern the meaning of the involved statements during macro expansion 4. The design of a macro processor generally is machine independent.



A macro processor designed for use by assembler language programmers.



Used with a high-level programming language. UNIT I | 1.4

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)



INTRODUCTION TO SYSTEMS PROGRAMMING

General-purpose macro processor, which is not tied to any particular language.

Fig. 1.5

1.1.2 Language Processing Activities Language Processing activities arises due to the difference between the manner in which a software designer describes the ideas concerning the behavior of a software and the manner in which these ideas are implemented in computer system. The designer expresses the ideas in terms related to the application domain of the software. To implement these ideas, their description has to be interpreted in terms related to the execution domain of the computer system. We use the term semantics to represent the rules of meaning of a domain, and the term semantic gap to represent the difference between the semantics of two domains.

Fig. 1.6 : Semantic gap

The semantic gap has many consequences, some of the important ones being large development time, large development efforts, and poor quality of software. These issues are handled by software engineers through the use of methodologies and programming languages (PLs). The software engineering steps aimed at the use of a PL can be grouped into : 1. Specification, design and coding steps. 2. PL implementation steps. Software implementation using a PL is called PL domain. The semantic gap between the application domain and execution domain is bridged by software engineering steps. The first step bridges the gap between the application and PL domains (called as specification gap). The second step bridges the gap between the PL and execution domains. The specification gap is bridged by software development team, whereas execution gap is bridged by designer of the programming language processor ( that is translator or interpreter).

UNIT I | 1.5

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)

INTRODUCTION TO SYSTEMS PROGRAMMING

Fig. 1.7 : Specification and execution gaps

Specification Gap : It is the semantic gap between the two specifications of the same task. Execution Gap : The gap between the semantics of programs written in the different programming languages.

1.1.2.1 Language Processors Language processor is a software which bridges a specification or execution gap. A spectrum of language processors is defined to meet practical requirements : •

A language translator bridges an execution gap to the machine language (or assembly language) of a computer system. An assembler is a language translator whose source language is assembly language. A compiler is any language translator which is not an assembler.



A detranslator bridges the same execution gap as the language translator, but in the reverse direction.



A preprocessor is a language processor which bridges an execution gap but is not a language translator.



A language migrator bridges the specification gap between two PLs.

(a)

(b) Fig. 1.8 : Language processors

The interpreter is a language translator. This leads to many similarities between translators and interpreters. From a practical viewpoint many differences also exist between translators and interpreters. The absence of a target program implies the absence of an output interface UNIT I | 1.6

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)

INTRODUCTION TO SYSTEMS PROGRAMMING

the interpreter. Thus the language processing activities of an interpreter cannot be separated from its program execution activities. Hence we say that an interpreter 'executes' a program written in a PL. Problem Oriented Languages PLs used for specific application are called problem oriented languages .They are more close to the application domain. They have more execution gap and it is bridged by a translator or interpreter. Procedure Oriented Languages Provides general purpose facilities required in most application domains .Such a language is independent of specific application domains and result in large specification gap which has to be bridged by an application designer.

Fig. 1.9 : Problem oriented language domain

1.1.2.2 Language Processing Activities The fundamental language processing activities can be divided into those that bridge the specification gap and those that bridge the execution gap. We name these activities as : 1. Program generation activities. 2. Program execution activities. A program generation activity aims at automatic generation of a program. The source languages specification language of an application domain and the target language is typically a procedure oriented PL. A Program execution activity organizes the execution of a program written in a PL on computer system. Its source language could be a procedure oriented language or a problem oriented language. Program Generation The program generator is a software system which accepts the specification of a program to be generated, and generates program in the target PL. In effect, the program generator introduces a new domain between the application and PL domains we call this the program generator domain. The specification gap is now the gap between the application domain and the program generator domain. This gap is smaller than the gap between the application UNIT I | 1.7

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)

INTRODUCTION TO SYSTEMS PROGRAMMING

domain and the target PL domain. Reduction in the specification gap increases the reliability of the generated program.

Fig. 1.10 : Program generation

Fig. 1.11 : Program generator domain

Since the generator domain is close to the application domain, it is easy for the designer or programmer to write the specification of the program to be generated. The harder task of bridging the gap to the PL domain is performed by the generator. This arrangement also reduces the testing effort. Proving the correctness of the program generator amounts to proving the correctness of the transformation .This would be performed while implementing the generator. To test an application generated by using the generator, it is necessary to only verify the correctness of the specification input to the program generator. This is a much simpler task than verifying correctness of the generated program. This task can be further simplified by providing a good diagnostic (i.e. error indication) capability in the program generator, which would detect inconsistencies in the specification. It is more economical to develop a program generator than to develop a problem-oriented language. This is because a problem oriented language suffers a very large execution gap between the PL domain and the execution domain whereas the program generator has a smaller semantic gap to the target PL domain, which is the domain of a standard procedure oriented language. The execution gap between the target PL domain and the execution domain is bridged by the compiler or interpreter for the PL. Program Execution Two popular models for program execution are translation and interpretation. Program Translation The program translation model bridges the execution gap by translating a program written in a PL, called the source program(SP), into an equivalent program in the machine or assembly language of the computer system, called the target program (TP) Characteristics of the program translation model are : • A program must be translated before it can be executed. UNIT I | 1.8

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)

• •

INTRODUCTION TO SYSTEMS PROGRAMMING

The translated program may be saved in a file. The saved program may be executed repeatedly. A program must be retranslated following modifications.

Fig. 1.12 : Program translation model

Program Interpretation The interpreter reads the source program and stores it in its memory. During interpretation it takes a source statement, determines its meaning and performs actions which implement it. This includes computational and input-output actions. The CPU uses a program counter (PC) to note the address of the next instruction to be executed. This instruction is subjected to the instruction execution cycle consisting of the following steps : 1. Fetch the instruction. 2. Decode the instruction to determine the operation to be performed, and also its operands. 3. Execute the instruction. At the end of the cycle, the instruction address in PC is updated and the cycle is repeated for the next instruction. Program interpretation can proceed in an analogous manner. Thus, the PC can indicate which statement of the source program is to be interpreted next. This statement would be subjected to the interpretation cycle, which could consist of the following steps : Fetch the Statement Analyze the statement and determine its meaning, viz. the computation to be performed and its operands. Execute the meaning of the statement.

Fig. 1.13 : Schematic of (a) Interpretation (b) Execution UNIT I | 1.9

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)

INTRODUCTION TO SYSTEMS PROGRAMMING

Comparison A fixed cost (the translation overhead) is incurred in the use of the program translation model. If the source program is modified, the translation cost must be incurred again irrespective of the size of the modification. However, execution of the target program is efficient since the target program is in the machine language. Use of the interpretation model does not incur the translation overheads. This is advantageous if a program is modified between executions, as in program testing and debugging.

1.1.3 Fundamentals of Language Processing Definition Language Processing = Analysis of SP + Synthesis of TP. Where SP : Source Program and TP : Target Program We refer to the collection of language processor components engaged in analyzing a source program as the analysis phase of the language processor. Components engaged in synthesizing a target program constitute the synthesis phase. A specification of the source language forms the basis of source program analysis. The specification consists of three components : 1. Lexical rules, which govern the formation of valid lexical units in the source language. 2. Syntax rules which govern the formation of valid statements in the source language. 3. Semantic rules which associate meaning with valid statements of the language. The analysis phase uses each component of the source language specification to determine relevant information concerning a statement in the source program. Thus, analysis of a source statement consists of lexical, syntax and semantic analysis. The synthesis phase is concerned with the construction of target language statement(s) which have the same meaning as a source statement. Typically, this consist of two main activities : •

Creation of data structures in the target program.



Generation of target code.

We refer to these activities as memory allocation and code generation, respectively. Lexical Analysis (Scanning) Lexical analysis identifies the lexical units in a source statement. It then classifies the units into different lexical classes e.g. id’s, constants etc. and enters them into different tables. This classification may be based on the nature of string or on the specification of the source language. (For example, while an integer constant is a string of digits with an optional sign, a reserved id is an id whose name matches one of the reserved names mentioned in the language specification.) Lexical analysis builds a descriptor, called a token, for each lexical unit. A token contain two fields class code, and number in class, class code identifies the class UNIT I | 1.10

SYSTEMS PROGRAMMING (TE IT SEM. II – PU)

INTRODUCTION TO SYSTEMS PROGRAMMING

to which a lexical unit belongs, number in class is the entry number of the lexical unit in the relevant table. Syntax Analysis (Parsing) Syntax analysis processes the string of tokens built by lexical analysis to determine the statement class, e.g. assignment statement, if statement, etc. It then builds an intermediate code(IC) which represents the structure of the statement. The IC is passed to semantic analysis to determine the meaning of the statement. Semantic Analysis Semantic analysis of declaration statements ...


Similar Free PDFs