General Knowledge of Computing
General Knowledge of Computing
1 Computer Hardware
1.1.1 Computer Concepts
RAM
Random Access Memeory. Stores loaded programs and data to be processed. There are
two types: volatile and non-volatile. Unlike non-volatile memory, volatile memory lost
when the computer is switched off or reset.
ROM
Read Only Memory. Stores information about BIOS and startup routines.
Both the primary and auxiliary devices have capacity measured in bits, bytes, kilobytes,
megabytes and gigabytes.
A 1 or a 0 is a BInary digiT (Bit).
A double density floppy disk holds 720Kb of data. A high density floppy disk contains
about 1.44Mb of data.
System Description
Microcomputers This a computer which uses a microprocessor as its CPU. Includes PCs,
laptops etc. They typically have between 1 and 128Mb of memory
(RAM). They process data in anything from 8-bit ro 64-bit chunks.
Minicomputers These are systems designed for multi-user access several terminals.
Varies from processing power from a very powerful micro to a small
mainframe.
Mainframes Supports hundreds of of terminals for multi-user access. Large amount of
primary and auxiliray storage.
Supercomputers These are the fastest and most expensive systems. Although they are not
multi-user machines, they are used when a vast amount of processing is
to be done.
This term describes the collection of hardware in use. A large computer configuration
would consist of several hundred micros in a building linked together by cabling to form
a local area network (LAN).
An embedded system is dedicated to one specific task. They are special purpose systems.
Embedded systems typically have their programs stored in ROM as opposed to auxiliary
storage and RAM. These programs are referred to as firmware - a combination of
software and hardware.
• Applications
• Operating Systems
• Utility Programs
• Programming Languages
• Word Processing
• Spreadsheets
• Desktop Publishing
• Databases
• Graphics
• Computer Aided Design
• Telecommunications
• Multimedia Authoring
• Expert Systems
Special Purpose
Special purpose applications software is used widely but only for a small number of
people in any given field. For example:
• Theatre Booking
• Stock Control
• Insurance Quotes
• EPOS (if not firmware)
• Dentist/GP Appointment Systems
Before the 1950s there was no software to help programmers write programs.
All computers process instructions using machine code. This is called low-level
programming because it uses many simple calculations in binary.
A big development in computing was the introduction of assembly language where the
binary machine code was represented by two or three letters. Assembly language was the
first programming language.
Each program requires its own translation program. This can be an interpreter or a
compiler. An interpretor translates code instruction by instruction and is therefore quite
slow. A compiler translates a source code file into machine code, saving it as a file taht
can be executed later.
The operating system always runs in the background allowing the system to perform such
tasks as:
• Graphical User Interface Systems which use WIMP (Windows, Icons, Menus &
Pointers) principles to manipulate files and control the system.
• Text User Interface Systems which require the user to type commands in.
Utility programs have no distinct result - they merely help the user to acheive a result.
They are usually very closely linked to the operating system.
• Screen Savers
• Disk Defraggmenters
• Anti-virus Software
• Compression & Partitioning Software
The following are a list of tasks for which special purpose interfaces are required:
• Safely
• Effectively
• Efficiently
and possibly:
• Enjoyably
The Considerations
In order to instruct the computer, the user has to type in the command and enter it to be
processed.
Advantages
• Could be quicker to enter more complex commands that would normally have to
be accessed via a number of menus.
Disadvantages
Windows
Can be used to display software or files. Easy to manipulate. Often allow more than one
task to be viewed at once.
Icons
Represent a file or directory or a frequently accessed task.
Menus
Menus allow much of the complexity of the software to be hidden until needed.
Pointer
1.3.4 Menus
This type of menu reamins on screen until the user makes a choice. Usually used at the
start of an application.
Pull down menus are usually displayed at the top an application menu. When the user
clicks on an item a menu appears.
Pop Menus
When a user is required to enter data it is common to display a form on the screen for a
user to fill in.
• a title
• plenty of space
• an indication of how many characters should be present in each field
• default values where possible
• a facility to allow the user to go back and correct mistakes
• items displayed in a logical sequence
• exit and help facilities
• written messages mainly in lower case
• a sensible number of 'attention grabbing' devices
Whole messages or individual words are spoken and recorded digitally. Output that
would normally be displayed can be 'spoken' by the computer.
Uses
• Phone banking
• '192' Directory enquires
• Document text speakers
• Run software
• Control printing
With these systems the computer is controlled by instructions spoken in whole sentences.
If the system is unsure what a particular word was it can examine the structure of the
sentence to predict what the word was.
These types of interfaces allow the user to instruct the computer without need for a
particular 'syntax'.
Advantages:
However:
This group includes the founders and/or the directors of the organisation. They are
responsible for long term planning and policy.
These are people who are middle management. They are responsible for operations
within a particular department.
These are the people responsible for the very basic needs of the company. They produce
the final output.
Each level requires a different type of information system (Although some people in the
operational level do not require an information system).
• Operational Systems
• Management Information Systems
• Decision Support Systems
• Expert Systems
Operational Systems
• Accounting Systems
• Invoicing Systems
• Stock Control Systems
• Order Entry Systems
These systems often summarise information generated at the operational level to generate
management information.
Example:
• Query languages
• Spreadsheet models
• Graphics
Expert Systems
An expert system combines the knowledge of human experts on a given subject to copy
human reasoning. The software follows a set of rules to draw it's inferences.
All computers perform tasks in terms of input, output and process. We can break this
understanding further into three categories:
• Real-time processing
• On-line processing
• Batch processing
Real-time Processing
The computer must keep pace with the external operation and produce almost
instantaneous results.
a. Process Control
Examples:
b. Interactive Processing
If the user enters all of the data for one transaction and then it is processed this is
known as transaction processing.
Examples:
o Airline reservation system.
o Stock control systems where an invoice is printed straight away.
On-line Processing
An on-line system is one where the input device is connected to the computer. The
hardware and software must exist so that the information can be accessed and possibly
changed.
Batch Processing
Some banking applications may use a combination of interactive and batch processing.
1. The customer inserts their card and types in their PIN number and the amount of
cash that they want.
2. The ATM computer retrieves the customers record from the banks central
customer file.
3. If the customer has enough money then the ATM computer sends the new balence
to the screen and issues the correct amount of cash.
4. The new balence is written to the customer file.
5. The ATM program then adds the record to the ATM transaction file which
contains a record for every transaction made that day.
6. At 2:00am the ATM is closed for a short while whilst its transaction file is
processed, producing a summary of ATM transactions.
Centralised Processing
In the 1960's when business systems were introduced it was common to have a
centralised data processing department.
Distributed Processing
With the introduction of minicomputers and later, microcomputers, the trend has been for
each department or individual to do their own processing.
Particular care must be taken to ensure that all data is correctly transcribed and no
documents are lost or entered more than once.
Validation checks are performed to see if data has been entered correctly by seeing if it
'makes sense'.
A code number can be made self-checking by adding an extra digit that follows the code.
This is currently the most popular system. It catches about 99% of errors.
1 5 8 7
1 Each digit is assigned a weight. × × × ×
5 4 3 2
1 5 8 7
× × × ×
Each digit is multiplied by its
2 weight. These numbers are then 5 4 3 2
added up. = = = =
5 + 20 + 24 + 14 = 63
This is enough to allow a unique code for each character with one bit spare.
This spare bit can be used in one of two ways:
• as a parity bit.
• to represent an extended character set.
Most micro-computers use ASCII, but some larger systems might use EBCDIC
(Extended Binary Coded Decimal)
Parity
4.2.1 Introduction
ASCII codes are fine for input and output but useless for arithmetic because:
In the binary system we move right to left, the value of each digit been twice that of the
previous one.
Binary To Decimal
We can set out the binary number 1001 0101 under these column headings.
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 0 0 1 0 1 0 1
128 + 0+ 0+ 16 + 0+ 4+ 0+ 1= 149
Decimal To Binary
Subtract the highest power of two possible from the denary number and place a '1' under
the column for that power of two. Take the remainder and repeat until there is no
remainder.
4.2.2 Binary Arithmetic (Addition)
To see the carry system works in binary we examine the first eight numbers:
Decimal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
137 1 0 0 0 1 0 0 1
+ 44 0 0 1 0 1 1 0 0
1
181 1 0 1 1 0 1 0 1
The most significant bit (msb) or leftmost bit can be used as a sign bit.
If the msb is 0 then the number is positive. If the the msb is 1 then the number is
negative.
Decimal Binary
-4 1111 1100
-3 1111 1101
-2 1111 1110
-1 1111 1111
0 0000 0000
1 0000 0001
2 0000 0010
3 0000 0011
4 0000 0100
Step 1 00000110
Find the binary value of the
equivalent positive denary number.
Step 2 11111001
Change 0s to 1s and 1s to 0s
(complement).
Step 3 11111010
Add 1 to the result.
11111011
Step 1 00000100
Complement the number.
Step 2 -00000101
Add one add prefix a minus sign.
Step 3 -5
Convert binary to decimal.
12 0 0 0 0 1 1 0 0
-12 1 1 1 1 0 1 0 0
+ 15 0 0 0 0 1 1 1 1
1 1 1 1 1
3 0 0 0 0 0 0 1 1
E.g. 6 × 3 = 6 + 6 + 6 = 18
It is easy to convert from binary to hex and hex is easier to read than a long string of 1s
and 0s.
Step 1
Divide the binary number into groups of four digits 0111 0101
starting at the LSB.
Step 2
Write down the hexadecimal equivalent for each 7 5
group of digits.
011101012 = 7516
Converting From Hexadecimal To Denary
To perform this operation we use the same method as for converting a binary number to
decimal. However the column headings are in powers of sixteen not powers of two.
In the octal number system there are only eight different symbols.
Step 1
Divide the binary number into groups of three digits 111 101
starting at the LSB.
Step 2
Write down the hexadecimal equivalent for each 7 5
group of digits.
111 1012 = 758
To perform this operation we use the same method as for converting a binary number to
decimal. However the column headings are in powers of eight, not two.
2 7 1 9
0010 0111 0001 1001
271910 = 0010 0111 0001 1001BCD
Advantages
Disadvantages
BCD Addition
Whenever the sum of any two BCD digits is greater than 10012 then 01102 has to be
added to the result to skip over the unused codes.
• Graphics
• Sounds
• Executive programs
• Boolean Values
The PCs screen can be thought of as being divided up into a grid. Each square on the grid
is called a pixel or a picture element.
Sounds are analogue (continously variable) and need to be converted into digital form.
This is done using an analogue to digital converter (ADC).
Advantages
• Data integrity.
• Easier to edit.
Disadvantages
• Any suggestions???
4.5 Fixed Point Binary Numbers
4.5.1 Positive Fixed Point Binary Numbers
27 26 25 24 23 22 21 20 2-1 2-2
128 64 32 16 8 4 2 1 0.5 0.25
1 0 1 0 0 1 0 0 . 1 1
=164.75
Binary Fraction Fraction Decimal
0.1 1/2 0.5
0.01 1/4 0.25
0.001 1/8 0.125
0.0001 1/16 0.0625
For negative numbers we use two's complement representation on the entire bit pattern.
Example
Represent -5.2510 in 8-bit binary with the binary point after the fourth digit.
Step 1
Calculate the positive equivalent 5 . 2 5
number in binary.
0 1 0 1 . 0 1 0 0
Step 2
Change 0s to 1s and 1s to 0s 1 0 1 0 . 1 0 1 1
(Complement).
Step 3
1 0 1 0 . 1 1 0 0
Add 1 to the result.
Advantages
Disadvantages
Example
7,800,000
The mantissa holds the digitsand the exponent determines the point where the fractional
point goes.
Binary
Positive Mantissa
Negative Mantissa
Negative Exponents
If the exponent's left hand bit is a 1 then, when converting the exponent to denary, the
mantissa's bit pattern is shifted right.
The precision of the floating representation depends on how many digits can be stored in
the mantissa.
In order to get the most accurate representation for a given number of digits in the
mantissa the number is written with no leading zeros.
Example
For a positive mantissa in normalised form the first two bits will always be 0.1.
Example
Normalise the number: 0 000110101 000010 (10-bit mantissa, 6-bit exponent)
Step 1 0 . 0 0 0 1 1 0 1 0 1
Put in the assumed binary point and
convert the exponent to denary.
Exponent = 0000102 = 210
Step 2
Remembering that the overall value of
the number must not change:
• Shift the mantissa bit pattern 0 . 1 1 0 1 0 1 0 0 0
three places to the left to make
it start 0.1.
• Subtract three from the 2 - 3 = -1
exponent. Then convert it to -1010 = 1111112
binary.
To normalise a negative mantissa shift the mantissa left until the second bit is zero and
subtract as necessary from the exponent.
Example
Step 1 1 . 1 1 1 1 0 0 1 0 0
Put in the assumed binary point and
convert the exponent to denary.
Exponent = 0000112 = 310
Step 2
Remembering that the overall value of
the number must not change:
• Shift the mantissa bit pattern 1 . 0 0 1 0 0 0 0 0 0
four places to the left to make
it start 1.0.
• Subtract four from the 3 - 4 = -1
exponent. Then convert it to -1010 = 1111112
binary.
With negative numbers with a magnitude greater than one it is better to normalise the
equivalent positive number and carry out Two's Complement.
QuickBASIC uses two bytes to store integers. As it uses the Two's Complement system,
the integer range is:
Positive Negative
0.11111 × 20111 1.00000 × 20111
Largest Magnitude
= 12410 = -12810
0.10000 × 21000 1.01111 × 21000
Smallest Magnitude
= 0.00195312510 = -0.002075195312510
Representation Of Zeros
The number 0.00000 × 20000 is not normalised and does not exist in this system.
Zero is usually represented by the smallest possible number and this number is left from
the range.
Exponents of floating point numbers may be represented in excess notation rather than
Two's Complement.
Floating and fixed point numbers will be accurate to the smallest number they can
represent.
Round-Off Errors
Often we cannot represent a denary fraction exactly even if we allow many bits in
memory. Therefore the number stored is "rounded off" to the closest possible binary
equivalent.
Truncation Errors
Often, in either floating or fixed point systems, results are calculated with too many
places of accuracy to be represented. We get this type of error when traling bits are
truncated to fit the result in the memory location available.
Overflow
Underflow
A result is produced that is smaller in magnitude than the smallest number that can be
represented.
A files is an organised collection of data. For example: An employee file may contain a
collection of organised data relating to employees within a company.
Data can only be stored or retrieved from one address after another.
Files which consist of records and fields are called data files. There are three main types:
Transaction Files
Such files contain details on all recorded events over the last period.
A sales transaction file contains data on all the sales made in the last day.
Transaction files have a very short life. Although they may sometimes be achived.
Master Files
These are permanent files that are regularly updated by processing transaction files.
They contain:
Resource Files
These are permanent files that are nt usually updated. Contents are used for reference.
6.1.4 Other File Types
Program Files
Document Files
Records are placed onto the disk or tape one after the other with no regard for sequence.
The three QuickBASIC commands that we need to create serial or sequential files are:
This creates a file called Filename$ so data from the program can be output to it.
CLOSE #n
CLOSE #n%
Note that data is always input starting from the beginning of the file.
The variables and their data types should match with those used in the WRITE statement.
As records in a serial file are in no particular order to add a new record we can simply
append it to the end of an existing file.
In order to delete a record, a brand new file (of the same name) has to be created without
the record that was to be deleted.
Physical Deletion
If it is to be kept, write it to the new file. If it is not, then move on to the next record.
Delete the old file and rename the new file as the old one.
Logical Deletion
Each record is given an extra field. This field is a flag field. If it is equal to 0 then the
record is shown as existing. If it is equal to 1 then, although the record exists, it is not
shown and can be considered to be logically deleted.
It is a more compact way of programming to swap many 1D arrays for one 2D array.
For example:
DIM Name$(1 TO 4)
DIM Age%(1 TO 4)
DIM NameAge$(1 TO 2, 1 TO 4)
There are two ways to handle a situation involving a variable number of records.
At the end of serial and sequential files we can detect the end of file marker.
EOF(n)
where n is the channel number.
When a serial file is created a separate reference file of the same name but with the
extension 'tot' is also created.
If records are added or deleted then the total in the reference file has to be altered.
Unlike serial files we cannot append new records to the end of the file. New records are
added using a method known as Updating by Copying.
This is done by inputting records one-by-one and then writing each record one-by-one
making sure that the new record is inserted in the right place.
Pseudocode
CLOSE files
rename files
END
Updating A Master File
In the business world it is common to 'update' a file by changing more than one record at
a time. A file can be updated by:
Example
An electricity company's master file contains records for customers. New customers have
to be added and customers who move house need to have their records modified.
• Master file
• Transaction file
• New master file
The master file could (for example) contain names, address and account numbers for
customers. The transaction contains records that need to be added and records that need
to be modified. The new master file will be produced by processing the transaction file on
the existing master file.
1. Make sure the transaction file is in the same sequence as the master file.
2. Read a transaction record into main memory.
3. Read a master record into main memory.
4. If the transaction record is less than the master record, write to the new master
file, read in the next transaction record and go to 4 (this is recursive).
5. Write the master record to the new file.
6. Go to 3.
If we want to modify existig records as well then this could be incorpriated in to step 4.
We may wish to keep the old master file as a record of previous situations.
This reads all the characters including commas to the next end of record marker and
assigns the string to rec$.
The string handling functions can then be used to extract the field data.
The index is created and stored with the file when it is first created.
The way in which the index works depends on how the data is written onto the disk.
Each platter has two surfaces although the outer surfaces are not used.
All the tracks of the same diameter together on different surfaces form a cyclinder.
The cyclinder (primary index) is read first. From this we can establish which cyclider
holds the data we want and the read/write heads are moved to that cyclinder. This is
known as seeking.
At the right cyclinder the surface index (the secondary index) is read. We can now switch
on the right head for the right surface. This is known as switching.
The read/write heads are now on the right track. We now read the sector index (the
tertiary index). This gives the sector at which the record should be found.
The sector is now searched serially. If the record is not found then either:
• Files can be processed randomly which is usually faster than serial processing.
• We have the flexibility to ignore the index and search the file sequentially.
• The index takes time to create, access and also consumes space.
6.3.3 Overflow
The sector which should accommodate a record is called it's home sector.
If a sector is full, there are two circumstances when a record will not fit into its home
sector.
If this happens a tag is left in the home sector which gives the key field of the record and
the address of the sector in the overflow area where the record is to be found.
6.3.4 Blocks
The smallest amount of data that can be transferred between main memory and backing
store is a block. A block of data occupies one sector.
The number of records stored in one block is called the blocking factor of a file. The
choice of deciding how large to make the blocking factor is called the blocking strategy.
if a large number of records have had to be stored in overflow areas becuase their home
sectors were full then file processing would be slow.
This involves:
More free space is left in the home sector for additional records. The indexes are also
recreated.
The program that stores and retrieves the records has to specify the address of the record
first of all.
An algorithm (a set of instructions) turns the value of the records key into an address for
the record.
The simplest method uses the value of the key field as the record address.
Example
Record Address Customer Number Customer Name
1 1 <empty record>
2 2 <empty record>
104 104 Davis
208 208 Peterson
405 405 Franks
408 408 Black
However, with this method, records are often too spaced out.
Hashing algorithms convert a records key into an address for the records.
For alpha-numeric key fields a common way of hashing the string to a record address is
to add up the ASCII values of the characters and find the remainder on division of the
sum.
Pseudocode
sum = 0
6.4.3 Synonyms
When two record keys are hashed to the same address, we say that they are synonyms.
Possible Solutions
As with indexed sequential files, at some point we may need to reorganise the file.
As well as the standard data types in QuickBASIC we can also define our own data types
using the TYPE statement.
Example
TYPE MyRecord
Aname AS STRING * 12
Phone AS STRING * 12
Units AS INTEGER
Price AS SINGLE
Amount AS DOUBLE
END TYPE
We can now dimension variables and arrays as this new data type.
Example
Each element of the 1D array would have the composite parts as defined in the TYPE
statement.
Example
The customer's name and telephone number are simple as they are strings. We decide that
no customers have names over 20 characters long. We allow 12 characters for the phone
number.
In sequential files numbers were stored as a series of ASCII characters. For example:
17,002 is stored using five bytes; one for each digit.
This is wasteful of memory, and in random access files, numbers are saved in a
compressed binary format.
In general:
Step 1
First, the field structure of each record is defined by means of the TYPE - END TYPE
statement.
TYPE MyRecord
Aname AS STRING * 12
Phone AS STRING * 12
Units AS INTEGER
Price AS SINGLE
Amount AS DOUBLE
Step 2
Step 3
Note that random files are opened for input and output simultaneously.
Step 4
Step 5
CLOSE #n
As with inserting data we need to have declared a variable or array with a composite data
type that matches the files field structure.
where n is the channel number and L% is the length of each record in bytes.
CLOSE #n
If we wish to find out how many bytes are in a random file we can use
LOF(n)
If this is divided by the byte length of each record, the number of records can be
calculated.
If the number of characters in a string field varies greatly or the number of fields in the
record varies then the use of variable length records is appropriate.
Updating By Overlay
Records in indexed sequential files and random files can be accessed directly, modified
and written back to their original locations.
Updating By Copying
This method involves copying the records one by one to a new file, making modifications
as needed.
Each time a master file is updated another, out of date, generation is left.
• Grandfather
• Father
• Son (Current version)
The choice of file organisation is a vital consideration. The following questions need to
be answered:
• What is the most suitable storage medium for the volume of data involved?
• Must the information always be up-to-date>
• Do users require immediate access to data>
• Can requests for information be grouped together and be batched processed?
• Are report required in a particular sequence?
• What is the hit rate?
• How volatile is the file?
6.5.4 Hit Rate
This is the measure of how many records are accessed out of the total number, usually
expressed as a percentage.
Example
During the process 190 out of 200 employee records are updated.
6.5.5 Volatility
This is the frequency at which records are added or deleted from a file.
Serial Files
Serial file organisation is mainly used for transaction files. As events in the real world
take place, relevant data records are written to a transaction file.
• Sales in a shop.
• Customer's withdrawing money from an ATM.
• Postal orders arriving at a mail order company.
The transactions may be batched and the master file updated later. Alternatively, the
master file may be updated as soon as each event occurs (in real-time). The transaction
file is then kept as a record of what occured in case the master file corrupted and its father
needs to be updated.
Sequential Files
Sequential file organisation is used for master files in high-hit rate applications.
• Payroll
• Direct mailing (a.k.a. Junk mailing)
Indexed Sequential Files
Indexed sequential files can be processed either sequentially or randomly. This is very
useful because when most of the records need to be processed then they can be
sequentially processed. When only a few need to be updated then they can be directly
accessed.
• Stock control
The stock file would be directly accessed when the customer makes a purchase. The
master file would be accessed using a multi-level index to find the relevant record. The
description and the price would then be printed on the receipt and the quantity in stock
would be updated right away.
The file would be sequentially processed if a report of all the stock or sales is needed in
stock code sequence. Processing the file this way is fast, but it is not as fast as processing
a sequential file.
Random Files
Random files are used when extremly fast access is required to individual records.
Becuase the hashing algorithm generates the record address when it's applied to the
record's key no time is taken looking through various levels of index.
If reports are needed containing all the records in key sequence, these will take a long
time to generate.
If our data items are stored in no particular order then a linear search of these items is
called a serial search.
The search can be abandoned either when the record is found or the search goes past the
item been sought.
Pseudocode
DO
IF record matches THEN
matchflag = 1
EXIT DO
ELSE IF search value > current record THEN
matchflag = 0
EXIT DO
END IF
Increment counter
LOOP end of file / end of array data
Display results
If the middle item matches the search item then we have found the item and we can stop
the search.
Else if the middle item is greater then the search item, then only the first half the table
needs to be searched.
Else if the middle item is less than the search item then only the second half of the table
needs to be searched.
Pseudocode
'Intialise
MatchFlag = 0
SearchFail = 0
DIM array
INPUT SearchValue
Calculate startp and endp
DO
Calculate midp
'Output
Show Output
In order to convert an unsorted list to a sequential list we can take an item out of the list,
shuffle the other items along until a gap appears at the appropriate place and insert our
item. This is repeated for all items.
Example
Position: 0 1 2 3 4 5
Value: 5 3 8 6 2
Start with the item in position 2. Take it out of the list to position 0.
Position: 0 1 2 3 4 5
Value: 3 5 8 6 2
Now start just to the left of the gap. Compare each item with the item in position 0 and
move it right if it is greater.
Position: 0 1 2 3 4 5
Value: 3 5 8 6 2
Position: 0 1 2 3 4 5
Value: 3 5 8 6 2
The third item is greater than the item in position 2 so nothing has to be done and the
number stays in the same position.
Position: 0 1 2 3 4 5
Value: 6 3 5 8 2
Position: 0 1 2 3 4 5
Value: 6 3 5 8 2
Position: 0 1 2 3 4 5
Value: 3 5 6 8 2
Position: 0 1 2 3 4 5
Value: 2 3 5 6 8
We now move the appropriate items right...
Position: 0 1 2 3 4 5
Value: 2 3 5 6 8
Position: 0 1 2 3 4 5
Value: 2 3 5 6 8
Pseudocode
DIM card% (0 TO 5)
FOR position% = 2 TO 5
card%(0) = card%(position%)
DO UNTIL card%(movpos%) <= card%(0)
card%(movpos% + 1) = card%(movpos%)
movpos% = movpos% - 1
LOOP
card%(movpos% + 1) = card%(0)
NEXT position%
In this internal sort, adjacent values in a list are compared and swapped if necessary.
1st Pass 6 5 3 2 8
5 6 3 2 8
5 3 6 2 8
5 3 2 6 8
2nd Pass 5 3 2 6 8
3 5 2 6 8
3 2 5 6 8
3rd Pass 3 2 5 6 8
2 3 5 6 8
4th Pass 2 3 5 6 8
On the fourth pass no swaps are made so the sort is complete.
This sort is called a bubble sort because small (or light) numbers 'bubble' to the top.
Pseudocode
DIMension card(1 to n)
READ in data
DO
swapped = 0
FOR position = 1
IF card(position) > card(position + 1) THEN
swap the cards
swapped = 1
END IF
NEXT position
LOOP UNTIL swapped = 0
This algorithm is a fast sorting algorithm because it swaps items that are a very large
distance apart.
It works by picking a pivot item in the list and then moves every item that is greater to
one side and every item that is less is passed to the other side.
The two sub-divisions are then recursively passed one after another to the Quick Sort
algorithm.
When lengthy records or variable length records need to be sorted it is often faster to sort
only the key field.
In order to retrieve the full record details a pointer is added to each key field value.
At any one time, two of these files are 'transmitting' records and the other two are
'receiving' records.
Example
Serial
23 16 57 43 90 13 29 75 36 25 41 82 19
File
File A 23 57 90 29 36 41 19
File B 16 43 13 75 25 82
File C 16 23 13 90 25 36 19
File D 43 57 29 75 41 82
File C and File D hold sequences of records with a minimum length of two records.
A second pass starts and File C and File D now 'transmit' their records to File A and File
B.
File C 13 16 19 23 25 29 36 41 43 57 75 82 90
7.4.2 Classic Four Tape Merge Sort
This is a better version of the basic merge sort. The main difference lies in the
initialisation step.
Serial
23 16 57 43 90 13 29 75 36 25 41 82 19
File
The records are moved in groups of ascending key field values to File A and File B.
File C 13 16 19 23 25 29 36 41 43 57 75 82 90
This algorithm took 3 passes whereas the simple merge sort took four passes.
Note that:
The act regulates the use of "automatically processed information relating to individuals
and the provision of services in respect of such information".
Data
Information in processable form.
Personal Data
Data relating to identifiable, living, individuals.
Data Subject
The individual concerned.
1. Personal data, held for processing, must be obtained fairly for a lawful purpose.
2. Such data must be held for a specific purpose.
3. Personal data must only be used for the specific purpose and may only be
disclosed in accordance with the specific purpose.
4. Personal data must not be excessive for the purpose but merely adequate and
relevant.
5. Personal data must be made avaliable to the individual concerned and provision
made for corrections.
6. The personal data must be held securely against unauthorised access or loss.
The act established the office of Registrar who is responsible for maintaining an
organisation's public register of Data Users (those people who collect and process
personal data).
Personal data held for payroll, pensions, and accounts data is exempt; as are names and
addresses for the purposes of distributing information (e.g. mail merge).
Also, personal data held in connections with national security, crime prevention, or for
the collection of tax or duty.
If personal data is collected for statistical or research purposes only, or is held simply for
backup then data subjects do not have the right to see such data.
Although personal data must be kept secure, it can be disclosed to the data subject's agent
(e.g. lawyer or accountant), to a person working for the data user and to anyone if there is
an urgent need to prevent injury or damage to health.
Programmers and other computer workers have more oppurtunity to defraud their
employer than other workers.
Some software licenses make provision for copies of the software to be used 'like a
boook'.
A computer virus is a portion of software that is able to copy itself and usually has an
undesirable effect of computer data.
Sources Of Infection
• Internet downloads
• Floppy disks
• Email attachments
• Local area networks
Virus Categories
Anti-virus software should be installed on all systems where there is a risk of infection.
The following precautions can be taken to slow down the spread of viruses.
8.5.3 Trojans
Trojans are programs that appear to be desirable peices od software, however they have
the capacity to harm data. Unlike viruses they do not copy themselves automatically.
• Disgruntled employees
• Terrorists acts
• Hackers gaining access
• Hardware failure
• Program failure
• Operator error
Environmental Hazards
• Fires
• Floods
• Power Surges
• Hurricanes
• Earthqaukes
8.6.1 Backup
Periodic Backup
Backups are made regularly and kept in a safe place. This is the least satisfactory method.
File Generations
Grandfather, and son files can be stored along with their respective transactions. This
method is only used with sequential file processing.
Incremental Dumping
During a user's work session all the updated files are marked. When the user logs out
these files are copied or 'dumped' to another disk.
Transaction Logging
8.6.2 Recovery
Disaster Planning
There is a contigency plan that comes into action when an organisations data is used.
A separate site with offices, computers and an up-to-date copy of the organisations data is
used.
Bypass Procedures
Bypass procedures are invoked if the central computer in an on-line system fails.
Intelligent terminals with their own backing store can record transactions temporarily
until the main computer is back on-line.
Data security is threatened by both hackers from outside and employees within a
company.
Usernames and passwords are usually stored in a table. The table is permanently stored in
a file on a disk.
Password tables are often stored with authorisation tables that contain a user's rights to
other files.
Passwords tables should be 'irreversibly' encrypted to prevent their contents from been
read.
The encrypted message is sent along a communications link and the receiving computer
decrypts the message.
Transition Cyphers
Example
"MEET_ME_TONIGHT_AT_8"
MEET_
ME_TO
NIGHT
_AT_8
The grid is then read column by column and sent out as:
"MMN_EEIAE_GTTTH__OT8"
Substitution Ciphers
Example
gives:
"WELL DONE"
• Iris recognition
• Fingerprint recognition
• Voice recognition
• Face recognition
Errors On Input
• Typing errors
• Transcription errors
• Lost batch sheets
Errors In Operation Procedures
• Electrical interference
• Loose connections
The following steps can be taken to try and ensure data integrity:
• verification.
• validation (range check, presence check, picture check, character count, file
lookup, check digit).
• control totals in batch processing.
• parity bits for data transmission and RAM.
• Checksums for data transmission.
Before data can be stored in the database, the structure must be created.
The standard notation to describe the structure of a table in the database is based on the
attributes of one entity.
Example
The primary key is the first attribute written in the brackets and is underlined. Other
attributes follow, separated by commas.
The entities (and therefore the tables) in a relational database can be related to each other
in any one of three ways:
• One-to-one
• One-to-many
• Many-to-many
Example
Example
Entities:
• Customer
• Order
• Product
Normalisation ensures that the database is structured in the best possible way.
To achieve control over data redundancy. There should be no unecessary duplication of
data in different tables.
To ensure data consistency. Where duplication is necessary the data is the same.
To ensure tables have a flexible structure. E.g. number of classes taken or books
borrowed should not be limited.
To put the table into 1NF the repeating attribute is turned into part of the primary key.
A table is in the second normal form if it's in the first normal form AND no column
that is not part of the primary key is dependant only a portion of the primary key.
Consider Student
Student number is uniquely associated with Student name but Class number is not.
To put the table into second normal form, the primary that the other attributes are not
dependant upon is removed and a linking table created.
This gives
A table is in the third normal form if it is the second normal form and there are no
non-key columns dependant on other non-key columns that could not act as the
primary key.
Staff(Lecturer no, Lecturer name, Tel no, Tutorgp name, Tutorgp room)
To put the table into 3NF the dependant column is removed from the table and a new
table containing both columns is created.
A foreign key is the primary key of one table that appears in another table.
Example
• Locking
o Operation in exclusive mode.
o Lock other users from tables been modified.
o Lock out the record been edited.
o No locks. Users are informed of conflicts.
o Ordinary users can only open tables in read-only mode.
• Refreshing
• Resolving a deadly embrace
Deadly Embrace
If two users attempt to update two records at the same time then the following can
happen:
User 1 User 2
Accesses and locks record 1 Accesses and locks record 2
Attempts to access record 2 Attempts to access record 1
waits... waits...
and waits... and waits...
and waits... and waits...
When database queires are made it is important to give users a fast response time.
Furthermore if users are locked out of records they will become frustrated and
disgruntled.
• Regular backups
• Transaction logging
• Checkpoints
o All updates are stored in transaction log.
o When the database is permantly updated a checkpoint is placed in the
transaction log and the old version of the database is kept as a backup.
o If failure occurs then all the updates up to the last check point can be
applied to the old database.
• Passwords
• The DBMS can assign priviledges to users or groups of users.
• Encrypting the data.
The DBA may be in charge of a group of people known as the database administration.
Responsibilities
• Database design
• Informing users of structural changes
• Maintaining the data dictionary
• Assigning access priviledges and passwords
• Training for users
A database is composed of the raw data and the software to organise it.
10.1 Introduction
The different methods of organising data are known as data structures.
Example
Integer - QuickBASIC
Character - Pascal
Example
Static data structures always occupy a fixed number of bits in the computers memory.
The number of bits in a dynamic data structure can change.
In order to implement a linear list we need an array large enough to hold the maximum
sequence that can occur.
We also need:
New items are inserted at the correct place. The variable holding the size must be
incremented.
To retrieve an item we place the sought item in position 0 and search linearly through the
list.
Example
train(0).dest = sought_value
pointer = 1
To delete an item from a list we first find the item using the code from the last section.
Example
CALL the retrieve sub program to see if it is in the list and then get its location
IF found = 0 THEN
display an error message
ELSE
FOR current = pointer to size
train(current) = train(current + 1)
NEXT current
size = size - 1
END IF
Each item in the list is called a node and is made up of information field (which often has
sub fields) and a next address field called a pointer.
The pointer of the last item is given a value of zero to indicate that there are no more
items.
This data structure also includes a variable that points to the first item in the list.
In order to keep track of the free space two linked lists are kept.
When a new item is added the data list a node is removed from the free space list.
When an item is deleted from the data list it is linked into the free space list.
At this stage the table just consists of a linked list free space.
1. Store the new name in the node pointed to by the next free.
2. Change the next free to point to the new next free.
3. Follow the links to find out where the new item should be linked in.
4. Change the new items pointer to point to the next item.
5. Change the previous items pointer to point to the new item.
Pseudocode
node(nextfree).nam = newname
tempfree = nextfree
nextfree = node(nextfree).pt
follow = start
DO UNTIL node(node(follow).pt).nam > newname
follow = node(follow)).pt
LOOP
node(tempfree).pt = node(follow).pt
node(follow).pt = node(tempfree).pt
Before we can work out the full pseudocode we need to identify the special cases.
They are:
10.4 Queues
In a queue, new items are added at the end.
Items are retreived (or deleted) from the front of the queue.
The simplest way of implementing a queue in memory is to use an array with four
variables.
Example
Now David, Debbie and Sam join the queue. Roy and James leave.
Items leave from the front. If front > limit then front = 1.
Items are added to the rear. Add one to rear pointer. If rear > limit then rear = 1.
First check that the queue is not empty. If it is not empty then the first item is placed into
a variable, the front pointer in incremented (cyclically) and the size is decreased by one.
10.5 Stacks
New items are added to a stack by placing then on top of the stack (called pushing).
Stacks are used in calculations and translating from one computer language to another.
A stack is used to keep track of the scopes encountered. This works by going left to right
and:
So for p + (q × [x - y] - {s - t} / q)
The comparisons were valid each time the stack was popped and the stack ended up
empty so there were no errors.
Example
Each instruction in the program has an address. When a subprogram is called, the return
address (the next line) is placed on the stack. When the sub is exited the stack is popped
and program flow continues at the next line.
Every tre has only one root, but each node in the tree can be regarded as the root of a sub-
tree.
A binary tree is a special type of tree. Each parent can have no more than children.
We can store a list of names (or any other data) in a binary tree.
One important use of binary search trees is to rapidly retrieve a single data item.
The traversal algorithms (that extract data in these different sequences) are recursive.
Traversal Algorithms
Preorder Traversal
D-B-A-C-F-E-G
Inorder Traversal
A-B-C-D-E-F-G
Postorder Traversal
A-C-B-E-G-F-D
Binary trees can be implemented using left and right pointers at each node.
11.1 Introduction
11.1.1 Project Selection
A business organisation may have more than one reason for the introduction of
computers. Usually a particular area of the business is selected for computerisation.
• Have a very good understanding of the organisation and how computers can be
used.
• expansion
• change of business activities
• the economic situation
• technological advances
• or other factors
11.2 Analysis
11.2.1 Problem Definition
The first step is to write down the terms of reference.
Constraints
• Maximum cost.
• Avaliable equipment.
• Any business area not to be changed.
Technological Feasibility
Social Feasibility
What will be the effect on employees and customers if the new system is implemented?
Economic Feasibility
• The procedures
• The data
• The future
• News reports
• Problems
The following are ways of investigating existing procedures and the existing problems:
• Observation
• Reading existing documentation
• Questionnaires
• Task counting - by clerical staff
• Interviews
11.3 Design
In designing a new system all aspects of the design must be documented.
This involves:
11.3.2 Prototyping
This could involve using special software to quickly design input screens and validate
data input.
This gives the user a chance to experience the look and feel of the input process.
These are software tools that insist in the design or development of a system.
Processing Method
The systems designer will need to chose between Batch Processing and On-Line
Processing. This decision will be dependant on:
Software Solution
• Usability
• Performance
• Suitability
• Maintenance
Hardware Solution
• The software
• Volume of data
• Number of users and their locations
• Processing method
• Security considerations
This type of representation is concerned with how data moves through a system not with
such details as what type of data storage is used.
Source or destination of data external to the system.
Conventions
1. Data flows may not go directly to and from data stores and entities.
2. Data flows must be labelled to indicate what data is been transferred.
A systems flow chart shows an overview of the whole system. In particular it represents:
Input/Output
Keyboard Input
Process
Manual Operation
Sort
Online Storage
Magnetic Tape
Disk Storage
Visual Display
Example
Each program in the system must have a specification written for it which describes what
it will do (and how it will do it).
Applications Generator
These are software tools that generate complete systems. The user defines the input,
output, data, files and what the system needs to do. The applications generator then
produces the program code.
Report Generator
A report generator will produce reports from information supplied by the user. The way
that they work is that the user supplies the headings, the fields to be printed, what order
they are in, the space to allow for each field and what totals are required.
The CASE software tools that aid the programmer in the development stage are:
• A source code generator
• A data dictionary tool
Applications Packages
Programs may not need to be written for the new system. If an "off-the-shelf" package
may be suitable then it is the analyst's job to evaluate the package and make sure that it
will meet the requirements.
Following the hardware considerations in the design stage of the life cycle, sutiable
equipment needs to be acquired.
11.6 Testing
11.6.1 Acceptance Testing
The tasks the finished system must perform in order to be accepted (by the user) can be
used as the basis for different tests.
Bottom-Up Testing
The individual modules are tested in a stand-alone fashion. The individual modules are
combined and tested. Finally, a system test is performed.
Top-Down Testing
The whole system (or at least a skeleton of it) is tested. Individual modules, yet to be
completed, are replaced by 'stubs'. Stubs often display a message on screen to show that
the module has been called.
A test plan should be developed which will go through as many paths as possible in the
system.
It should include:
We need to ask:
We test the program by examining the code and trying to test each possible path in the
program at least once.
In Black Box we are not concerned with the program code. The progarm specification is
used as the basis for producing a set of test data that covers all the inputs, outputs and
program functions
Performance Testing
The system is tested to see if it can handle the volume of data anticipated in the user
environment.
Recovery Testing
Here we need to ensure that the system can recover from various types of failure.
Before the new system can come into operation hardware will probably have to be
installed. This may include:
• New computers
• New peripherals
• New office layout and furniture
Prior to the new system going live, all the staff involved in the system will need hands on
training.
All the master files will have to be created before the system can be used.
Phase 1
All the data that will not change can be typed in over a few days or weeks.
Phase 2
Data that is liable to change needs to be keyed in just before the changeover to the new
system.
Direct Changeover
The organisation stops using the old system one day and starts using the new
system the next.
Advantages
o Fast
o Efficient
o Little or no duplication of work
Disadvantages
Parallel Conversion
The old system is kept running alongside the new system for a few weeks or
months.
Advantages
o The old system can be relied upon while any problems with the new
system are fixed
o Results from the new system can be checked against the old system
Disadvantages
This is used with larger system that can be broken down into several stages.
Pilot Conversion
11.8 Maintenance
11.8.1 Post Implementation Review
This is carried out several weeks or months after the system has been implemented.
For example:
• Correct program errors
• Amend clerical procedures
• Modify screen and report formats
Here we are concerned with taking an acceptable system and making it better.
There may still be problems with our system that need to be corrected.
A system specification
System flow charts or data flow diagrams
Program descriptions
Structure diagrams, program flow charts and pseudocode
Files or database descriptions
Layouts for screen display and reports
Current program listings
Test data with expected results
Clerical procedures manual
This describes the activities that clerical staff undertake when preparing data for
input to the system.
Operating instructions
This details how to enter data what format the data should be in.
• A user manual
• A technical manual/operations manual
• Tutorials
Such a system is used in a batch environment where several thousand documents need to
be keyed in every day.
Step 1
A key station operator runs the data entry program and keys in a batch of data.
Step 2
Step 3
Step 4
Step 5
The original batch is verified and discrepancies are checked and corrected.
Step 6
The completed batch is transferred to the mainframe for processing (either on tape or
electronically).
12.1.2 ???????
12.1.3 ???????
The scanner shines a bright light onto the image been scanned while a mirror reflects a
strip of the image onto a bank of photosensors.
The ink head used to print the characters at the bottom of the cheque contains iron oxide
which can be magnetised during processing.
Uses of OMR
OMR forms can be used where answers are sought to 'closed' questions.
Examples:
Cash machines (ATMs) use a keypad and a magnetic strip card as input devices.
The bank card is encoded with:
When a customer inserts the bank card and enters a PIN number which is then checked
against the PIN on the card and if possible, the PIN number held in the customer's record
on the bank computer.
If the customer then wishes to withdraw cash the following checks are made:
A touch screen allows the user to provide input by touching an area of the screen.
• Industrial environments
• Retail order processing
• Public information systems
In general they are useful when the operator is moving but not so useful when the
operator is at a desk.
Graphics Tablets
• Tracing a drawing
• Computer aided design
A LASER beam passes rapidly across the barcode on the item been purchased.
The reflected light is picked up by a photosensitive cell and the numeric code is
calculated.
The price and description of the item can then be looked up in a master file.
Most Point of Sales 9POS) terminals can automatically deduct money from the customers
bank account. Such systems are known as EFTPOS systems.
Daisywheel Printers
Line printers print off one line at a time. However this is not quite true.
A drum with rows of the same letter embossed upon it rotates at high speed. All the As
are printed for a given line, then the Bs, etc.
This is done by hammers that strike the paper on the other side to the embossed
characters.
Ink jet printers work bydirecting a fine jet of ink at the paper.
Advantages:
Disadvantages:
Laser printers fuse powdered ink/toner onto the paper by heat and pressure.
Advantages:
Disadvantages:
12.2.4 Plotters
Plotters are used to produce high quality line drawings.
Most plotters are vector plotters. They move a pen using point to point data.
Advantages:
Disadvantages
• data integrity
• storage capacity
• access time
• data transfer rate
• low cost
Formatting a disk marks out concentric tracks and sectors on both of the surfaces of the
disk.
The hard disks inside PCs consist of one or more disk platters sealed inside a casing.
The read/write heads float on a cushion of air about one millionth of an inch off the
surface of the disk.
Advantages:
Disadvantages:
CD-R (WORM)
Advantages:
Disadvantages:
CD-RW
Advantages:
Disadvantages:
DVD-ROM
Advantages:
• Increased storage capacity
• Marginally faster data transfer than CD-ROM drives
Disadvantages:
• DVD-R
• DVD-RW
• DVD-RAM (likely to become standard)
• Backup
• Archiving
• Batch Processing
It is inexpensive, robust and has a large data storage capacity with a very fast data
transfer rate.
Mainframe Environment
Minicomputer Drives
Uses:
• Black box flight recorders
• Satellites
• Fighter aircraft weapon systems
A computers memory can be thought of as a series of boxes each containing one byte (or
more) of data.
Each memory location has its own unique address counting from zero up.
The CPU is connected to the main memory by two sets of wires (or buses).
• Address Bus
When the CPU wishes to access a particular memory location, it sends its address
down this bus
• Data Bus
The contents of the memory location requested are sent down this bus.
This is the number of bits that the CPU can process simultaneously.
13.1.5 Memory
Memory Mapping
Some RAM is reserved for a special function (e.g. OSs or addresses and paramters (on
the stack)).
Cache is a small amount of fast memory that acts as a intermediate store between the
CPU and memory.
It is fast because:
Two principles are used in decoding what data to copy from conventional RAM to cache.
• Temporal Locality
An instruction that has been accessed once is likely to be accessed again in the
near future.
• Spatial Locality
It is likely that data items near previously accessed data items will be accessed in
the near future.
Registers
Registers are special storage locations to hold data whilst its been decoded or
manipulated.
Additionally, the CPU has to control all data transfer between peripherals and main
memory.
When there is a need to transfer data to an input/output (I/O) device an interrupt is
generated and the CPU deals with the transfer.
Internal buses connect the various registers and components of the CPU.
External buses connect the CPU to the main memory and the periherals.
Single Bus
With multiple units the number of single bsues required grows rapidly.
Advantages
Disadvantages
Shared Bus
Advantages
Disadvantages
These instructions are fetched and executed one at a time. These instructions are stored in
main memory just like any other data. This is known as the stored program concept.
13.4.2 Pipelining
Both the Von Neumann architecture and its pipelined version are classified as single
instruction stream, single data stream (SISD).
This architecture is known as single instruction stream, multiple data stream (SIMD).
In this system, multiple instruction streams operate on multiple data streams (MIMD).
The CPU consists of several control units and several ALUs. These processing elements
have to be co-ordinated.
Example Program
MOVE #100, R0
MOVE #112, R1
RTS
In the ASM Tutor memory locations 5 to 14 map to the mapped memory window.
MOVE #'H', 5
Immediate Mode
Here the operand holds the address of the data to be used in the instruction.
Indirect Mode
In this mode the operand holds a register/memory location that in turn holds the address
of the data to be used.
MOVE (R1), R0 - Moves the contents of the memory location that is
referenced by register R1 into register R0.
Indexed Mode
The operand address is calculated by adding a base address to a value in a register (often
called the index register).
MOVE 200(R0), 129 - Move the value from the address stored in R0 + 200
to address 129.
Relative Mode
The contents are changed by clicking on the appropriate key in the interrupt window.
Jumping
JUMP <address>
For example
Sub-routines
RTS - Return to the next instruction after the JSR that invoked the sub-rotuine.
• to access a file
• to display a window
• to get input from the keyboard
To Output A String
To Input A String
i. Place the start address of the buffer to receive a string into R0.
ii. Place the size of the buffer into R0.
iii. JSR 88
Addition
The source is added to the destination. The sum is placed in the destination.
Subtraction
The source is subtracted from the destination and the result is left in the
destination.
Conditional flow control can be acheived by comparing two values and branching,
depending on the result.
First use:
After an arithmetic operation the result may be negative or an overflow may occur.
These operations are used to manipulate the individal bits in memory locations.
The AND operator takes two inputs and gives one output.
The output will be only be 1 if both the first and the second inputs are 1.
When several logical operators are applied to values represented by several bits the
answer is calculated in a bitwise manner.
E.g.
The OR Operator
The output will be 1 if either the first, second or both inputs are 1.
0011 0011
This can be generated from the binary code for 310 by:
0011 0000
Input Output
0 1
1 0
In an 8 bit system:
ASM Syntax
AND and OR take a source and a destination which are treated as input 1 and input 2.
The results are then replaced in the destination.
NOT takes a single address or register and swaps the 1s and 0s.
• Logic
• Arithmetic
• Rotate
Logical Shift
A logical shift causes the m.s.b. to be shifted to the carry bit (in the status register) and
zero moves to the l.s.b.
ASM Syntax
Arithmetic Shift
This results in multiplying or dividing the value by 2. Arithmetic shifting takes account
of two's complement negative numbers.
ASM Syntax
Rotational Shift
Here the bits in an address are are physically rotated left or right. The bit that jumps from
one end to the other is replicated in the carry bit.
ASM Syntax
ROL #1, <address> - Rotate left (one place)
ROR #1, <address> - Rotate right (one place)
It is useful to be able to work out the equivalent assembly language code for high-level
constructs.
FOR K = 1 TO 10
DO N to N + 1
END FOR
14.1 Interpreters
An interpreter analyses the high level source code, statement by statement.
Advantages
14.2 Compilers
A compiler translates an entire high level program into machine readable object code
prior to execution.
Advantages
1. Lexical analysis
2. Syntax and semantic analysis
3. Code generation
Print A$
becomes...
Print A$
This is the process of checking to see that the sequence of input characters is a valid
sentence.
Examples
This table contains an entry for every keyword, variable, constant and operator (called
identifiers)
Input Radius
Token Item Name Kind of Item Data Type Run Time Value
1
2 Input Keyword
3 Pi Constant Single 3.1415926536
4 Radius Variable Single ?
5 = Operator
6 Area Variable Single ?
7
8 * Operator
Using this table, the program can be tokenised as the lexical string:
24
6538484
Note that the syntax analyser fills in the columns "Kind of Item" and "Data Type". The
lexical analyser only adds the "Item Name" and "Run Time Value".
The most common way of organising the symbol table is to use a hash table. The
identifier is hashed to a memory location.
In this final phase the machine code (or object code) is produced.
Code Optimisation
Some compilers attempt to make the object code run quickly by removing redundant
instructions and by spotting better ways to produce the same effect as the source
program.
Disadvantages
14.4 Assemblers
The assembler program converts assembly language into machine code.
These are instructions to the assembly program that do not have a machine code
equivalent.
- - -
- - -
- - -
ADDUP 300, 301, 302
- - -
- - -
User Interaction
1. Memory Management
2. CPU Sharing
3. Input/Output (I/O) Control
4. Backing Store Management
5. Interrupt Handling
6. Operator Interface
7. Utilities (eg. Defragmenter)
8. Security Facilities
9. Accounting Facilities
15.2 Different OS Modes
These modes decide the method of program execution.
It is often used with batch processing where tasks can be assigned different priorities and
actions can be taken on errors.
High-Level Scheduling
The scheduler decides which jobs are allowed into the queue for resources and what their
priorities are.
The dispatcher decides which process is allocated CPU time when the CPU becomes
avaliable.
The aim is to make the most effecient use of the computers resources.
Objectives
1. Maximise throughput
2. Maximise the number of users with acceptable response time
3. Balance resource use
4. Enforce priorities
5. Avoid repeatedly sending low priority jobs to the back of the queue
Not all of these objectives can be fulfilled at once. For example: we need to acheive a
balance between response time and resource utilisation
Advantages
Disadvantages
• The user has to estimate how long the jobs will take
In early multi-programming systems the main memory was divided up into a number of
fixed sized partitions.
Each partition held a single job. A job can only be in one partition.
Proccesses to be run are held on disk. While a proccess gets CPU time the OS transfers
the correctly running proccess to disk and the next proccess to memory.
Paging
Data is transferred between memory and disk. Paging means that a fixed number of bytes
is swapped between disk and main memory.
The operating system has to keep track of where the parts of a program are at any given
moment.
For each running process, the OS maintains a map showing which blocks of virtual
storage are currently in real storage and their locations.
Segmentation
Programs are divided up into different sized segments which may be loaded into non-
contigous areas of memory.
Device drivers are small programs that contain details on how to communicate with a
particular peripheral. They form part of the OS.
15.6.2 Buffering
A buffer is an area of memory or a memory module used for holding data during I/O
transfer.
Once the CPU issues the 'start' instruction the I/O channel can place data in a buffer while
the CPU is busy.
Because different peripherals have different buffers and I/O channels autonomous
operation of peripherals is permitted.
15.6.3 Spooling
The technique allows effecient communication between devices that operate at different
speeds. The high speed device spools or writes ita data to disk and the slow speed device
can read it later.
15.6.4 Polling
One unit (often the CPU) checks the status of another (often a peripheral) at frequent
intervals.
Polling takes up large amounts of processor time and an interrupt system is usually
preferrable.
An interrupt is a signal generated by an event that alters the sequence in which the CPU
executes instructions.
The hardware generates the interrupts but the interrupts may be related to current
processes.
The interrupt register inside the CPU contains one bit for every different interrupt.
At the beginning of the FE cycle the interrupt register is checked and if a bit is set then
the state of the current process is saved and the OS gives control to the appropriate
interrupt handler.
The interrupt handlers are programs which carry out the action required by an interrupt.
Interrupt Masking
This term refers to the ability to enable and disable peripherals by software instruction.
• Access methods
• Files
• Free Space
• First fit
• Best fit
When backing store media are capable of holding more than a few files, it is common to
organise the files into directories.
These directories can then be organised into a hierarchical (or tree) structure.
Some operating systems (not DOS) give access rights to all the levels above a particular
user.
C
Fortran
Delphi
Uses
They consist of a series of statements which act act on a given set of data.
Programs are usually designed in a top-down fashion.
• If the structure of the data changes all the programs that use the data must change.
• If the way the system function changes then program alterations will be
widespread.
Objects
An object is a data item with characteristics in common with other objects in its class.
Inheritance
Such classes have their own extra characteristics and are known as derived classes.
Encapsulation
Each object has its own functions and data. The data can only be accessed through
functions that belong to the object.
Examples of events:
Example:
male (joe_bloggs)
car (ferrari)
owns (joe_bloggs, ferrari)
? male (joe_bloggs)
output: Yes
In the 4GL the programmer sometimes specifies what is to be done, rather than how to do
it.
It is the close integration of the DBMS with a programming language that leads to it
being classified as a 4GL.
These are computer programs that attempt to replicate the performance of a human expert
on some specialised reasoning task.
A Knowledge Base
As well as containing facts on who is male and female and who is a parent of whom, the
knowledge base also consists of rules.
? - brother(X, Liz)
Output: X = Bob
Applications
Syntax Rules
Both computer languages and natural languages have well defined syntax rules which
determine whether a statement is correct or not.
Vocabulary
Ambiguity
Factors to consider:
Coaxial Cable
Coaxial cable (simliar to that used in television systems) has an outer mesh which is
'earthed' and shields the signal in the inner wire. The inner wire carries the signal.
Pros
• Inexpensive
• Accurate data transfer
Cons
Pros
Cons
• Susceptable to interference
Pros
• Cost
• Cable cannot bend around tight corners
• Difficult to interface with computer
Microwave Transmission
Pros
Cons
Satellite Transmission
A one or two-way link can be established by using a satellite (in geosynchronus orbit)
and a dish.
Pros
• Good bandwidth
• No wiring or boosters needed
Cons
• Expensive
• Possibly insecure
Simplex
Data can be sent in both directions but not at the same time.
OR
Full-Duplex
The speed at which data is transmitted is measured in bits per second (bps).
The bandwidth is the maximum speed at which data can be sent along a communication
channel.
A parity bit can be transmitted with the code for each character.
An element of redundancy can be introduced with 2D parity. This allows corrupted data
to be recovered.
Analogue Systems
Digital Systems
• An ISDN line
• A LAN connection
• A digital radio network
• A phone line with ADSL
This has a maximum bandwidth of 9Mbps and runs over a standard telephone line.
Parallel transmission is not pratical for long distance communication. This is because of
the cost of manufacturing the wires.
17.1.7 Multiplexing
Multiplexing allows more than one signal to be sent over a single link at one time.
There are two main methods of doing this:
The transmission time is broken up into slices and each device wishing to transmit can
take a packet in turn.
Different frequency carrier waves are used to send many signals over the link. A high
bandwidth is required for this.
At the heart of the process is the method of looking for repeated patterns and replacing
them by one copy of the bit pattern plus the number of times it occurs.
This network topology involves connecting each workstation to the server separately.
Advantages
Disadvantages
• Costly to install.
• Easy and inexpensive to install as this topology requires less cable than any other.
• Adding more stations is relatively easy.
Disadvantages
In a ring network there is no central controlling computer. Messages are passed from
computer to computer (in one direction) until they reach their destination.
Advantages
Disadvantages
A circuit switched network is one where switches are used to connect two computer
systems for a given length of time. The path does not change.
Advantages
Disadvantages
With packet switching the messages (or other data) are divided up into fixed length
blocks of data called 'Packets'.
These contain:
Advantages
• Communications channels are used more efficently because channels are not 'tied
up' when transmission is not in progress. Also, because data is sent in packets,
data compression can be used.
• More more resiliant to network failure.
• Data is more secure becuase packets are sent down various routes.
Disadvantages