100% found this document useful (2 votes)
3K views57 pages

A2 Computer Science 9618 Paper 3 Notes

The document discusses different types of file organization methods including serial, sequential, and random. Serial file organization stores records one after another in the order they were added. Sequential file organization stores records in a given order, usually based on a key field. Random file organization stores records in any available position, with the location found using a hashing algorithm on the key field.

Uploaded by

Manav Maistry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
3K views57 pages

A2 Computer Science 9618 Paper 3 Notes

The document discusses different types of file organization methods including serial, sequential, and random. Serial file organization stores records one after another in the order they were added. Sequential file organization stores records in a given order, usually based on a key field. Random file organization stores records in any available position, with the location found using a hashing algorithm on the key field.

Uploaded by

Manav Maistry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

A2 Computer Science 9618

Paper 3 Notes
Produced by: Baraa Khaled
INDEX & CONTENTS

Table of Contents
INDEX & CONTENTS 2
CHAPTER 13 3
END OF CHAPTER 13 QUESTIONS 13
CHAPTER 14 21
END OF CHPATER 14 QUESTIONS 30
CHAPTER 15 38
END OF CHPATER 15 QUESTIONS 47

2|Page
CHAPTER 13
o User-defined data types are based on an existing data type or other data
types that have been previously defined by a programmer.
o Such data types can be divided into two categories:
Composite data
Records Sets Classes
types
User-defined
Non-Composite
Data Types Enumerated Pointer Primitive
data types

o The use of user-defined data types: In some cases, primitive data types
(integers, strings, etc) may be found insufficient or even inefficient in some
programs, hence, the need for constructing user-defined data types is vital
for such occurrences.

o As an enumerated data type is non-composite, it does not reference any


other data types when it is defined.
o One main feature of this type of data is that it is ordinal, meaning the position
of the values in the list is important.
o It is crucial to know that the values in the enumerated data types are not
strings, and so must NOT be enclosed by quotation marks.
o Structure:
Enumerated
→ Defining enumerated data type in pseudocode:
Data Type TYPE <identifier> = (value1, value2, value3, ...)
→ Declaring a variable as an enumerated data type in pseudocode:
DECLARE <variable> : <identifier>
→ Example in pseudocode:
TYPE Days = (Sun, Mon, Tue, Wed, Thu, Fri, Sat)

o Pointer data types are a non-composite data type that uses the memory
address of where the data is stored.
o A pointer is a variable which stores the address of a variable. Instead of the
data, the pointer contains the address of the data.
o However, dereferencing is a special use of a
pointer where it is used access the value
Pointer Data
stored at the address pointed to.
Type o Pointers require information about the type
of data that will be stored in this memory
location.
o They
o are mainly designed to overcome the need
of reserving memory in advance (as in arrays).

3|Page
o Structure:
→ Defining pointers in pseudocode:
TYPE <pointer> = ^<TypeName>
→ Declaring a variable as a pointer data type in pseudocode:
DECLARE <variable> : <pointer>
→ Example of dereferencing a pointer in pseudocode:
ValuePointedTo <--- MyPointer^
→ Example in pseudocode:
TYPE ATMTransaction = ^Integer
DECLARE TransactionPointer : ATMTransaction

o Record is a composite data type that refers to other data types in its
definition. It is a data type that contains a fixed number of components,
which can be of different types.
o It allows the programmer to collect values together with different data types
in one variable, where each element is considered a field.
o Structure:
→ Defining records in pseudocode:
TYPE
<identifier>
DECLARE <variable1> : <TypeName>
DECLARE <variable2> : <TypeName>
DECLARE <variable3> : <TypeName>
Record Data ENDTYPE
Type → Example in pseudocode:
TYPE
TbookRecord
DECLARE title : STRING
DECLARE author : STRING
DECLARE publisher : STRING
DECLARE noPages : INTEGER
DECLARE fiction : BOOLEAN
ENDTYPE
→ Accessing an individual item from a record:
TbookRecord.noPages <-- 243

Continuation Next Page

4|Page
o A set is a collection of items where every element is unique, and no
duplication is present. This data type allows for mathematical operations
defined in set such as:
→ Union
→ Difference
→ Intersection
o Unlike enumerated data type, sets are composite and do not follow any order
in the list.
o Structure:
Set Data Type
→ Defining sets in pseudocode:
TYPE <set-identifier> = SET OF <Basetype>
→ Declaring a variable as a set data type in pseudocode:
DEFINE <identifier> (value1, value2, value3, ...) : <set-
identifier>
→ Example in pseudocode:
TYPE letters = SET OF CHAR
DEFINE vowel ('a', 'e', 'i', 'o', 'u') : letters

o This composite data type will be covered thoroughly later in paper 4. Here is
an introduction:
o A class is a data type that includes variables of a given data types and
Classes methods.
o An object is defined from a given class; several objects can be defined from
the same class.

o The following is a summary of all the four user-defined data types:

ENUMERATED POINTER RECORD SET

TYPE Non-composite Non-composite Composite Composite

List is ordinal Uses memory Can access Mathematical


Summary KEY FEATURES address individual items operations
TYPE TYPE <pointer> TYPE<pointer> TYPE <set-
<identifier> = = DECLARE identifier> =
DEFINITION (value1, value2, ^<TypeName> <variable1> : SET OF
...) <TypeName> <Basetype>
ENDTYPE

o File organization refers to the way data is stored in a file; how new data is
added and their position.
File o There are 3 methods of file organization:
Organization → Serial file organization
→ Sequential file organization
→ Random file organization

5|Page
o It is the method in which records of data are physically stored in a file, one
after another in the order they were added to the file.
o In other words, new records are appended to the end of the file, hence
making them in a chronological order.
o Diagram:

Serial File
Organization

o Use:
→ Often used for temporary files storing transactions to be made to more
permanent files.
→ For example, a bank recording transactions involving customer accounts.
A program would be running where each time there was a withdrawal or a
deposit the program would receive the details as data input and record
them in a file.
→ Text files
o This method physically stores records of data in a file, one after another, in a
given order.
o The order is usually based on the key field of the records as they are unique
and sequential but not necessarily consecutive.
o Diagram:

Sequential
File
Organization

o Use:
→ For example, a file could be used by a supplier to store customer records
for gas or electricity to send regular bills to each customer. Records are
stored in ascending order using the customer number.

6|Page
o The random file organization method physically stores records of data in a
file in any available position.
o The location of any record in the file is found by using a hashing algorithm on
the key field of a record.
o Diagram:

Random File
Organization

o Use:
→ Random (direct) file organization allows data to be retrieved quickly in a
random manner, regardless of the way in which the data was originally
stored.
o A hashing algorithm, in the case of storing and accessing data, is a
mathematical formula used to perform calculation on the key field of a
record.
o The output of this algorithm will indicate the address where the key field
should be found.
o Example: If a file has space for 2000 records and the key field can take any
values between 1 - 9999, then the hashing algorithm could use the remainder
when the value of key field is ÷ 2000, together with the start address of the
file and the size of the space allocated to each record.

Hashing
Algorithm o Problem arises when the key field is 5024, 7024, etc since we will have the
same remainder and hence, same address.

o This is tackled in two ways:


→ Open hash: the record is stored in the next free space
→ Closed hash: overflow area is set up and the record is stored in the next
free space in that overflow.

7|Page
o File access is the method used to physically find a record in the file.
o The two types considered here are:
File Access → Direct (random) access
→ Sequential access
o Direct access is the method of file access in which a record can be physically
found in the file without physically reading
other records.
o In other words, we can access an
individual record in a file immediately,
Direct making retrieval time of a record
(random) significantly quicker than sequential
Access access.
o In a sequential file, an index of the key fields in the file is stored and used to
search the address of the file where that certain record is found.
o For a random file, a hashing algorithm is used on the key field to search the
address of the file where that certain record is found.
o The sequential access method searches for records one after another from
the physical start of the file until the required record is found.
o This method can be used on serial and sequential files.
o For a serial file, every record needs to be
checked until the required record is found
Sequential or the whole file has been checked with no
Access sign of that record.
o In a sequential file, every record needs to be
checked until the record is found, or the key
field of the current record being checked is
greater than the key field of the record being
searched for.
o The following is a summary of the types of file access:

DIRECT (RANDOM) SEQUENTIAL FILE


ACCESS ACCESS

SERIAL FILE  ✓
Summary SEQUENTIAL FILE  ✓
SEQUENTIAL FILE
WITH INDEX ✓ ✓
RANDOM FILE ✓ ✓

8|Page
o General representation of a floating-point number with 8 bits for both the
mantissa and exponent:
Mantissa Exponent
01010001 x 23
01010001 x 00000011
01010001 00000011
o The mantissa itself has a whole number part and a fractional part separated
by a binary point (assumed to exist after the Most Significant Bit, MSB).
o Reminder on how to convert into two’s complement:
→ Copy bits from right to left, up to and including the first “1”
Floating Point → Flip the remaining bits to the left
Numbers

o Weightings of mantissa and exponent when they’re both in 2’s complement:

o To convert, there are two methods. However, always check...


→ ...whether the mantissa and/or the exponent is in two’s complement
→ ...the number of bits given for the mantissa and the number for exponent
o Although there are 2 methods to convert from binary floating-point numbers
to denary, only the common faster way is shown here.
o Convert 01011010 00000100 to denary:
Step 1 Write the mantissa in the following form

• 0.1011010
Binary
Floating Point Step 2 Exponent = 4, so shift the binary point 4 places right
Numbers to
• 0.1011010
Denary
• 01011.010
Step 3 Convert by ADDING the value before and after the binary point
• 01011 = 11
• . 010 = 0.25
• 11 + 0.25 = 11.25
o REMEMBER: you must always show working out when asked for any
conversion, and that includes showing how you shifted the binary point using
the half-circle arrows.

9|Page
o For negative binary floating-point numbers, same steps are applied.
o However, remember that the left most ‘1’ bit will always be negative for
negative binary floating point numbers.

o Convert 11001100 11111100 to denary:


Negative Step 1 Write the mantissa in the following form
Binary
• 1.1001100
Floating Point
Numbers to
Step 2 Exponent = -4, so shift the binary point 4 places LEFT
Denary
• 1.1001100
• 0.00011001100
Step 3 Convert by adding the value before and after the binary point
•0=0
1 1 1 1 13
• . 00011001100 = − 16 + 32 + 256 + 512 = − 512
13
• 0+ − = −0.025390625
512

o Again, converting from denary to binary floating-point numbers, there are


also two possible methods, however only the common one is shown:
o Convert 4.5 to binary floating point number:
Step 1 Convert the integral and fractional parts to denary
• 4 = 0100(don't forget the sign bit)
• .5 = .1000 (sometimes it's not easy to convert the fractional part due to its length, check below)
• 4.5 = 0100.1000
Step 2 Move the binary point to sit just after the MSB
• 0100.1
Denary to • 0.1001
Binary Step 3 Count the number of times the binary point was shifted
Floating Point
• Number of times: 3
Numbers
• Direction: left
• Hence, exponent in binary: 0011

o Sometimes it is not easy to convert the


fractional part due to its length (example:
8.40625). Here is how it is done:
→ Successive multiplication by 2 to the
FRACTIONAL PART ONLY (0.40625)
→ From the product, take the integral part
and carry the fractional part to be multiplied by 2 again.

10 | P a g e
o Two methods are available to convert the negative denary value into a binary
floating point number.
o Since both ways are useful in different scenarios, they are both shown here:
o Convert -7.75 to binary floating-point using METHOD 1:
Step 1 Convert +7.75 to binary
• 7 = 0111 (don't forget the sign bit)
• .75 = .11
• 7.75 = 0111.11
Step 2 Convert to two's complement

Negative • 0111.11 = 1000.01


Denary to Step 3 Make the binary point right after the MSB
Binary
Floating Point • 1000.01 = 1.00001 x 23
Numbers • 1.00001 x 23 = 10000100 0011

o Alternative shortcut method (usually for small numbers):


Step 1 Find two numbers which add up to give -7.75
• −7.75 = −8 + .25
• −8 + .25 = 1000 + .01
Step 2 Make the binary point right after the MSB
• 1000.01 = 1.00001 x 23
• 1.00001 x 23 = 10000100 0011
o Normalisation is the process of moving the binary point so that the first digit
after the point is a significant digit. This improves the precision of binary
floating-point numbers.
o With this method, for a positive number, the mantissa must start with 0.1
o For a negative number, the mantissa must start with 1.0
o Three simple steps to achieve the normalised form:
Shift the bits until the Check if both the
number starts with 0.1 Calculate the new denary values before
(positive) or 1.0 exponent and after normalisation
Normalisation (negative) are equal

o Normalise 0000000110 000111: Normalise 1111110111 000000

11 | P a g e
o The accuracy/precision of a number can be increased by increasing the
number of bits used in the mantissa.
o The range of numbers can be increased by increasing the number of bits used
in the exponent.
o Accuracy and range will always be a trade-off between mantissa and
exponent size.
o Increasing and decreasing the precision and range:

Precision and
Range

o If a calculation produces a number which exceeds the maximum possible


value that can be stored in the mantissa and exponent, an overflow error will
be produced. This could occur when trying to divide by a very small number
or even 0.
o When dividing by a very large number this can lead to a result which is less
than the smallest number that can be stored. This would lead to an underflow
error.
Floating Point o This problem can be minimized when using programming languages that
Problems allow for double precision and quadruple precision.
o One of the issues of using normalized binary floating-point numbers is the
inability to store the number zero. This is because the mantissa must be 0.1 or
1.0 which does not allow for a zero value.
o Some binary representations can lead to rounding errors because:
→ There is no exact binary conversion for some numbers
→ More bits are needed to store the number than are available

12 | P a g e
END OF CHAPTER 13 QUESTIONS
9608/33/MJ/20

13 | P a g e
9618/03/SP/21

14 | P a g e
9608/31/ON/18

15 | P a g e
9608/31/MJ/18

16 | P a g e
9608/32/MJ/17

17 | P a g e
18 | P a g e
9618/31/MJ/21

19 | P a g e
20 | P a g e
CHAPTER 14
o A protocol is defined as a set of rules governing the communication across a
network, where the rules are agreed upon by both the sender and receiver.
o Why protocols are essential:
Protocols → It also provides the formatting rules which specify how data is packaged
into messages sent and received
→ ∴ ensuring a successful transmission of data over a network.
o One of the dominant protocols is the TCP/IP protocol suite which is a
collection of related protocols involving the internet usage.
o The four-layer structure for TCP/IP protocols:

TCP/IP
Protocol
Suite

o You are required to know each layer’s purpose and its protocols’ functions:
o The use of layers breaks the process down into manageable self-contained
modules, making it easier to develop and make software & hardware
compatible.
o Note: Each layer is implemented using software.
o Application is the top layer in the TCP/IP protocol suite.
o It contains all the programs that exchange data, such as web browsers or
server software.
o Made up of applications (ex. web browsers) that use transport layer for data
Application transmission.
Layer o Protocols associated with the application layer:
→ HTTP, FTP
→ SMTP, MIME
→ POP3, IMAP
o HTTP (hypertext-transfer protocol) is an application-level protocol used on
the World Wide Web which defines the
format of the messages sent and received.
o It is used when, for example, fetching an
HTTP HTML document from a web server.
o This protocol is considered to be a
client/server since request messages are
sent out to the web servers which then respond (eg. “Error 404”).
21 | P a g e
o Steps when a user requests a web page from a website:
→ The user keys the URL into their browser.
→ HTTP transmits the request from the application layer to the transport
layer (TCP).
→ The TCP creates data packets and sends them (via port 80) to the
destination port(s).
→ The DNS server stores a database of URLs and matching IP addresses.
→ The DNS server uses the domain name typed into the browser to look up
the IP address of the appropriate website.
→ The server TCP sends back an acknowledgement
→ Once communication has been established, the web server sends the web
page back in HTML format to the browser.
→ The browser interprets the page and displays it or sends the data in the
correct format to the media player.
o FTP (file transfer protocol) is used when transferring files from one client to
another via the internet or other networks.
o Web browsers can be used to connect to an FTP address in a way similar to
HTTP, for example: ftp://[email protected]/
FTP o Simple features of FTP:
→ Anonymous FTP: user accesses files without identification
→ FTP commands: delete, close, rename....
→ FTP server: the place where all files are stored
o Simple mail transfer protocol
(SMTP) is used when sending emails
involving text.
o It is sometimes called a “push
protocol” as the client opens the
connection to the server and keeps
the connection active all the time.
SMTP and o Since SMTP can only handle emails
MIME with ASCII characters, MIME can be
used as an extension to support
binary files (ie images, videos, audio,
etc) in emails.

o The post office protocol (POP3) and internet message access protocol
(IMAP) are both used in receiving emails from the server.
POP3/4 and o They are frequently called “pull protocols” where the client periodically
IMAP connects to a server, checks for and downloads new emails from the server –
the connection is then closed; this is repeated to ensure the client is updated.
o IMAP is a more recent protocol than POP3/4 (no. 3 & 4 indicate versions).

22 | P a g e
o In general, the application software will package up the “core data” which is
to be transmitted:
→ For an email client, it is the email text content
→ For a web browser, it is the text content, tags, and JavaScript code
→ For file-transfer client software, it is the downloaded file

o HTTP and FTP:

Summary of
Application
Layer
Protocols

o SMTP/MIME + POP3/IMAP:

23 | P a g e
o The transport layer regulates the network connections; this is where data is
broken up into packets, which are then sent to the internet/network layer.
o The main protocol we consider is the TCP (Transmission Control Protocol).
o This layer ensures packets arrive in sequence, without errors, by swapping
acknowledgements and retransmitting packets if they are lost or corrupted.
o Roles of the TCP:
→ When data is sent from client to server, the TCP re-organises the packets
into a format that the network layer is expecting.
→ When data is sent from server to client, the TCP re-organises the packets
into a format that the client application is expecting.
→ The TCP also sets an end-to-end connection between the two hosts using
Transport handshakes and maintains this connection.
Layer (TCP) → There will be a software process running on each host, which detects
errors in packets transmission and requests a re-transmission.
o Steps taken when two hosts wish to establish a connection:

o The main purpose of this layer is to identify the intended network and host
by using the common protocol IP (internet protocol). Recall IPv4 and IPv6...
o By identifying those IP addresses, the network layer would direct and
organize the movement of data on the network.
o Data packets coming from the above layer (transport layer) are addressed
with the source and destination IP addresses.
Internet or o When the data are coming from the layer below (link) the network layer
Network or removes the source and destination IP addresses.
o Functions of the IP:
IP Layer
→ Ensure correct routing of packets of data over the internet/network.
→ Encapsulates data into datagram.
→ Take a packet from the transport layer and add its own header which will
include the IP addresses of both sender and recipient.
→ The IP packet (datagram) is sent to the link layer where it is assembles
the datagrams into frames for transmission.
o The link layer involves the physical connection between nodes.
o It receives packets from the network layer and adds the hardware addresses
Link Layer “MAC” of the destination client.
o The final packaging of packets for sending across the cable is called Ethernet
frame.
24 | P a g e
o FUNCTIONS:

o SENDING:

Summary of
all TCP/IP
Protocol Suite
Layers

o RECEIVING:

25 | P a g e
o Wi-Fi OR IEEE 802.11x:
→ A type of wireless communication that allows the users to communicate
within a particular area/access internet.
→ They use a MAC protocol called carrier sense multiple access with
collision avoidance (CSMA/CA).
→ This protocol ensures a WIFI device can only transmit when there is a
free channel available.
→ If a device does not receive an acknowledgement a collision will be
assumed to have happened. After waiting for a random time interval, the
Other
data would be resent.
Protocols o Ethernet:
→ an array of networking technologies and systems used in local area
networks (LAN), where computers are connected within a primary
physical space.
o Bluetooth
→ Protocol used for short-distant data transmission.
o WiMax:
→ WiMax is short for Worldwide interoperability for Microwave Access.
→ It is connectivity originally designed for wireless MANs (WMAN).
o The BitTorrent is a protocol based on peer-to-peer (P2P) networking where
two or more PCs are connected and share resources without going through a
separate server computer.
o It allows for the fast sharing of files between peers
o Unlike, P2P networks which only work for small number of nodes, BitTorrent
can be used by thousands of users who connect over the internet.
o How BitTorrent works in general: | The concept of a leecher:

BitTorrent
Protocol

o Key Terms:
→ Torrent file: A file that contains details regarding the tracker
→ Tracker: A server that keeps track of the peers in the swarm.
→ Peers: A user who is at the time downloading the torrent file
→ Swarm: A network of peers that are sharing the torrent – simultaneously
downloading and uploading the file.
→ Seeding: The act of uploading a part (piece) of the file or the file itself as a
whole after/while downloading.
→ Leeching: The act of simply downloading a part of the file or the file itself
on a whole and not seeding it during or after the download.
26 | P a g e
o Circuit switching is a method of transmission in which a dedicated
circuit/channel lasts throughout the duration of the communication.
o Physical links are formed between nodes to establish a dedicated
communications channel.
o Steps that occur for data transmission:
→ Sender provides identity of intended receiver
→ System checks if receiver is ready to accept data
→ A circuit/channel between sender and receiver is established (shown in
orange on diagram)
→ Data transfer takes place
→ Connection is terminated (circuit breaks)

Circuit
Switching o Pros and Cons of Circuit Switching:
Pros Cons
the circuit used is dedicated to the it is not very flexible (for example, it
single transmission only will send empty frames and it must
use a single, dedicated line)
the whole of the bandwidth is nobody else can use the
available circuit/channel even when it is idle
the data transfer rate is faster than the circuit is always there whether it
with packet switching is used
the packets of data (frames) arrive at if there is a failure/fault on the
the destination in the same order as dedicated line, there is no alternative
they were sent routing available
a packet of data cannot get lost since dedicated channels require a greater
all packets follow on in sequence bandwidth
along the same single route

it works better than packet prior to actual transmission, the time


switching in real-time applications required to establish a link can be long

27 | P a g e
o Packet switching is a method of transmission where a message is broken into
packets which can be sent along paths independently from each other.
o Unlike circuit switching, the data sent (packets in this case) will need to be
reassembled into their correct order at the destination.
o Key points about packet switching:
→ Each packet follows its own path
→ The shortest path available is selected
→ The route taken by a packet depends on the number of packets waiting to
be processed at each node (router)
→ Packets can reach the destination in a different order to that in which
they are sent.

Packet o Pros and Cons of Circuit Switching:


Switching
Pros Cons
no need to tie up a communication the protocols for packet switching
line can be more complex than those for
circuit switching
it is possible to overcome failed or if a packet is lost, the sender must re-
faulty lines by simply re-routing send the packet (which wastes time)
packages
it is easy to expand the traffic usage does not work well with real-time
data streams
circuit switching charges the user on the circuit/channel has to share its
the distance and duration of a bandwidth with other packets
connection, but packet switching
charges users only for the duration of
the connectivity
high data transmission is possible there is a delay at the destination
with packet switching while packets are reassembled
packet switching always uses digital needs large amounts of RAM to
networks which means digital data is handle the large amounts of data
transmitted directly to the destination

28 | P a g e
o Many questions will ask you to identify which of circuit/packet switching is
more suitable in a scenario.

o Circuit switching VS Packet switching:


Circuit Packet
Feature
switching switching
actual route used needs to be set up before
Comparison transmission can begin ✓ 
a dedicated transmission path is required
✓ 
each packet uses the same route
✓ 
packets arrive at destination in the correct
order ✓ 
all the bandwidth of the channel is required
✓ 
is bandwidth wasted?
✓ 
o Sometimes packets are lost and keep ‘bouncing’ around from router to router
and never actually get to their destination.
o This clogs up the system over time.
o To overcome this, a hop number is added.
Hopping / o A hop number is a number in the packet header used to stop packets which
Hop Number never reach their destination from ‘clogging up’ routes by restricting the
number of times each packet is allowed to hop.
o Each time packet passes through a router, the hop number is decreased by 1.
o If the packet has not reached its destination and the hop number = 0, then it
will be deleted when it reaches the next router.
o Routing Table is a data table that contains the information necessary to
forward a package along the shortest or best route reach its destination.
o As soon as the packet reaches a router, the packet header is examined and
compared with the routing table.
o Routing table example:

Routing
Tables

29 | P a g e
END OF CHPATER 14 QUESTIONS
9618/03/SP/21

30 | P a g e
9618/31/MJ/21

31 | P a g e
9608/31/MJ/21

32 | P a g e
9608/31/ON/20

33 | P a g e
9608/32/ON/20

34 | P a g e
35 | P a g e
9608/31/MJ/19

9608/31/ON/18

36 | P a g e
37 | P a g e
CHAPTER 15
o The primary goal of CISC (Complex Instruction Set Computer) architecture is to
complete a task in as few lines of assembly as possible
o The philosophy behind it is that hardware is always faster than software,
therefore it needs a processor hardware that is capable of understanding and
executing a series of operations.
o This methodology is based on converting (by the
CISC processor) a complex instruction into a number of
Processor sub-instructions...
o For instance, when executing an instruction such as
“MULT”, the instruction loads the two values into
separate registers, multiplies the operands in the
execution unit, and then stores the product in the
appropriate register.
o Thus, the task of multiplying 2 numbers is completed with one instruction.
o RISC (Reduced Instruction Set Computer) processors only use simple, highly
optimised instructions that can be executed within one clock cycle.
o With fewer built-in instruction formats than CISC, this architecture leads to
higher processor performance.
RISC o Using the same example as above to carry out the multiplication of two
Processor numbers A and B:
LOAD X, A – this loads the value of A into a register X
LOAD Y, B – this loads the value of B into a register Y
MULT A, B – this takes the values for A & B from X & Y and multiplies them
STORE Z – the result of the addition is stored in register Z
o Features of RISC and CISC:
CISC Features RISC Features
Many instruction formats are possible Uses fewer instruction formats/sets
There are more addressing modes Uses fewer addressing modes
Makes use of multi-cycle instructions Makes use of single-cycle instructions
Instructions can be of a variable length Instructions are of a fixed length
Longer execution time for instructions Faster execution time for instructions
Decoding of instructions is more Makes use of general multi-purpose
complex registers
RISC vs CISC It is more difficult to make pipelining Easier to make pipelining function
work correctly
The design emphasis is on the hardware The design emphasis is on the software
Uses the memory unit to allow complex Processor chips require fewer
instructions to be carried out transistors

o Notice the difference between the


processors:
o In general, CISC is used in computers while
RISC, in small devices such as smart phones.

38 | P a g e
o Pipelining, one of the developments from RISC architecture, allows several
instructions to be processed simultaneously without having to wait for
previous instructions to finish.
o It allows for the improvement of computer performance in a less complex way.
o The execution of an instruction may be divided into 4 or 5 stages:
1. Fetch
2. Decode
3. (Operand Fetch)
4. Execution
5. Write-back
o How pipelining works:
→ Clock cycle 1: the first
stage of instruction 1.
→ Clock cycle 2: the second
stage of instruction 1 and
the first stage in
instruction 2.
→ Clock cycle 3: the third
Pipelining stage of instruction 1,
second stage of
instruction 2 and first
stage of instruction 3 are
implemented.
→ This continues until all
instruction are processed.
o Problems of pipelining:
→ A data dependency occurs when an instruction depends on the results of a
previous instruction.
→ Branch instructions are those that tell the processor to decide about what
the next instruction to be executed should be based on the results of
another instruction.
o You will be required to fill in diagrams and to calculate the number of clock
cycles saved by pipelining:
→ Clock cycles taken using pipelining: 8
→ Clock cycles it would require without pipelining: 4 x 4 = 16
→ Saved clock cycles: 16 – 8 = 8
o An interrupt is a signal sent to the processor from a hardware device/software,
indicating that the device/software requires attention.
o In CISC processor, interrupt handling is applicable in the traditional way.
o It would also be applicable to a RISC processor if there was no pipelining.
o In RISC processor, one option for handling the interrupt is to erase/flush the
Interrupts pipeline contents for the latest instructions that have entered. Then the normal
interrupt-handling routine can be applied to the remaining instruction.
o The other option is to construct the individual units in the processor with
individual program counter registers. This option allows current data to be
stored for all of the instructions in the pipeline while the interrupt is handled.
39 | P a g e
o Parallel processing is an operation which allows a process to be split up and for
each part to be executed by a different processor at the same time.
o It is divided into four categories: SISD, SIMD, MISD, MIMD.
→ SISD (Single Instruction Single Data)
SISD
Information The original Von Neumann Architecture that does not employ
any kind of parallelism. The sequential processor takes data
from a single address in memory and performs a single instruction
on the data. All single processor systems are SISD.
Common ▪ Older Computers
Usage ▪ Microcontrollers
Advantages ▪ Low power requirements as only a single core
▪ Simpler architecture than others therefore cheaper and easier
to manufacture
Disadvantages ▪ Speed of the system limited due to it being a single core

→ SIMD (Single Instruction Multiple Data)


SIMD
Information A single instruction is executed on multiple different data streams.
These instructions can be performed sequentially, taking advantage
of pipelining, or in parallel using multiple processors. Modern
GPUs, containing Vector processors and array processors, are
commonly SIMD systems.
Common ▪ Graphics Processing Units when performing vector and array
Parallel Usage operations.
Processing ▪ Scientific processing
Advantages ▪ Very efficient where you need to perform the same instruction
on large amounts of data.
→ MISD (Multiple Instruction Single Data)
MISD
Information In this architecture multiple instructions are performed on a single
data stream. An uncommon type commonly used for fault
tolerance. Different systems perform operations on the data and
all the results must agree. Used on flight control systems where
fault detection is critical.
Common ▪ Not used commercially.
Usage ▪ Some specific use systems (space flight control)
Advantages ▪ Excellent for situation where fault tolerance is critical

→ MIMD (Multiple Instruction Multiple Data)


MIMD
Information Multiple autonomous processors perform operations on
difference pieces of data, either independently or as part of shared
memory space.
Common ▪ Most modern desktop / laptop / mobile processors are MIMD
Usage processors.
Advantages ▪ Great for situations where you need to perform a variety of
processor and data intensive tasks (such as video editing, game
rendering)
40 | P a g e
o Visual Representation:

o Advantages of parallel processing over the Von Neumann architecture:


→ Faster when handling large amounts of data, with each data set requiring
the same processing.
→ Not limited by the bus transfer rate; can make maximum use of the CPU.
o Disadvantages of parallel processing over the Von Neumann architecture:
→ Only certain types of data and programming languages are suitable for
parallel processing. Data that relies on the result of a previous operation
cannot be made parallel. For parallel processing, each data set must be
independent of each other.
→ More costly in terms of hardware.
o As SIMD and MIMD are the most commonly used processors in parallel
processing, a cluster may be formed when a number of computers (using SIMD)
are networked together.
o A massively parallel computer is effectively one machine with several thousand
processors.
o In massively parallel computers, each processor will carry out part of the
Massively processing and communication between computers is achieved via
Parallel interconnected data pathways.
o Standard answer for characteristics/definition of massively parallel computers:
Computers
→ Large number of processors
→ ...working collaboratively on the same program
→ ...working together simultaneously on the same
program
→ ...communicating via a messaging interface

Continuation Next Page

41 | P a g e
o Simplifying boolean algebra can be done using a set of rules, which are:

o This table is crucial to know and memorize...


o Keep in mind that
→ =A
→ TRUE (1) is A
→ FALSE (0) is
o De Morgan’s Law can be thought of as:
→ If you have two inputs separated by a . or + with the same ‘NOT’ line over
them like this: (A.B) or (A+B)
→ ...then you can split that ‘NOT’ line by switching the sign like this:
The ‘NOT’ line splits The ‘NOT’ line splits
Boolean
Algebra (A.B) = (A+B) or (A+B) = (A.B)

Notice the switch of signs Notice the switch of signs


o Simplification examples:
No. QUESTION ANSWER

42 | P a g e
o K-map is one other method used to simplify logic statements and logic circuits
using Gray codes.
o Gray code rules:

o Karnaugh maps are similar to truth tables, in that they show all possible
combinations of input variables and output for a given function.
o However, in K-maps, the variable values form the coordinates of the map (row
and column headings) and the function output forms the squares in the map.
o An example for a specific three-variable expression:
o For the AB variables, note that
adjacent values (headings) are
arranged so that they only change by
one bit at a time.

Karnaugh
Maps o Possible loops (you will be asked to draw loops):

o Once the map is drawn:


→ List the combinations that you have just grouped in boolean notation on top
of each other as if you were to add them. Be sure to list each loop separately.
→ Cancel whatever is not common between each loop.
→ Add the results of the listings of the different groupings to each other.

43 | P a g e
o An 'adder' is any electronic circuit which performs the addition of bit patterns.
Adder circuits are a component of the ALU in the processor.
o The half adder circuit is the simplest circuit which carries binary addition on 2
bits generating two outputs: Sum (S) and Carry (C)
o Circuit:

Half Adder
o Truth Table:

o As the half adder is unable to deal with the addition of several binary bits, we
will make use of the full adder.
o The full adder has two half adders combined to allow the sum of several binary
bits.
o It has three inputs – A and B (as before) and a ‘previous carry’ (PC)
o Two outputs – Sum and Carry
o Circuit:

Full Adder

o Truth Table:

44 | P a g e
o All the regular circuits we are used to are called combinational circuits.
o Flip flops (or latches) are an example of sequential logic circuits where the
output depends on the input value produced from a previous output value
o In general, flip flops are electronic circuits with two stable conditions (1 or 0)
using sequential circuits therefore can be used to store data in memory;
contains a single bit.
Flip Flops o A sequential logic circuit will stay in its current state until the next clock cycle
signal changes one of the states.
o Uses of Flip Flops:
→ Memory // data storage
→ Stores a single bit
→ the basic building blocks for storage registers, shift registers and other
memory devices.
o The S-R (Set-Reset) flip flop is the most basic type. It can be constructed from
NOR gates or NAND gates.
o Two inputs – Set (S) and Reset (R)
o Two outputs – Q and Q where they should be opposite values, if not that would
be an invalid state (unstable).
o NOR gates: the latch responds to active-HIGH inputs (invalid state: S & R = 1);
NAND gates: it responds to active-LOW inputs (invalid state: S & R = 0).
o Diagram:

o Sample truth table with explanation:


SR Flip Flops

o Notes:
→ When S = 1 and R = 1, output Q can be either 0 or 1 depending on the state
of R and S before this current state existed, Therefore S =1 and R = 1 does
not change the Q output.
→ S = 0 and R = 0 is an undesirable state and must be avoided, It will cause
both Q and NOT Q to be set high at I and the flip-flop to become unstable.
→ The SR flip-flops can be used as a storage/ memory device for one bit;
because a value can be remembered but can also be changed (RAM).

45 | P a g e
o The simple JK flip Flop is the most widely used of all the flip-flop designs and
considered to be a universal flip-flop circuit.
o The sequential operation of the JK flip flop is exactly the same as for the
previous SR flip-flop. (JK however do not represent anything).
o The invalid states are now avoided using JK flip flops by adding a clock which
synchronizes the inputs.
o Diagram:

o Sample truth table with explanation:


JK Flip Flops

o Uses of JK Flip Flops:


→ Several JK flip-flops can be used to produce shift registers in a computer.
→ A simple binary counter can be made by linking up several JK flip-flop
circuits (this requires the toggle function).

46 | P a g e
END OF CHPATER 15 QUESTIONS
9608/03/SP/15

47 | P a g e
9608/31/ON/16

48 | P a g e
9608/31/ON/15

49 | P a g e
9608/31/MJ/20

50 | P a g e
9608/31/MJ/20

9608/32/ON/18

51 | P a g e
9608/31/ON/19

52 | P a g e
9608/31/ON/17

53 | P a g e
9618/03/SP/21

54 | P a g e
9618/31/MJ/21

55 | P a g e
9608/31/MJ/19

56 | P a g e
9608/32/ON/18

57 | P a g e

You might also like