Introduction To Systems Programming (CSE 405) Credit: 4 Prerequisite: CSE 301

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 25

MU-MIT

Chapter 01
Introduction to Systems
Programming
(CSE 405)
Credit: 4
Prerequisite: CSE 301
By Desta Gebre (MSc.)

Objectives

To enable students to understand the concepts of Systems


programming.
To enable students understand concepts of design and
implementation of Assembler, Editors, Linkers and
Loaders
To achieve this the course is organized in six chapters
References:
John J. Donovan, Systems Programming, Prentice
Hall

Evaluation
Lab assignments (15-20%)
Quiz (10%)
Bonus programming Assignment (5%)
Mid exam (30-35%)
Final Exam (40%)
Total out of 105%

Introduction
A modern software application typically needs to manage both
private and system resources.
Private resources are its own data, such as the values of its internal
data structures.
System resources are things such as files, screen displays, and network
connections.
Threads and sub-processes are also system resources.

Modern operating systems prevent application software from


managing system resources directly, instead providing interfaces
that these applications can use for managing such resources.
Although it may seem that functions from the C standard library
such as fprintf() access files directly, they do not; they make calls to
system routines that do the work on their behalf.

Definition

Systems Programming is the design and implementation of system


software.

System Software: a variety of programs supporting the operation


of a computer.
Typical system programs: OS, Complier, Assembler (Linker, Loader,
Macro Processors), Text Editor, Debugger

Application software focuses on an application or problem to be


solved.

Systems Programs were developed to make computers better


adaptable to the needs of the users.
One characteristic in which most system software differ from application
software is machine dependency
Free users from knowing the detail of machines.

Computer System
Hierarchies

Figure 1.1: Foundations of Systems Programming

Contd

Relations

Type and modify a program in HL or AL (by an editor)

Translate it into object code in ML (by a compiler or assembler)

Load it into memory for execution (by a linker and/or loader)

Execute it on CPU (by an OS)

Detect errors in the code (by a debugger)

All the processes and programs are run under and controlled by an
OS such as Windows or Linux.

IDE (Integrated Development Environment)

Machine Structure
One characteristic in which most system software differs
from application software is machine dependency.
Assembler: instruction format, addressing modes
Compiler: registers (number, type), machine
instructions
OS: all of the resources of a computing system.
Of course, some aspects of system software are machineindependent.
General design and logic of a assembler
Code optimization in a compiler
Linking of independently assembled subprograms.

Machine Structure Contd

Machine Structure Contd

Memory is the device where information is stored.


Information in memory is coded into group of bits
that may be interpreted as a characters, words or
bytes.
A code is a set of rules for interpreting a group of
bits.

Eg. BCD-code for decimal digits, ASCII-code for characters,


specific processor operation codes for instruction

Memory locations are specified by address where


each address identifies a specific word, byte ..
The content of a word may be interpreted as a data
(value to be operated on) or instruction (operation to
be performed).

A processor is a device that performs a sequence of


operations specified by instruction in the memory.
Processors operate on the information stored.

Machine Structure
I/O processors are concerned with the transfer of
data between memory and peripheral devices.
The Central Processing Units (CPUs) are concerned
with the manipulation of data stored in memory.
The I/O processors execute instruction in the
memory; they are generally activated by a command
from CPUs. Typically this consists an execute I/O
instruction whose argument is the address of the
start of the I/O program.
The CPUs interpret the command and pass the
arguments to the I/O processors.

Evolution of the Components of a


Programming system

The programming system has


undergone a series of development
phases, basically:
Basic Machine
Mnemonic(Symbol)
High level programming

Basic Machine
The programmer has a basic machine at
his disposal that interprets instruction by
hardware.
A programmer writes series of 0s and 1s
(machine language) place them into
memory.
Press a button and start executing.

This approach is not suitable as it is difficult


to read/write in machine language. Hence,
programmers have to find a better remedy

mnemonic for each instruction

Mnemonics (Symbol)
As a solution to the difficulty of using
machine language, mnemonic symbols or
Assembly language was introduced.
Assemblers were written to automate the
translation of assembly language to
machine language.

Source programAssemblerObject program

Every time a program is executed an


assembler has to assemble and pass the
control residing in core memory.

Wastes memory and translation time

Retranslation for every execution

Loader: a program that places program into


memory and prepares them for execution.

Minimizes usage of core memory, loader is much smaller


than assembler.
Avoids re-translation for each execution.

Many programmers wrote essentially the same


program.

Assembler translates the symbols (once) and stores the


output in secondary memory

This led to development of ready made programs or


packages written by computer manufacturers or users.

As programs got sophisticated users wanted to mix


ready made programs and with their own.

Users can create main program that calls several other


programs (subroutines; body of computer instructions
designed to be used by other routines to accomplish a
task).

Closed and open (macro) subroutines: transfer control to


subroutine vs insert the subroutine into the main program.

Relocation
Relocation is the process of assigning load addresses to
various parts of a program and adjusting the code and
data in the program to reflect the assigned addresses.
Relocating loaders perform:
Allocate space in memory for programs (allocation)
Resolve symbolic references between objects
decks (linking)
Adjust all address dependent locations such as
address constants to correspond to allocated space
(relocation)
Physically place the machine instruction and data
into memory (loading)

Macros
Allows programmers to define an abbreviation of
part of a program that will be used now and again
in the program.
Macro processor:
Treats identical parts of a program defined by the
abbreviation as macro definition and saves it.
Substitutes all occurrences of the abbreviation
(macro call).

High level Programming

User problems became more categorized into


areas such as scientific, business and statistical
problems: specialized languages (high level
programming) were developed.
Examples: FORTRAN, COBOL, ALGOL, PL/I
Are processed by compilers and interpreters.

A compiler is a program that accepts program


written by high level language and produces an
object program.

Same name like FORTRAN is often used for both the


language and its compiler.

An interpreter is a program that appears to


execute a source program like a machine
language.

Operating Systems
An Operating system is a program that manages
the computer hardware. OS acts as an
intermediary between the computer user and
the computer hardware.
An amazing aspect of operating systems is how
varied they are in accomplishing these tasks.
Mainframe operating systems are designed
primarily to optimize utilization of hardware.
Personal computer (PC) operating systems
are designed to be convenient to use for the
user.
Thus, some operating systems are designed to
be convenient, others to be efficient, and
others some combination of the two.

Evolution of Operating Systems

Some years ago a FORTRAN programmer would


approach the computer with a deck of his source
program and green deck; FORTRAN Compiler.

Place green deck on the card hopper and press load


to load the FORTRAN compiler.

Place his source deck into card hopper and the


compiler translates it into a red machine language
deck.

Find a pink deck (loader) and load it to memory.

Place red deck into hopper and load it.

Load any subroutines deck called by the program.

Finally loader transfers control to user program


which may require reading of data decks.

Evolution of Operating Systems Contd

Multi-colored system was unsatisfactory strong


motivation for moving towards a more flexible system.
Reasons:
Wasted time (card handling and between jobs).
Solutions:
Batching jobs.
Place a number of jobs into the card hopper to be loaded.
Batch operating system handled these jobs.
Memory allocated to a single job (low efficiency)

Multiprogramming
Place more than one programs in a partitioned memory.
Fragmentation, some sections of memory became unused.
Reloadable memory (compaction)
Paging: Simple and demand

Multi processing: More than one processor in a computer.


Scheduler allocates processor time.
Time sharing: slicing processor time; interactive processing
Virtual memory (logical vs physical address)

Operating System: User View Point on Functions

From the users view point, an operating


system is used for solving problem in a
convenient to use manner.
The following functions are performed by
OS to achieve this.

Job scheduling: FCFS, SJF, RR


Eg: Prioritizing 5 seconds and 5 hours jobs
IO programming - programming IO processor
IO processor is a processor concerned with IO.
Protection: User OS or user user.
Secondary storage management
Tapes, Disks
Error handling: Errors caused by users or programs

Operating System: Facilities

For the applications-oriented user, the function of the


operating system is to provide facilities that help to
solve problems.
Questions of scheduling or protection are of no
interest to the user.

The OS provide the following facilities.


Compilers like FORTRAN
Subroutine libraries: SINE, COSINE, SQRT
Linkers and loaders that prepare pgm for execution.
Utility routines: SORT and MERGE
Application packages: Circuit Analysis and Design
Debugging utilities: program traces and core dumps
Data management and file processing
Management of system hardware

End of Chapter One!

You might also like