SYSTEMS PROGRAMMING. Srimanta Pal. Associate Professor Indian Statistical Institute Kolkata OXFORD UNIVERSITY PRESS

Similar documents
About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1

GUJARAT TECHNOLOGICAL UNIVERSITY

Compilers and Interpreters

Compiler, Assembler, and Linker

Evaluation Scheme L T P Total Credit Theory Mid Sem Exam

COMPILER DESIGN LEXICAL ANALYSIS, PARSING

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

List of Figures. About the Authors. Acknowledgments

Crafting a Compiler with C (II) Compiler V. S. Interpreter

Torben./Egidius Mogensen. Introduction. to Compiler Design. ^ Springer

1. The output of lexical analyser is a) A set of RE b) Syntax Tree c) Set of Tokens d) String Character

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND ENGINEERING COURSE PLAN

COMPILER DESIGN LECTURE NOTES

COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR

Formal Languages and Compilers Lecture I: Introduction to Compilers

SYLLABUS UNIT - I UNIT - II UNIT - III UNIT - IV CHAPTER - 1 : INTRODUCTION CHAPTER - 4 : SYNTAX AX-DIRECTED TRANSLATION TION CHAPTER - 7 : STORA

Life Cycle of Source Program - Compiler Design

Computer Organization and Assembly Language. Lab Session 01

CS 415 Midterm Exam Spring 2002

CS131: Programming Languages and Compilers. Spring 2017

PESIT Bangalore South Campus Department of MCA Course Information for. System Programming (13MCA24)

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN

Mastering BorlandC++ 4.5

SYED AMMAL ENGINEERING COLLEGE (An ISO 9001:2008 Certified Institution) Dr. E.M. Abdullah Campus, Ramanathapuram

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING ACADEMIC YEAR / EVEN SEMESTER

Trustworthy Compilers

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY

QUESTION BANK CHAPTER 1 : OVERVIEW OF SYSTEM SOFTWARE. CHAPTER 2: Overview of Language Processors. CHAPTER 3: Assemblers

Compiling Regular Expressions COMP360

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

VALLIAMMAI ENGINEERING COLLEGE


CST-402(T): Language Processors

CD Assignment I. 1. Explain the various phases of the compiler with a simple example.

G.PULLAIH COLLEGE OF ENGINEERING & TECHNOLOGY

Compiler Construction Using

2068 (I) Attempt all questions.

Chapter 3: Describing Syntax and Semantics. Introduction Formal methods of describing syntax (BNF)

Lexical Scanning COMP360

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING

PSD1C SYSTEM SOFTWAE UNIT: I - V PSD1C SYSTEM SOFTWARE

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER-15 EXAMINATION Model Answer Paper

CS2304-SYSTEM SOFTWARE 2 MARK QUESTION & ANSWERS. UNIT I INTRODUCTION

Question Bank. 10CS63:Compiler Design

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Theoretical Part. Chapter one:- - What are the Phases of compiler? Answer:

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

COMP455: COMPILER AND LANGUAGE DESIGN. Dr. Alaa Aljanaby University of Nizwa Spring 2013

Syntax Analysis Part I

Compilation I. Hwansoo Han

4. An interpreter is a program that

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Outline. Programming Languages 1/16/18 PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY. Current

COMPILER DESIGN. For COMPUTER SCIENCE

Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov Compiler Design (170701)

Course Syllabus [1/2]

Year 12 Computer Science Learning Cycle 2 Overview

Theory and Compiling COMP360

COP 3402 Systems Software Syntax Analysis (Parser)

UNIT I. Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK-4. 1

Chapter 3 Loaders and Linkers -- Loader Design Options

QUESTIONS RELATED TO UNIT I, II And III

Assembly Language Fundamentals

2) Save the Macro definition:- The processor must store the macro instruction definitions which it will need for expanding macro calls.

The analysis part breaks up the source program into constituent pieces and creates an intermediate representation of the source program.

SOFTWARE ARCHITECTURE 5. COMPILER

CS606- compiler instruction Solved MCQS From Midterm Papers

1. INTRODUCTION TO LANGUAGE PROCESSING The Language Processing System can be represented as shown figure below.

SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION SECTION -A

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail.

A simple syntax-directed

Understanding and Writing Compilers

GUJARAT TECHNOLOGICAL UNIVERSITY

COMPILER DESIGN UNIT I LEXICAL ANALYSIS. Translator: It is a program that translates one language to another Language.

Building Compilers with Phoenix

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

SEM / YEAR : VI / III CS2352 PRINCIPLES OF COMPLIERS DESIGN UNIT I - LEXICAL ANALYSIS PART - A

EMBEDDED SYSTEMS: Jonathan W. Valvano INTRODUCTION TO THE MSP432 MICROCONTROLLER. Volume 1 First Edition June 2015

Principles of Programming Languages. Lecture Outline

DEPARTMENT OF INFORMATION TECHNOLOGY / COMPUTER SCIENCE AND ENGINEERING UNIT -1-INTRODUCTION TO COMPILERS 2 MARK QUESTIONS

LECTURE NOTES ON COMPILER DESIGN P a g e 2

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: CS2352 Principles of Compiler Design Year/Sem : III/VI

CMPS Programming Languages. Dr. Chengwei Lei CEECS California State University, Bakersfield

Context-Free Grammar. Concepts Introduced in Chapter 2. Parse Trees. Example Grammar and Derivation

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

ALT-Assembly Language Tutorial

Syntax Analysis. Chapter 4

PESIT SOUTHCAMPUS 10CS52: SYSTEM SOFTWARE QUESTION BANK

DEPARTMENT OF INFORMATION TECHNOLOGY AUTOMATA AND COMPILER DESIGN. B.Tech-IT, III Year -I Sem

Compiler Design (40-414)

Introduction to Parsing Ambiguity and Syntax Errors

Personalised Learning Checklist ( ) SOUND

SLIDE 2. At the beginning of the lecture, we answer question: On what platform the system will work when discussing this subject?

Appendix A The DL Language

Special Topics: Programming Languages

Transcription:

SYSTEMS PROGRAMMING Srimanta Pal Associate Professor Indian Statistical Institute Kolkata OXFORD UNIVERSITY PRESS

Contents Preface v 1. Scope of Systems Programming 1 1.1 Introduction 7 1.2 Computers and uman Beings 2 1.3 Concept of ardware 2 1.4 Machine Structure 3 1.5 Some System Software Concepts 4 1.6 Operating Systems 6 1.7 System Repairing and Debugging Tools 8 ft! Ph 1 Systems Programming Background 2. Prerequisites of Systems Programming 11 2.1 Introduction 77 2.2 Systems 77 2.3 Popular Terms and Concepts 13 2.4 Number Systems and their Representation 14 2.5 Components of A Computer Program 20 2.6 Programming Techniques 27 2.7 Data Structures 23 2.8 Design of Algorithms 29 2.9 Analysis of Algorithms 32 3. Overview of System Software 36 3.1 Introduction 36 3.2 Software 36 3.3 Software ierarchy 37 3.4 Systems Programming 37 3.5 Embedded Systems Programming 39 3.6 Machine Structure 39 3.7 Interfaces 39 3.8 Address Space 40 3.9 Computer Languages 42 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 Language Translators 43 Operating Systems 46 Distributed System 48 Tools 48 Database System 49 Life Cycle of a Source Program Different Views on the Meaning of a Program 50 System Software Development Recent Trends in Software Development 50 Levels of System Software 57 Machine Structures Introduction 53 49 50 53 John Von Neumann Machine Structure 53 A General Approach to Machines 57 Machine 58 Numbered Register-Based Instructional Computers 62 Accumulator-Based Computers 65 Classification of Computers 67 Microprocessor Evolution 69 The Architecture ofa Microcomputer 70 CISC Architecture-Based Computers 77 RISC Architecture-Based Computer 82

CONTENTS ix 5. System File and Library Structures 5.1 Introduction 86 5.2 Library and File Organization 86 5.3 Design of a Record 87 5.4 Source Program/Data File Structure 92 8B 5.5 Object Code 93 5.6 Object Files 98 5.7 Standard Object File Structures 103 5.8 Executable File 115 5.9 Standard Executable File Structures 116 5.10 Libraries 122 5.11 Image File Structures 124 12, Low-Level Translators B. Machine and Mnemonic Languages 6.1 Introduction 129 6.2 Machine Languages 129 6.3 Mnemonic Languages 130 6.4 Machine Language vs Mnemonic Language 130 6.5 Machine Operations In Machine Languages 131 6.6 Programming Techniques In Machine Languages 134 6.7 Object Code 173 6.8 Advanced Concepts 173 7. Assembly Languages 129 175 Programming in Assembly Language: an Illustrative Approach 195 8.1 Introduction 195 8.2 Features 795 8.3 The Intel 8086 Instruction Set 196 8.4 Interrupts /96 8.5 ousekeeping of Interrupt Calls 197 8.6 Programming Techniques 198 8.7 Assembly Language Programming Styles 201 8.8 Language Constructs 202 8.9 ow to Run Assembly Programs 203 8.10 Standard Assemblers 203 8.11 Microsoft Assembler (MASM) 203 7.1 Introduction 775 7.2 Roles of Assembly Language 175 7.3 Basis of Assembly Languages 175 1A Disadvantages 776 7.5 Why Learn Assembly Languages? 776 7.6 Comparisons 776 7.7 Assembly Language Applications 777 7.8 Multi-Platform Assembly Programming 778 7.9 Assembly Language Formats 178 7.10 Assembly Statements 779 7.11 Basic Operations 180 7.12 Importance of Registers 184 7.13 Macros 184 7.14 Structured Assembly Language 185 7.15 Elements of Assembly Programs 7S5 7.16 Programming Techniques 185 7.17 Assembly Language Subroutines 792 8.12 Borland Turbo Assembler (TASM) 205 8.13 Microasm 207 8.14 Netwidc Assembler (NASM) 208 8.15 DOS Batch Files for TASM and M ASM 208 8.16 Memory Models 209 8.17 Program Illustrations 209 9. Assemblers 237 9.1 Introduction 237 9.2 Basic Tasks 237 9.3 Classification of Assemblers 238 9.4 Working Principles 238 9.5 Problems in Manual Assembly 241 9.6 General Problems in Assembler 241 9.7 General Procedure for Assembler Design 241 9.8 A Simple Assembly Process 242 9.9 Assembly Process 245 9.10 Design Issues 253 9.11 Assembler Features 258

x CONTENTS 9.12 Assembler Design Criteria 259 9.13 Types of Assemblers 259 9.14 Two-Pass Assemblers 259 9.16 One-Pass Assemblers 280 9.17 Multi-Pass Assemblers 286 9.18 Advanced Assembly Process 286 9.19 Variants of Assemblers 288 10. Macros and Macro Languages 293 10.1 Introduction 293 10.2 Definitions 295 10.3 Advantages of Using a Macro 295 10.4 Macro vs Procedure 295 10.5 Development of Macro Languages 296 10.6 Local Variables in a Macro 297 10.7 Macros Without Parameters 297 10.8 Concept of Parameters in Macros 300 10.9 Formal vs Actual Parameters in Macros 302 10.10 Concatenation of Macro Parameters 302 10.11 Parameter-Passing Mechanism in Macros 302 10.12 Conditions in Macro Definitions 307 10.13 Macro Calls Within Macro Definitions 311 10.14 Macro Instructions Defining Macros 313 10.15 Case Studies 314 11. Macro Programming: An Illustrative Approach 322 11.1 Introduction 322 11.2 Features 322 11.3 Macro Programming Techniques 322 11.4 Program Illustrations 325 12. Macro Processors 335 12.1 Introduction 335 12.2 Functions of a Macro Processor 335 12.3 Basic Tasks of a Macro Processor 336 12 A Design Issues of Macro Processors 336 12.5 Features 336 12.6 Macro Processor Design Options 337 12.7 Two-Pass Macro Processors 339 12.8 One-Pass Macro Processors 350 12.9 Generalized one-pass Macro Processors 367 12.10 Applications of Macro Processors 367 12.11 Macro Command Interpreter 567 13. Linkers 372 13.1 Introduction 372 13.2 Principles of Linking 573 13.3 A Simple Linking Process 374 13.4 Basic Linking Tasks and Procedure 375 13.5 Memory Management During Linking 376 13.6 Symbols and Symbol Resolution 378 13.7 Binding 379 13.8 Resolving External References 380 13.9 Relocation and Code Modification 380 13.10 Linking Methods 385 13.11 Static Linking 385 13.12 Dynamic Linking 385 13.13 Library Linking 389 13.14 Object Linking and Embedding (OLE) 392 13.15 Module Linking 392 13.16 Design of Linkers 393 13.17 Linker Command Languages 398 13.18 Automatic Library Searching 399 13.19 Some Popular Linkers 400 14. Loaders 405 14.1 Introduction 405 14.2 Programs in Memory 405 14.3 Principles of Loading Operation 405 14.4 Linkers vs Loaders 407 14.5 Loading Shared Libraries From Applications 408 14.6 Different Loading Schemes 408 14.7 Sequential and Direct Loaders 409 14.8 Compile-and-Go Loaders 409 14.9 General Loader Schemes 410 14.10 Absolute Loaders 411 14.11 Relocating Loaders 415 14.12 Practical Relocating Loaders 422 14.13 Linking Loaders 423 14.14 Relocating Linking Loaders 427 14.15 Overlay 429 14.16 Binder 433 14.17 Dynamic Loader 434 14.18 Automatic Library Search 434 14.19 Complexity 435 14.20 Some Popular Loaders 435 14.21 Graphics Loaders 441

CONTENTS xi 15. Object Code Translators 15.1 Introduction 444 15.2 Binary Code Translators 444 444 15.3 Object Code Translators 447 15.4 Translation Process 447 15.5 ybrid Method 449 15.6 Applications 450 OS 3 igh-level Translators eu 16. Overview of igh-level Translators 453 16.1 Introduction 453 16.2 Programming Languages 454 16.3 Compilers 455 16.4 Variant of Compilers 456 17. igh-level Programming Languages for Compilers 458 17.1 Introduction 458 17.2 Nature 458 17.3 Needs 459 17.4 Structured Language 459 17.5 Features 460 17.6 Regular Expressions 460 17.7 Finite Automata 467 17.8 Grammars 462 17.9 Context-Free Grammars 463 17.10 Ambiguous and Unambiguous Grammars 470 17.11 Left-Recursive Grammar 477 17.12 Grammar Classes 477 17.13 BNF to Parsing Table 472 17.14 Some Terminology Used in Parsing 481 17.15 Parsing Table Construction 481 17.16 Predictive Parsing Table Construction 482 17.17 LR Parsing Table Construction 483 17.18 Operator Precedence Grammars 485 17.19 Object-Oriented Programming Languages 491 17.20 Functional Programming Languages 18. Design of Compilers.1.2.3.4,.5,6 ;.7 18.1 Introduction 495 Compilation Process 496 Other Programs with Compilers 497 Translation of a Statement 498 Compiler Construction Tools 498 Lexical Analysis 499 Syntax Analysis 505 Basic Parsing Techniques 505 Semantic Analysis 523 Parameter Passing 526 Intermediate Code Generation 528 Code Generation 531 Code Optimization 532 Optimizing Compilers 533 Some Popular Compilers 534 19. Compiler-Compilers 19.1 Introduction 538 19.2 Design of Compiler Generators 539 19.3 Popular Compiler Generators 542 19.4 Lex 545 19.5 Yacc 549 19.6 Inside of Lex and Yacc 552 19.7 Compiler Design Toolbox 553 19.8 Universal Compiler-Compilers 554 493 495 538 OS Oh4, Lowest-Level Translators 20. Principles of Operating Systems 567 20.1 Introduction 567 20.2 The Scope of Op'erating Systems 567 20.3 The Functions of Operating Systems 569 20.4 Memory Management Schemes 577 20.5 Interrupts 588 20.6 Structural Overview of Operating Systems 594 20.7 State Transition of Concurrent Processes 596

xii CONTENTS 20.8 igher-level Synchronizing Tools 20.9 Deadlocks 599 20.10 andling Deadlocks 607 20.11 Scheduling 670 597 20.12 Device Management 676 20.13 Buffer Allocation Algorithm 20.14 Case Studies 629 628 OS 5, System Tools 0u 21. Editors 21.1 Introduction 649 21.2 Document Editor 649 21.3 The Design of a Text Editor 651 21.4 Sound Editor 667 21.5 Case Studies 662 22. Debuggers 22.1 Introduction 667 22.2 Types of Errors 667 22.3 Debugging Procedures 668 22 A Classification of Debuggers 669 22.5 Dynamic/Interactive Debugger 669 649 667 22.6 Debugging Using 22.7 Use of Debugger in Unix C 672 ardware 672 23. System Administration 675 23.1 Introduction 675 23.2 System Administrators 675 23.3 System Installation 677 23.4 System Configuration 678 23.5 On-Going Process 678s 23.6 System Administration for DOS 679 23.7 System Administration for Windows 679 23.8 System Administration for UNIX 681 Appendix 683 Bibliography 708 Index 713