M150 Data, Computing and Information

advertisement
DATA, COMPUTING AND INFORMATI
1
Haifaa Elayyan
M150 – UNIT 6
UNIT 6: FIVE THEMES

Unit 6 sets the scene by providing you with some useful background about
the components of the computer that are involved when a program is run,

2
and some of the structures that programs employ.
Distinguishing: Computer as a system that is made up of Software, Hardware
and Firmware.

Describing: Functions of different components of a computer ( memory, OS,
mother board, etc….).

Collaborating: Different computer components to process a computer program.

Understanding: How computer understand our commands???!!!.

Introducing: The mechanism of how the software is going to skip or
sequence of instructions
AO
U
repeat Leb.
aF08
M15
0Unit
EARLY COMPUTING MACHINES AND THEIR
INVENTORS

Haifaa Elayyan
From the time that numbers were invented
humans have invented devices to help in
manipulating them. The abacus, of which the
oldest surviving example dates from 300 , is still
used today. The Roman abacus, in use between
the second and fifth centuries consisted of beads
strung on a number of wires and the Roman word
for the beads used, calculus, give us the modern
word ‘calculator
3
EARLY COMPUTING MACHINES AND THEIR
INVENTORS

Haifaa Elayyan
The first mechanical calculating device, which used a
system of cogs, was invented by William Schickard in 1623.
Schickard, like the famous astronomer Kepler, was born in
Wu¨rttemberg, Germany, and Kepler used Schickard’s
machine for his astronomical calculations. Because the sixdigit numbers manipulated by the machine were
insufficient for Kepler’s needs, the device came with a
number of rings, which the operator could add to his
fingers in order to keep track of higher order digits! Figure
1.2
4
EARLY COMPUTING MACHINES AND THEIR
INVENTORS

Haifaa Elayyan
In 1694 the German mathematician and
philosopher, Gottfried Wilhelm von Leibniz
improved the Pascaline by creating a machine
that could also multiply, but it was not until 1820
that Charles Xavier Thomas de Colmar, a
Frenchman, invented a machine that could
perform the four basic arithmetic operations
5
HARDWARE, SOFTWARE AND COMPUTER
SYSTEMS

we will discuss what hardware, software, and computer systems are.
Then we will focus on how computer hardware and software components
work together to execute computer programs.
The aims of this section are to:

explain that a computer program is a sequence of instructions fo

performing a certain task on a computer;

explain that hardware consists of the tangible parts of the computer;

Haifaa Elayyan

show that hardware and software solutions can be logically equivalent –
that is, a task carried out on a computer using software might be
reproducible using hardware, and vice versa;

describe the information system model of a computer;

describe the nature of data and instructions as they are stored in a
computer;

recount the history of some early computing machines.
6
SOFTWARE VS. HARDWARE
Haifaa Elayyan
You will be learning about both hardware and software so it
is helpful to consider the relationship between them.
 Hardware consists of the tangible parts of the computer
system – ‘the parts that can be kicked’. Examples of
hardware include the electronic circuits inside the casing,
the keyboard and hard disk.
 Software, on the other hand, is more abstract – it consists
of sets of instructions that tell a computer how to perform a
particular task. Examples of software are word-processor
applications such as Microsoft Word, browsers such as
Explorer or Netscape, and communications software such
as FirstClass. The terms software and computer program
are often used synonymously, though it could be argued
that software is generally made up of a number of
programs
7
CONTINUE


0 + 3 gives a result of 3 (first addition)

3 + 3 gives a result of 6 (second addition)

6 + 3 gives a result of 9 (third addition)

9 + 3 gives a result of 12 (fourth addition)
Haifaa Elayyan
Although software and hardware are very different in nature,
they are also inextricably related. Any instruction performed by
software can also be built directly into hardware, and instructions
executed by hardware can often be simulated in software. As an
illustration let us consider the multiplication of two numbers. One
way of thinking about multiplication is to consider it as a number
of additions: starting with nothing (zero) you need to add a
particular number (one of the numbers to be multiplied) a
specified number of times (the second number to be multiplied).
For example, to multiply 3 by 4, we need to add 3 to 0, then add 3
to the result, and so on, until we have added 3 four times, as
follows:
8
CONTINUE

The hardware and software solutions are logically equivalent –
they both use repeated addition – but the hardware solution uses
several ‘tangible’ electronic circuits, whereas the software solution
uses the more abstract idea of ‘instructing’ the machine to use the
same circuit repeatedly. The decision to implement some
functions in hardware and others in software is based on factors
such as speed, cost and reliability. You will learn how to write
your own software (computer programs) in Units 7 to 10. 9
Haifaa Elayyan

Now suppose that a computer has hardware (i.e. an electronic
circuit) to carry out a simple arithmetic instruction such as ADD.
Since multiplication is nothing more than repeated addition, we
could construct a new circuit (or piece of hardware) made up of a
number of ADD circuits that, working together, can multiply two
numbers. Alternatively we could instruct the computer, using a
computer program, to perform repeated addition using the
existing ADD circuit .
9
UNIT 6: AGENDA
Hardware, Software and Computer system

The resources of a computer , and how they are
managed.

Running a program.

Types of programming languages.

The structure of computer programs.
10

AO
U
Leb.
F08
M15
0Unit
UNIT 6: HARDWARE, SOFTWARE AND
COMPUTER SYSTEM
Hardware vs. Software

Computer Hardware and Software components work together in order to execute
computer program

Hardware: describes the physical parts of computer that can be touched.

Software: describes the information or the programming the computer uses, you
can't touch it .
11


Firmware is the term used to refer to a sequence of instructions (software)
etched into the read-only memory (ROM) of the computer, usually to perform
some system function. Because these instructions are on a chip they form a
permanent part of the computer and could be viewed as a combination of AO
U
hardware and software.
Leb.
F08
M15
0Unit
UNIT 6: FIRMWARE
a software program or set of instructions programmed on a
hardware device (usually in the ROM)

It provides the necessary instructions for how the device
communicates with the other computer hardware

can be thought of as "semi-permanent" since it remains the
same unless it is updated
12

AO
U
Leb.
F08
M15
0Unit
UNIT 6: EXAMPLE1
video to a
I contacted my DVD drive manufacturer and they suggested
update the firmware on the DVD drive.
that I
The updated Firmware had a new set of computer code for my
instructing how to write to the DVD I’m using
drive
13
"I bought a 100-pack of empty DVD discs and tried to burn a
few of them but it would not work".
AO
U
Leb.
F08
M15
0Unit
UNIT 6: HARDWARE VS. SOFTWARE
Although Hardware and Software are different in nature,
there are related.

A solution to a computer problem can be implemented using
either Hardware or Software.

Hardware uses several tangible electronic circuits.

Software uses instructions to use same circuits.
14

AO
U
Leb.
F08
M15
0Unit
UNIT 6: REFLECTION 1
EX: 2.3
Which view is analogous to Software and which to
Hardware?
15
A book could be thought of as being made of paper and
ink, or
it could be thought of as being a collection of words and
sentences.
AO
U
Leb.
F08
M15
0Unit
UNIT 6: COMPUTER AS A SYSTEM

16
The tutor asked us to define computer, after a discussion the result was a
computer is a machine that Accepts input, Process Input then it gives a result
as an Output.

So every machine that Accepts input, Processes that input, and produces
Output is called a system
Perfect
Then my mother’s Washing machine is a system
Yes
Or
No
AO
U
Leb.
F08
M15
0Unit
UNIT 6: AGENDA
Hardware, Software and Computer system

The resources of a computer, and how they are managed.

Running a program.

Types of programming languages.

17

The structure of computer programs.
AO
U
Leb.
F08
M15
0Unit
UNIT 6: REFLECTION 2
EX:3.1
18
In what form are the data and Instructions stored in a
computer?
Well, it is the easiest question so far , All data and instructions
saved inside the computer ( in Memory) , read and accessed by
CPU in order to execute these instructions are in Machine
language ( 0/1) – Digital form .
COMPUTER SYSTEM :

Our view is that a computer differs from a calculating device in
that it includes a mechanism that stores not only the data but
also the instructions for processing that data, and the results that
are to be output. If we have a computer at the heart of our
information system we can extend our model as
Haifaa Elayyan

One simple view of an information system is that it is a machine
that can solve problems by carrying out a sequence of
instructions, usually on a given set of data. The data provided is
usually referred to as input, and the solution (or results) produced
is referred to as the output.
( Input --- ( Process/ Storage) -- Out put
This is what we call information system based on computer .


The word ‘process’ has a very particular meaning in some areas of
computing. In this unit we are using it to refer to all the
processing (or manipulation) of the input so as to produce the
output.
So far , system is what ever accepts ( input) , process this input (
execute, compute ) accordingly by executing specific instructions ,
then produce result .
19

ACTIVITY 2.2
Discussion



The whatis.techtarget.com website has the following definition:
A computer is a device that accepts information (in the form of digital data) and
manipulates it for some result based on a program or sequence of instructions on
how data is to be processed.
Complex computers also include the means for storing data (including the
program, which is also a form of data) for some necessary duration. (accessed 11
July 2003)

The webopedia website defines a computer as:

A programmable machine. The two principal characteristics of a computer are:

It responds to a specific set of instructions in a well-defined manner.

It can execute a prerecorded list of instructions (a program).

The first definition emphasizes the digital nature of the data that is manipulated
by the program, and it also mentions the storage of instructions and data, but only
for ‘complex’ computers. The second definition does not mention digital data or
storage, but it requires that the computer must respond to the instructions in a 20
well-defined manner. Both definitions agree that a computer executes a list of
instructions called a program.
Haifaa Elayyan
Use two online dictionaries (they could be the ones mentioned in Activity 2.1, or any
others) to look up the term ‘computer’. Compare the two definitions.





Input, output and instructions:
The input to a computer process starts off as words or numbers
entered from a keyboard. However it can take other forms, such as
images, sound, or digital information from scientific instruments.
Sometimes data will already be available in the computer as a file, in
which case the input might be via mouse clicks or some other input
device.
In modern computers, all data, including the instructions that make
up a computer program, are stored in the computer as binary digits
(bits) – sequences of zeros and ones. The branch of mathematics that
defines the rules governing the manipulation of entities with only two
states, such as bits, is called binary logic (or Boolean algebra – after
the Englishman, George Boole, who developed it in the middle of the
nineteenth century).
It is important to be aware that at a fundamental level computer
processing is simply the application of logic to binary numbers.
Of course in order to make the results readable by humans, the binary
representations of the output need to be ‘translated’ back into an
appropriate format.
Haifaa Elayyan

A computer is a device that accepts data and manipulates it by
carrying out a sequence of instructions (a program), so as to produce
some output. A computer also has the means of storing the input, the
output and the program.
21

EXERCISE 2.5
Hardware, software and computer systems





(a) Could this be described as a computer according to the two website
definitions given in the discussion following Activity 2.2?
(b) Does it fulfil the M150 course definition, as given after the same
discussion?
Discussion
Haifaa Elayyan

In History snippet 2 you learned about Babbage’s analytical machine.
(a) Babbage’s machine could respond to a series of instructions in a
well-defined way, and so it could be described as a computer according
to the webopedia definition. However, the analytical machine did not
process digital data and so it is not a computer according to the
whatis.techtarget definition.
(b) According to the M150 definition, a computer must be able to store
data, instructions and results. The analytical machine did not have
storage space for the instructions (they were to be input using
punched cards) and so it cannot be considered to be a computer
according to our definition.
22
INSIDE THE COMPUTER SYSTEM :

Haifaa Elayyan
You learned that the circuits at the heart of a
computer system consist of switch-like electronic
components and that all data and instructions
are stored in the computer as sequences of binary
digits (bits), which are manipulated using binary
logic. You read about some of the early machines
which are considered to be the forerunners of
today’s computers.
23
THE HEART OF THE COMPUTER – THE
CENTRAL PROCESSING UNIT (CPU)
Computer processes manipulate binary
representations of data, using instructions that
are themselves stored in binary format. The
component of the computer in which this
manipulation of binary data takes place is
referred to as an arithmetic/logic unit (ALU).
Movement of data between the ALU and other
parts of the computer is coordinated by the
control unit.
 The terms ‘processor’, ‘microprocessor’ and ‘CPU’
are often used interchangeably. The term
‘microprocessor’ usually refers to the chip on
which the processor is implemented.

Haifaa Elayyan
24
CONTINUE

Haifaa Elayyan

Within both the ALU and the control unit are small
numbers of memory locations known as registers which are
used to hold single pieces of data or single instructions
immediately before and after processing. The ALU and the
control unit along with their registers are together referred
to as the central processing unit (CPU) or processor of a
computer. A much larger area of memory, known as main
memory, is where the data and instructions that are not
immediately required are held, and where results are
eventually stored.
Individual pieces of data and instructions are moved from
main memory into the registers as required. The registers
are built from more efficient (and expensive) memory than
main memory, thus allowing fast access and transfer of
data.
25
CONTINUE
The processor of a PC is usually on a single
microchip,(or microprocessor) which can contain
several tens of millions of circuits. Processors
come in ‘families’, such as the Pentium 4,
Celeron, AMD Athlon XP. Each family of
processors has what is termed an instruction set.
This is the collection of basic instructions, called
machine language instructions, which a
particular processor understands .
 The terms ‘machine language’ and ‘machine code’
are synonymous, but we will be using machine
language in this unit.

Haifaa Elayyan
26
The CPU together with the way in which memory, internal
communications and input/output are organised define an
architecture for a computer that has been well established
since the 1940s when it was first described by the
 mathematician John von Neumann. Characteristic of the
von Neumann architecture is the fact that the program
instructions are stored in the main
memory along with the
data.
Figure 3.2 shows how data
moves between the various
components. The data flow is
coordinated by the control unit,
through the sending and
receiving of control signals.

Haifaa Elayyan
27
UNIT 6: HARDWARE :
CPU – THE HEART OF COMPUTER
The Central Processing Unit: (CPU also called processor) is the part of the computer that
executes program instructions. It consists of two parts:

1.
The Arithmetic and Logic Unit (ALU) is where all calculations and logical operations
are performed.
28

a- Arithmetic operations involve addition, subtraction, multiplication, and division.
b- Logic operations basically consist of comparing or combining two values:
• All ALUs can compare >, <, and =.
• Some ALUs can also compare >=, <=, and <>.
• Comparisons can be combined using the logical operations NOT, AND and OR.
Truth tables are used to formally define these logical operations.
AO
U
 2.
The Control Unit (CU): The control unit interprets program instructions. The control
Leb.
unit communicates with main memory and with input and output device controllers. The
control unit directs the ALU to execute program instructions.
F08
M15
0Unit
UNIT 6: CPU – THE HEART OF COMPUTER
The CPU Registers : are high-speed storage locations
within the CPU, used for specific tasks:

Memory Data Register (MDR) is used to hold data that are being
transferred to or from primary storage.

Memory Address Register (MAR) indicates the location of the data to be
stored or retrieved from primary storage.

Instruction Register (IR) holds the instruction being executed.

Program Counter (PC) holds the primary storage address of the next
instruction to be executed.
AO
 The address held in the PC ,instruction cycle
U
 insures sequential execution of instructions.
Leb.
 Jumps to another part of the program are achieved by instructions,
F08
which reset the contents of the program counter.
-
29

M15
0Unit
UNIT 6: CPU – THE HEART OF COMPUTER
Accumulator (AC) holds the results of ALU operations.

Program Status Register (PS) contains binary flags that signal the results
of the previous operation.
30

For example the carry bit will be set to 1 if the last arithmetic operation
lost a carry bit, and to 0 otherwise. Other condition codes indicate whether
the last result was negative, zero or overflowed.

General-purpose registers are used for different purposes.

The first three registers are used by the control unit and are not
accessible to the programmer.

The arrangement of registers define the processor architecture.
AO
U
Leb.
F08
M15
0Unit
REGISTERS


Arithmetic/logic unit (ALU)
The arithmetic/logic unit is the part of the CPU where the arithmetic
and logical operations are carried out. It contains a number of
registers where data is held directly prior to and following processing.
Among other things, the ALU can:

add

subtract

compare

multiply and divide (which may be derived from adding and

subtracting).
Haifaa Elayyan

We stated that registers are very fast, efficient areas of memory that
are located in the CPU and used as a holding area for all the data and
other information needed during the processing of a program. In fact
there are a number of different types of register, some located in the
ALU, some in the control unit, and each designed to hold a particular
type of information .
31
INSTRUCTION CYCLE
Each computer's CPU can have different cycles
based on different instruction sets.
 1. Fetch the instruction from main memory
 The CPU presents the value of the program
counter (PC) on the address bus. The CPU then
fetches the instruction from main memory via the
data bus into the memory data register (MDR).
The value from the MDR is then placed into the
current instruction register (CIR), a circuit that
holds the instruction temporarily so that it can be
decoded and executed.

Haifaa Elayyan
32
INSTRUCTION CYCLE
Decode the instruction
 The instruction decoder interprets and
implements the instruction. The instruction
register (IR) holds the current instruction, while
the program counter (PC) holds the address in
memory of the next instruction to be executed.
the machine cycle or instruction cycle is generally
divided into four parts:- 1)Fetching a instruction
2)Decoding a instruction 3)Executing a
instruction 4)storing the instruction
2. Fetch data from main memory
 Read the effective address from main memory if
the instruction has an indirect address. Fetch
required data from main memory to be processed
and placed into registers.

Haifaa Elayyan
33
INSTRUCTION CYCLE
Haifaa Elayyan
3. Execute the instruction
 From the instruction register, the data forming the
instruction is decoded by the control unit. It then passes
the decoded information as a sequence of control signals to
the relevant function units of the CPU to perform the
actions required by the instruction such as reading values
from registers, passing them to the Arithmetic logic unit
(ALU) to add them together and writing the result back to
a register. A condition signal is sent back to the control
unit by the ALU if it is involved.
4. Store results
 Also called write back to memory. The result generated by
the operation is stored in the main memory, or sent to an
output device. Based on the condition feedback from the
ALU, the PC is either incremented to address the next
instruction or updated to a different address where the
next instruction will be fetched. The cycle is then repeated.
34
SUMMARY

This cycle continues, as shown in Figure 4.1, until all the
instructions in the computer program have been carried out.

get an instruction from the program;

find and transfer any data necessary to perform the instruction;

Haifaa Elayyan

the instructions in a computer program are processed by the CPU,
that data and instructions are stored in main memory, but moved
to registers in the CPU as required, and that operations such as
adding and logical comparisons are carried out by the ALU. We
can summarise the steps carried out by the CPU in the execution
of a computer program as follows:
carry out the instruction (which may involve saving a result for
later use).
35

During each cycle the CPU must:

1

the program, which is stored in main memory;

2

appropriate register;

3

discussed in more detail in Subsection 4.2);

4

into the processor by placing it into an appropriate register;

5

number to another number);

6 place the result in an appropriate register;

7 if necessary move the result back to main memory so that it can be

used later in the processing;

8 update the program counter to hold the memory address of the next

instruction
locate the next (or if execution has just started, the first) instruction in
transfer this instruction into the processor by placing it into an
decode the instruction to see what it is to do (what this involves will be
Haifaa Elayyan
locate (in main memory) any data the instruction refers to, and fetch it
do the processing on the data that the instruction requires (e.g. add a
36
MAIN MEMORY


Haifaa Elayyan

A computer has a number of different types of memory (or data
storage). As a computer user you are probably most familiar with
main memory, often referred to as RAM, and file storage memory,
such as that provided by a hard disk. Main memory is used to
store a program of instructions and the data needed by the
program while it is running. Its contents are volatile, i.e. they are
lost when the computer is switched off. File storage memory is
memory that is used to store large amounts of data for use at
some later date. Unlike main memory, it is non-volatile, i.e. the
data is persistent – it is not lost when the computer is turned off.
We will consider only main memory in this subsection.
Main memory can be envisaged as a large collection of
sequentially ordered pigeon-holes, each of which can hold the
same number of bits, equivalent to the word size of the computer.
37
MAIN MEMORY


Haifaa Elayyan

The word size refers to the number of bits that the CPU can
manipulate at one time. It is determined by the size of the
registers in the CPU and the number of bits that can be moved
round the computer as a single unit. When people refer to
computers as being ‘32-bit’ or ‘64-bit’ machines they are referring
to word size. Older personal computers (including 386, 486 and
Pentium PCs) had a word size of 32 bits. Newer processors such
as the Itanium series have a 64-bit (or 8-byte) word size.
Locations in main memory are sequentially numbered, so that
each one has a unique ‘address’ by which it can be directly
accessed. This is why this type of memory is sometimes referred
to as random-access memory (RAM).
The addressable nature of main memory makes the retrieval of
data much faster than if there was a need to search sequentially
through each ‘pigeonhole’ in turn until the right one was found.
Furthermore, random access means that each memory location
takes the same amount of time to access, regardless of its address.
38
UNIT 6: MEMORY
(also called primary storage, internal storage, or main memory).

Memory is the part of the computer that holds data for processing, programs, and
information waiting to be output to secondary storage.

There are three main characteristics of memories:

The capacity of the memory varies in different computers and is measured in bytes.
A byte consists of 8 binary digits called bits.
Each bit can represent binary 0 or binary 1. Each byte represents one character in
memory.
There are four commonly used units of memory capacity:



39

AO
U
Leb.
F08
M15
0Unit
QUESTIONS :
List two characteristics of main memory.


It is randomly accessible (or addressable).
It is volatile.
Suppose a computer is described as having 128KB
(i.e. 128 kilobytes) of RAM.

(a) How many bytes of memory does it have?


(b) If the word size of the processor is 64 bits, how many words can the
memory store?
You learned about bits, bytes and words in Section 3 of Unit 3. In
particular you should recall that a byte contains 8 bits, and a kilobyte
contains 1,024 bytes.
Haifaa Elayyan

Discussion

(a) There are 131,072 bytes of memory.

As a single kilobyte is 1,024 bytes, 128 kilobytes is 128 6 1024 bytes,

i.e. 131,072 bytes.

(b)
The memory can hold 16,384 words. As each byte contains 8 bits,
a 64-bit word is equivalent to an 8-byte word.
40

There are 131,072 bytes in all, so the number of words is 131,072/8,

i.e. 16,384.
UNIT 6: MEMORY
There are two types of memory chips:

Random access memory (RAM): Data and programs must be loaded from
external storage (such as disk) into RAM before it can be used by the
processor. RAM is volatile (temporary).

Read only memory (ROM): chips have programs built into them at the
factory and cannot be changed by the user, thus they are not volatile.
 programmable ROMs (PROM) that can be programmed by the user
using special devices to save his own information.
 ROM typically contains special instructions to start up the computer,
AO
U
give keyboard keys their special control capabilities and put characters
Leb.
on the screen.
-
41

F08
M15
0Unit
UNIT 6: MEMORY HIERARCHY
Memory hierarchy: there is a memory hierarchy consisting of
primary memory (CPU internal registers, cache memory,
main memory) and secondary memory (external devices
such as disks)
 Cache memory: is a high-speed expensive RAM memory
used to store copies of the most frequently accessed
information in main memory.
 Virtual memory: Virtual memory is a memory system used to
increase the effective size of the computers physical mainAO
U
memory.

42
Leb.
F08
M15
0Unit
UNIT 6: SECONDARY (EXTERNAL) STORAGE






43

We mentioned before that the main memory is volatile (temporary).
If the power is turned off program and data disappear.
External storage is nonvolatile (permanent).
External storage also has much more capacity than the primary memory.
There are two approaches to external storage:
sequential access and
direct access.
The most widely used external storage media are
-floppy disks,
-hard disks,
-optical disks and
AO
-magnetic tapes.
Disks are direct access storage media, while tapes are sequential
storage media.
U
Leb.
access
F08
M15
0Unit
THE OPERATING SYSTEM

Haifaa Elayyan

We have briefly examined the important hardware
components of a computer: the processor, memory and
peripheral devices. Managing these resources to effectively
coordinate and carry out all the computer’s tasks is the job
of the operating system. Common operating systems for
personal computers include Linux, Mac OS (for the Apple
Macintosh) and the various versions of Windows, e.g.
Windows 2000 and Windows XP.
An operating system is a complex piece of software that
acts as an interface between the user (or an application
program) and the computer hardware. It essentially
enables the user to carry out a variety of complex tasks on
the computer, without the need to know anything about
what goes on ‘inside the box’. The functions of the operating
system include the following.
44
CONTINUE


The user interface is the software that enables us to communicate with
our computers. It provides us with a means of inputting data and
instructions, and presents output in a way that we can understand.
The user interfaces of early operating systems such as CP/M and DOS
were text based, requiring the user to learn a set of commands which
needed to be typed in following precise rules. Output to the screen also
consisted entirely of characters. Today most PC operating systems provide
graphical user interfaces (GUIs), the most common example of which is
Microsoft Windows. GUI-based operating systems make use of icons,
menus and other graphical widgets, with which the user interacts via a
pointing device, usually a mouse. Most people find graphical interfaces
more intuitive, quicker to learn, and easier to use than sequences of
commands. A further advantage of GUIs is their availability for use by
programs other than the core software provided by the operating system.
For example, application programs (e.g. word processors, spreadsheet
packages), even those produced by companies other than Microsoft, can
‘hook in’ to the Windows user interface to provide a consistent look and
feel. This makes it much easier for users to learn how to use new
applications.
Haifaa Elayyan

Provision of a user interface
45
QUESTION :
Name four functions of an operating system?
 You could have given any four of the following:
 providing a user interface;
 managing the allocation of memory;
 controlling peripheral devices;
 scheduling access to the processor;
 providing an interface between a computer and
an application;
 providing basic utilities.

Haifaa Elayyan
46
UNIT 6: OPERATING SYSTEM


Is the most important system software component.
It interacts between the application software and the computer and
manages the computer’s internal resources.
47

Within the OS, besides the kernel, there is a group of other programs
called utility programs, that perform common tasks, such as formatting
disks, copy files from other disks, backup disks, remove and rename files,
and others.

Mainframes and minicomputers have powerful OS, including virtual
memory, multiprogramming and multiprocessing, where many users can
run different programs at the same time. Microcomputer OS focus on AO
a
U
single user.
Leb.
The most important operating systems are: DOS, Microsoft Windows,F08
Unix, Linux and MAC.
-

M15
0Unit
UNIT 6: OPERATING SYSTEM
48
The Operating system has the following functions;
 Provision of user interface
 Management of the memory
 Coordination and control of peripheral devices.
 Scheduling access for the processor
 Interface between Hardware and computer applications.
 Provide basic utilities (disk formatting, file management,
etc….).
AO
U
Leb.
F08
M15
0Unit
The bootstrap loader: is a program that is stored permanently in
the computer’s electronic circuitry in ROM. This process is
called booting.

UHardware,
NIT 6: ASoftware
GENDA and Computer system
The resources of a computer , and how they are managed.

Running a program.

Types of programming languages.

The structure of computer programs.
49

AO
U
Leb.
F08
M15
0Unit
UNITthe6:program
THE Fexecution
ETCH/EXECUTE
CYCLE
During
the CPU do
the following steps:
Get an instruction from the program.

Find and transfer any data necessary to perform instruction.

Carry out the instruction.
50

The process of locating, transferring and carrying out a single
AO
instruction during execution is called fetch/execute cycle.U
Leb.
F08
M15
0Unit
UNIT
CONTINUE
During
each6:
cycle
the CPU must:

51
Locate the next instruction in the program which is stored in the main
memory (first one is used if the execution has just started).
Transfer the instruction in to the processor by putting it in a register.
Decode the instruction.
Locate any data located in the main memory which refers to the
instruction.
Do the processing.
Place the result in an appropriate register.
If needed move result back to the main memory to be used later.
AO
U
Increment the program counter by 1.







Leb.
F08
M15
0Unit

UNIT 6:Program
EXAMPLE EXECUTING
Executing
PROGRAM
LDA
501
ADD 502
STO 503
HLT 000
Memory
location of
instructions
701
702
703
704
Data
Memory
location of data
52
Instruction
2
3
?
501
502
503
AO
U
Leb.
F08
M15
0Unit
UNIT 6:CONTINUE
operator
operand
LDA 501
53
address of a
memory
location
LoaD Accumulator
part of the computer's
memory
The Accumulator
Before LDA
executes
after LDA
executes
???
2
?
2
3
?
500
501
502
503
AO
U
Leb.
F08
M15
0Unit
UNIT 6:CONTINUE
operator
operand
ADD 502
54
address of a
memory
location
ADD to Accumulator
The Accumulator
before ADD
executes
after ADD
executes
2
5
part of the computer's
memory
?
2
3
?
500
501
502
503
AO
U
Leb.
F08
M15
0Unit
operator
UNIT
6:CONTINUE operand
STO 503
The Accumulator
before STO
executes
after STO
executes
55
STOre Accumulator in
memory
address of a
memory
location
computer's memory
before STO
?
2
3
?
500
501
502
503
AO
computer's memoryU after
STO Leb.
5
5
?
2
3
5
500
501
502
503
F08
M15
0Unit
UNIT 6:CONTINUE
operator
operand
56
HLT 000
HaLT
No effect on accumulator or memory
dummy value not used
AO
U
Leb.
F08
M15
0Unit

UHardware,
NIT 6: ASoftware
GENDA and Computer system
The resources of a computer , and how they are managed.

Running a program.

Types of programming languages.

The structure of computer programs.
57

AO
U
Leb.
F08
M15
0Unit
UNIT 6: TYPES OF PROGRAMMING
 Five
Generations of
LANGUAGES
. Programming Languages


SAMPLE STATEMENT
10010001
ADD A, B JMP L
Overtime:= 5 0;
FIND NAME "JONES“
IF patient is dizzy, THEN check
temperature and blood pressure
58
GENERATION
NAME
 First
Machine
 Second
Assembly
 Third
Procedural and structural
 Fourth
Object oriented
 Fifth
Natural
Computer professionals talk about levels or generations of programming
languages, ranging from ‘low’ to ‘high.’ Programming languages are called lower
level when they are closer to the language the computer itself uses.
The computer understands the 0s and 1s that make up bits and bytes.
Programming languages are called higher level when they are closer to the
language humans use that is, for English speakers, more like English.
AO
U
Leb.
F08
M15
0Unit
UNIT 6: MACHINE LANGUAGES: THE FIRST
GENERATION
We
mentioned earlier that a byte is made up of bits,
consisting of 1s and 0s.
 These 1s and 0s may correspond to electricity’s being on or
off in the computer.
 They may also correspond to a magnetic charge’s being
present or absent on storage media such as disk or tape.
 Data represented in 1s and 0s is said to be written in
machine language.
 To see how hard this is to understand, imagine if you had to
code this :
AO
U
 111100100111001111010010000100000111000000101011
Leb.
 Machine languages also vary according to computer design
F08 another characteristic that makes them hard to work with M15

59
0Unit
UNIT 6: ASSEMBLY LANGUAGES: THE SECOND
60
Assembly
languages have a clear advantage over the 1s and 0s of machine
GENERATION
language because they use abbreviations or mnemonics.
 These are easier for human beings to remember.
 The machine language code we gave earlier could be expressed in assembly
language as:
ADD A, B
JMP L
 Assembly language is also considered low-level.

Assembly languages also vary from computer to computer.
AO
 With the third generation, we advance to high-level languages, many ofU
Leb.
which are considered portable languages.
F08
 That is, they can be run on more than one kind of computer—they are M15
0“portable” from one machine to another.
Unit
UNIT 6: HIGH-LEVEL PROCEDURAL LANGUAGES: THE THIRD
GENERATION


People are able to understand languages that are more
like their own (e.g., English) than machine languages or assembly
languages. These more English-like programming languages are called
“high-level” languages.
61




However, most people still require some training in order to use
higher-level languages. This is particularly true of procedural
languages.
Procedural languages are programming languages with names like
BASIC, Pascal, C, COBOL, and FORTRAN.
They are called “procedural” because they are designed to expressAO
the
U
logic—the procedures—that can solve general problems.
Leb.
For a procedural language to work on a computer, it must be
F08
translated into machine language Depending on the language, thistranslation is performed by either a compiler or an interpreter. M15
0Unit
UNIT 6: HIGH-LEVEL PROCEDURAL LANGUAGES: THE THIRD
GENERATION

A compiler converts the programmer’s procedural language program,
called the source code; into a machine language code, called the object
code.
62
An interpreter converts the procedural language one statement at a time
into machine code just before it is to be executed. No object code is
saved.
What is the difference between using a compiler and using an interpreter?
 When a program is run, the compiler requires two steps. The first step is
to convert the entire program’s source code to object code.
 The second step is to run the object code. The interpreter, in contrast,
converts and runs the program one line at a time.
 The advantage of a compiler language is that once the object code has
AO
U
been obtained, the program executes faster.
Leb.
 The advantage of an interpreter language is that programs are easier to
F08
develop.

M15
0Unit
UNIT 5: PROBLEM-ORIENTED LANGUAGES: THE FOURTH
GENERATION
Third-generation languages are valuable, but they require
training in programming.
 Object-oriented languages, also known as very high-level
languages, require little special training on the part of the
user.
 Unlike general-purpose languages, object-oriented
languages are designed to solve specific problems. Some of
these fourth-generation languages are used for very specific
applications. Many consider Lotus 1-2-3 and dBASE to be
flexible fourth-generation languages.
AO
 Query languages: Query languages enable nonprogrammers
U
to use certain easily understood commands to search andLeb.
F08
generate reports from a database. An example is the
commands used on an airline reservations system
M15

63
0Unit
UNIT 6: NATURAL LANGUAGES: THE FIFTH
GENERATION
Natural languages are still being developed.

They are designed to give people a more human (“natural”)
connection with computers.

The languages are human languages: English, French,
Japanese, or whatever.

Researchers also hope that natural languages will enable a
AO
computer to learn — to “remember” information, as people
U
do, and to improve upon it.
Leb.

64

Clearly this area is extremely challenging.
F08
M15
0Unit

UHardware,
NIT 6: ASoftware
GENDA and Computer system
The resources of a computer , and how they are managed.

Running a program.

Types of programming languages.

The structure of computer programs.
65

AO
U
Leb.
F08
M15
0Unit
UNIT 6: THE BASIC BUILDING BLOCKS OF

All
programs canPROGRAMS
be built from three logical building blocks
COMPUTER
• Selection/ifs
66
• If the traffic in the high
street is heavy
• take the first left
• take the first right
Sequence
• Take the first left
• Take the second right
• Take the third exit at
the roundabout
• take the first left
• else
• follow the high
street to the end
Repetition/loops
• while you have not yet
reached the turnoff for
Little Whamping
• go straight aheadAO
at
each roundabout U
Leb.
F08
M15
0Unit

UNITnot
6:C
ONTINUE
Let's
worry
about the programming language for a
while
67
The syntax for how you do sequence, selection and
repetition varies from programming language to
programming language but the basic structures stay the
same.
 Once you have the concepts clear you can apply them to
any language (JavaScript, Java, Visual Basic, C#, C++,AO
U
Perl etc etc)

Leb.
F08
M15
0Unit

UNIT
6:thing
SEQUENCE
The
only
to worry about is getting the instructions in the
correct order
buy a stamp
68
post the
envelope
put the card in the
envelope
write in the
birthday card
buy a birthday card
address the
envelope

Put these instructions into a logical sequence for
Robbie the willing but slightly dim robot!
AO
U
Leb.
F08
M15
0Unit
UNIT
6: Sinstruction
ELECTION
A selection
allows you to write programs (and remember

programs are basically just plans) that will operate in different ways
depending on circumstances
69
If I win the lottery this Saturday I'll
tell my boss what I think of her on
Monday otherwise I'll start an OU
degree and get a better job in a
couple of years
AO
U
Leb.
F08
M15
0Unit
UNIT
6: always
TRUE
OR aFALSE
Selection
includes
condition that can be evaluated when the


program runs (i.e. the plan is executed) to be true or false (this is called a
Boolean expression).
The truth or falsity of the condition determines which path is taken.
70
a "flow chart"
The condition is
like a fork in the
road determining
which path you
take
True
tell my boss what I
think of her on
Monday
I win the
lottery this
Saturday
False
start an OU
AO
U
Leb.
degree
F08
M15
0Unit

UIfNIT
6: SELECTION
EXERCISES
Charlton
Athletic stay
in the premiership next season
I'll renew my season ticket. Otherwise I'll spend my
money on getting Sky instead.
71

Identify the condition and draw a flow chart diagram
AO
U
Leb.
F08
M15
0Unit

AU
repetition
allows one or more instructions to be
NIT 6:instruction
REPETITION
repeated a number of times.
I've got a
chance of
winning
False
True
Sorry Paula!
72
While I've got a chance of
winning I'll keep putting one
foot in front of the other
put one foot in front
of the other
AO
U
Leb.
F08
M15
0Unit



put milk in cup
put teabag in cup
pour in boiling water
73
Ugetting
NIT 6: R
EPETITION
EXERCISE
I'm
Robbie
to plant
tulip bulbs in the garden.
I've given him a bag of bulbs and told him that
while there are still any left in the bag he should
take one out, dig a hole for it and put it in.
 Draw a flow chart representing my instructions to
Robbie.
What's wrong with these instructions for Robbie
 To make cups of tea for the family repeat the
following actions:
AO
U
Leb.
F08
M15
0Unit
UNIT 6: Cobservation:
ONDITIONS AGAIN
both selection and repetition
 Important
are controlled by conditions that can be evaluated
to true or false (i.e. Boolean expressions).
74
Selection - which path should I follow?
 Repetition - how often should I go round the loop?

 Because
Boolean expressions are of crucial
importance a considerable chunk of Unit 6 section 6
is devoted to them.
AO
U
Leb.
F08
M15
0Unit

UNITwe
6:want
COMPOUND
Often
to combineCONDITIONS
separate conditions when using
them to control a selection or a repetition e.g.
75
if (the customer is over 64
or the customer is under 18)
charge them reduced rate
else
charge them full rate
AO
U
Leb.
F08
M15
0Unit
UNIT 6: EVALUATING COMPOUND
CONDITIONS

You have to evaluate the separate parts and combine them
according to rules in order to evaluate the truth or falsity of the
overall expression
76
true/false
true/false
true/false
(the customer is over 64 or the customer is under 18)

The rules used to combine the separate parts depend on the
operator used. In this case the operator is or.
AO
U
Leb.
F08
M15
0Unit
Ueither
NIT 6: EVALUATING OR EXPRESSIONS
or both of the sub-expressions are true then
 If
77
the whole expression evaluates as true. Only if both
the sub-expressions are false does the whole
expression evaluate to false.
 Evaluate
(the customer is over 64 or the customer is under 18)
 When
the customer is 17
b) the customer is 65
c) the customer is 63
a)
AO
U
Leb.
F08
M15
0Unit
UNIT 6: ANOTHER OR EXERCISE
What will happen when the patient is:
a) 16
b) 11
c) 70
Is there a problem here?
78
if (the patient is over 12 or the patient is under 60)
prescribe the adult dosage
else
prescribe reduced dosage
AO
U
Leb.
F08
M15
0Unit
NIT 6: EVALUATING AND EXPRESSIONS
If U
(the
sky is purple and there is a shower of dead
frogs)
stay under the duvet
79
else
get up and go to work
 If
either or both of the sub-expressions are false
then the whole expression evaluates as false. Only
if both the sub-expressions are true does the whole
AO
U
expression evaluate to true.
Leb.
F08
M15
0Unit
80
NITdate
6: AisNan
AND
If U
(the
oddEXERCISE
number and there's an "r" in the
month)
drink Coffee
else
drink Tea
What's to be drunk on:
a)
b)
c)
May 11th
March 21st
September 22nd
AO
U
Leb.
F08
M15
0Unit
81
NIT 6: M=IXING
EXERCISE
If U((gender
"male"ITand
age > 64)
or
(gender = "female" and age > 59))
charge reduced rate
else
charge full rate
What will happen for:
a)
b)
c)
a male of 63
a female of 60
a male of 25
AO
U
Leb.
F08
M15
0Unit
NIT 6: M
IXING>IT2000
EXERCISE
if U
(monthly
income
2
or (monthly income > 1000 and
monthly outgoings < 500))
82
grant credit
else
refuse credit
What will happen for:
a)
b)
c)
someone with monthly outgoings of 1800 and a monthly
AO
income of 2100
U
Leb.
someone with a monthly income of 900 and monthly F08
outgoings of 200
someone with a monthly income of 1200 and monthlyM15
0outgoings of 600
Unit
WHAT’S NEXT
Unit 7: An introduction to programming using JavaScript
Introduction

Getting started

Programming for selection: the if statement

Programming for repetition: the while statement

Programming for repetition: the for statement
83

AO
U
Leb.
F08
M15
0Unit
SOME REVIEW QUESTIONS
What is assembly language?
 Write using assembly language a program that adds 2
numbers. Using your program describe what is meant by
operator and operand .Also describe what happens to
in the computer hardware as the program is executed?
In this case you can assume that the first number is
stored at memory location 400 is 3 and the second
number is stored at 401 is 4. Also assume that the
starting memory location is 700.
 Define virtual and cache memory?
AO
 Describe using an example the meaning of low and high
U
level language?
Leb.
F08
 What is meant by compiler and interpreter?

84
M15
0Unit
Download