AD Computer Science Flashcards
What is a digital computer?
a computer that accepts and processes data that has been converted into binary numbers.
What is binary and why do we use it?
These are transistors. They are tiny electrical components that form the basis of all digital computing devices. They have two distinct states: 1 - On 0 - Off
What kind of data do we store?
Text, image, audio, numbers.
Bits
A bit is the smallest unit of information that can be processed inside a computer.
A bit can hold one of two symbols, 0 or 1.
`
How many patterns?
2ⁿ
1 bit - 2 values = 0, 1.
3 bits - 8 values = 000,001,011,100,110,010,111,011.
Nibbles
A set of 4 bits is called a nibble.
A single nibble can store 16 unique values (2⁴) - the denary numbers 0 - 15.
Bytes
Two nibbles make a byte.
A byte is 8 binary digits.
Is the standard unit of measurement in digital computing.
Represents 256 values (0-255).
Most significant bit
Refers to the leftmost bit.
Has the largest place value.
Rules for binary addition
0 + 0 = 0
0 + 1 = 1
1 + 1 = 0 carry 1
1 + 1 + 1 = 1 carry 1
Overflow error
Overflow error means that the result of the calculation is too large for the space allocated.
The way a computer handles this will depend on how its set up:
It could crash and report an overflow error.
It could truncate the answer.
It could wrap the number around back to 0.
Sign and magnitude
The most significant bit is the ‘sign bit’.
1= minus
0 = positive
Problems with sign and magnitude
Waste one binary code.
Both 1000 0000 and 0000 0000 represent 0.
Addition doesn’t always work.
Two’s complement
The MSB is a minus number as well as a sign bit.
The largest positive number that can be represented is +127 (0111 1111)
The largest negative number that can be represented is -128 (1000 0000)
If it’s positive, make sure to write the + sign.
Denary to binary (negative numbers)
Convert the unsigned equivalent into 8 bit binary Flip the bit (each 1 becomes a 0 and vice versa) Add 1 (arithmetically, not appending)
Left shifting
Logical left shifting
MSB is shifted out of the pattern.
Each remaining bit is shifted left.
A new 0 is placed into all vacated spot
Arithmetic left shifting
Same as logical left shifting
Right shifting
Logical right shifting
A 0 is always inserted into the vacated MSB.
A 0 is always placed into all vacated spots
Arithmetic right shifting
The MSB is always maintained and copied into all vacated spaces.
Binary to Hexadecimal
Binary to Hexadecimal
0110 - 1111
6 - 15
6 - F
Hexadecimal to Binary
B - E
11 - 14
1011 - 1110
BE - 1011 1110
Denary to hexadecimal
Denary to Hexadecimal
58₁₀
16 - 1
3 - 10
3 - A
Hexadecimal to denary
Hexadecimal to denary
27₁₆
16 - 1
2 - 7
(32) - (7)
39₁₀
ASCII
One way to encode binary to store text is to use ASCII.
ASCII is the American Standard Code for Information Interchange.
Why is it necessary?
Imagine if everyone used a different encoding scheme for text.
They would not be able to communicate.
ASCII enables computing devices to communicate with another and to translate their communication into identical information.
Bit patterns
ASCII uses 7 bits.
128 patterns.
A - 65 - 0100 0001
a - 97 - 0110 0001
Limitations of ASCII
ASCII represents 128 unique characters.
ASCII is suitable for English (and languages that use the same characters) but it cannot represent languages that have additional different characters.
French, German and Mandarin are examples of languages that do not fit into ASCII.
For these languages Unicode was created.
The first version is able to represent 120,000 characters such as:
÷ x ᵀᴹ ©
Von Neumann Architecture
Every computer is made up of:
A processing unit that contains an ALU and processor registers.
A control unit that contains an instruction register and program counter register,
Memory that stores both data and instructions.
External data storage.
Input and output mechanisms.
Fetch
CPU fetches data and instructions from RAM.
CPU stores in its own memory called registers.
CPU uses address bus.
The memory address of the next item in the CPU wants is put onto the address bus.
Data from this memory travels from RAM to CPU on the data bus.
Decode
The CPU works out what the instruction it just fetched actually means.
The control unit decodes the instruction and gets things ready for the next step.
It does this by looking up the instructions from the instruction set.
This is the full list of operations that a microprocessor can carry out.
Execute
Data processing happens.
Instructions are carried out on the data,
Some instructions are carried out by the ALU.
Fetch - Decode - Execute summary
Instructions and data are stored in memory.
Instructions are fetched one at a time into the processor.
The instructions are decoded by the control unit.
The instructions are executed, sometimes using the ALU.
Explain why programmable computers were considered a huge step forward in digital computing.
Mechanical computers could only do one task.
The term ‘stored program concept’ is used to describe modern computers. State why this term is accurate.
Modern computers allow data and instructions to be stored in the same memory.
Every processor has a unique instruction set. Define what is meant by an ‘instruction set’.
Set of instructions that can be recognized and executed by the CPU.
Give three examples of operations that would be executed in the ALU.
Addition, subtraction, multiplication and division.
State what goes onto the address bus during the fetch-decode-execute cycle.
Memory address of location in RAM.
State two items that can go onto the data bus, during the fetch-decode-execute cycle.
Data and instructions
Fetch - decode - execute
Fetch - The CPU fetches data and instructions from the RAM.
decode - CPU working out what the instructions it fetched actually means.
execute - Execute
Data is processed
Central Processing Unit
The CPU is the brain of the computer.
It is the hardware component responsible for all the processing that the computer carries out.
Its job is to process data.
Processing means: searching, sorting, calculating and decision-making.
Control Unit
The control unit receives signals from other parts of the computer system and sends signals to them.
It is responsible for handling hardware interrupts.
It is responsible for fetching, decoding and executing instructions.
It has the most responsibility.
It is the powerhouse of the CPU.
Arithmetic logic unit
Performs actual operations on data. Arithmetic: + / = * Logic: AND, OR, NOT It is able to compare numbers against 0. It can test if two numbers are equal. It uses logic gates in combination to perform operations.
Registers
Also known as immediate access storage.
Registers are a type of memory that is extremely fast.
Each type of processor has different registers that are designed to hold different information.
Most processors have:
An instruction register - holds instructions currently being executed by the CPU.
An accumulator - holds the accumulated result of operations carried out by the ALU.
A program counter - holds the memory address of the next instruction to be executed.
Clock
A clock chip determines the speed of the CPU.
This chip uses vibrating crystals that maintain a constant rate of vibration.
The speed of the clock is measured in Hertz (Hz), which is the amount of cycles per second.
Current computers have a clock speed of 3GHz, which means 3 billion cycles per second.
Each ‘tick’ means that one part of the fetch,decode,execute cycle can be carried out.
pipelining
Pipeline is a method of keeping all the components busy to improve overall CPU performance.
Pipelining attempts to keep every component busy at all times.
Instructions flow through the CPU in stages.
This means that an instruction can be completed every clock cycle.
This increases CPU throughput allowing overall performance to be outputted.
A CPU is fully ‘pipelined’ if an instruction can be fetched every clock cycle.
Clock Definition
An electronic device that ‘ticks’ at regular intervals and is used to synchronise the actions of the other components of the CPU.
Hertz Definition
A measure of clock speed. One Hertz equals one cycle per second.
Pipelining definition
A way of improving the performance of the CPU. The stages of the fetch-decode-execute cycle are overlapped. While the CPU is executing one instruction, it is decoding a second and fetching a third one from memory.
Instructions Definition
An operation that the CPU carries out.
Fetch Decode Execute Definition
The cycle followed in the CPU to retrieve an instruction or data from memory, look it up in an instruction set to determine its meaning, and then enact the operation.
Control Unit
The unit that decodes the instruction and coordinates all the actions of the other components.`
Arithmetic logic unit
Carries out arithmetic operations (add, shift) and Boolean logic operations (AND, OR, NOT)
RAM Definition
The memory where the instructions and data are stored for programs.
Instructions and Data
In a computer, everything is represented in binary.
This includes the instructions that the CPU needs to carry out.
Instructions and data are stored in RAM until they are needed by the CPU.
Each instruction and item of data is a location in memory.
Each element of the memory has a unique address.
This means that each instruction has an address.
The first memory element that contains the instructions is the address of the instruction.
Buses
The CPU is connected to other components using a physical connection called a bus.
They are known as buses as they carry a number of bits simultaneously.
Data bus
Carries binary data from component to component.
For example an instruction from RAM that is being transferred to the CPU.
Bidirectional
Two way data transfer is required when reading and writing data to memory.
Control Bus
Carries signals that control the CPU components.
For example a signal to start fetching the next instruction
Bidirectional
It needs to carry status information to devices and to carry the status information signals that devices send back.
Address bus
Carries the address of a memory location.
For example the address of an instruction being fetched from memory.
Unidirectionality
The CPU can point to the addresses in memory or to other devices, however those hardware components cannot point to an address in the CPU.
Address bus
32-bit processors are cheaper, but can only use a limited amount of RAM.
The ‘bandwidth’ of these CPUs is related to the size of the address bus.
Bandwidth - the capacity of information that can be transferred in a second.
It refers to the number of unique memory addresses that can be accessed.
A CPU with a 4 bit bandwidth
4 bit addresses range from 0000 to 1111 inclusive.
1111 in denary is 15, which gives 16 addresses (including 0).
2⁴ = 16 addresses
Primary storage (memory)
A 32-bit CPU can access 4,294,967,296 unique memory locations.
Each memory location consists of a row of cells.
If the row is 8 cells long, each 4,294,967,296 different addresses points to a row of 8 bits (1 byte).
That’s why a 32 bit CPU can only use 4GiB of RAM which means it can hold 4 billion memory locations (addresses).
Memory (RAM)
Random Access Memory is volatile memory.
This means its contents are erased when its power supply is turned off.
RAM is often referred to as ‘primary storage’ as it sits close to the CPU.
It’s necessary to have somewhere to store the program and data when the power is switched off.
The non-volatile storage required for this job is most often a hard disk.
Hard disks are often referred to as ‘secondary storage’ to make them distinct from ‘primary storage’.
Control, address and data bus
Control bus
Transports signals that control the CPU and other parts of the computer system.
Bidirectional
It needs to carry status information to devices and to carry the status information signals that devices send back
Address bus
Carries the address of memory locations used to store data and program instructions.
Unidirectionality
The CPU can point to the addresses in memory or to other devices, however those hardware components cannot point to an address in the CPU.
Data bus
Transfers the binary data and instructions around the computer.
Bidirectional
Two way data transfer is required when reading and writing data to memory.
Give one reason why RAM is called ‘primary storage’.
RAM sits very close to the Central Processing Unit (CPU). It is very fast and can therefore store running programs and data.
Give one reason why a hard disk is called ‘secondary storage’
A hard disk sits further away from the CPU than RAM. It is not as fast as RAM and is used for storing programs and data that are not in execution.
General purpose devices
You can use the device for multiple purposes.
Most of the computers we use are general purpose.
New software can be downloaded and installed to give additional functionality.
Secondary storage
Making sure you can store and receive data.
In everyday computer use, you need a way to write data and store data when your computer is switched off.
You also need a way to retrieve data the next time you switch it on.
Magnetic storage
Magnetic media are coated with a substance that can be magnetised.
Magnetic storage technology works by magnetising parts of this substance as north and south poles to represent binary 1s and 0s.
Examples include: hard disk drive, tape drive and cassette.
Optical storage
Optical media consists of a platter with a flat reflective surface.
Optical storage technology works by using a laser to burn ‘pits’ into the flat surface.
The reflective areas between pits are known as ‘lands’.
A laser is directed onto the medium’s surface.
When it hits land, a beam reflects (this is read as binary 1).
When it hits a pit, the beam does not reflect (this is read as binary 0).
Examples: CD and DVD.
Solid state / flash drive
Solid state media consists of silicon chips that feature a special kind of transistor called NAND flash.
This type of media is called ‘solid state’ because it has no moving parts.
Solid state technology works by using a large electric current to force electrons through a barrier trapping them in positions called pools.
A full pool - 0.
An empty pool - 1.
Examples include: SSD card, USB, SD memory card and flash storage.
Advantages and disadvantages of optical storage
ADVANATGES
Cheap to produce
Thin and lightweight
Portable
DISADVANTAGES
Slow to access
Low capacity
Prone to scratches
Advantages and disadvantages of magnetic media
ADVANTAGES
High capacity
Quick to access,
Providing the disk is defragmented periodically
DISADVANTAGES
Has moving parts that will eventually fail
Advantages and disadvantages of solid state storage
ADVANTAGES Quick to access No moving parts so very reliable. Low power requirements Quite No need to defragment
DISADVANTAGES
Expensive.
Has a limited number of read write cycles
Explain why secondary storage is necessary.
RAM is volatile. It loses its contents when the power is switched off. Secondary storage provides non-volatile storage that can be used to write and rewrite data, so that it does not vanish when the power is turned off.
Define the term ‘general purpose device’.
A computing device that can have different application programs loaded into it to provide different or enhanced functionality. For example, a smartphone can also be used as a calculator and a camera.
Capacity, portability and speed
Capacity: how much data can the device store?
Portability: can the device be moved around without damaging it or the data it contains?
Speed: how fast can data be read from and written to the device?
Units
bit byte kibibyte mebibyte gibibyte tebibyte
B (byte) K (thousand) M (million) G (gazillion) T (trillion)
Media students have taken part in a national competition. Each has produced a one-hour high-definition video of an original screen play. The judges for the competition are in different parts of the country and each will do a pre-screening of a subset of entries. They are willing to accept any type of media. The competition sponsors have asked that all submissions be sent through the post, directly to one of the judges.
Name and give a justification for a way to send the submission by physical post to the judge.
The file size of the video is likely to be about 3-4 GiB. The capacity of a DVD is more than sufficient to hold such a video. DVDs are cheap to buy and strong enough to be sent through the post. Alternatively, students could use a high-capacity flash drive (memory stick). The advantage of using a flash drive is that there would be no need to have a dedicated peripheral device to record/view the video. However, using a memory stick for this purpose would be considerably more expensive than using a DVD. There is also a greater likelihood of a memory stick being damaged in transit.
A group of students is working on a monthly college newsletter. Due to other activities, four of the group did not have time to complete their sections at school, so must complete them at home. Unfortunately, the college does not allow access to students’ file storage from home.
Name and give a justification for a way that the students can carry the newsletter files and finish their sections of the newsletter at home.
A flash drive (memory stick) would be the best way to take the newsletter files home. Flash drives are lightweight and portable and would have sufficient capacity to hold the files. Most laptops, even old ones, have USB ports where a USB drive can be inserted, so no other device is required.
Files can then be worked on either directly on the USB drive or uploaded to the hard disk of each student’s laptop. Files can be copied back to the USB drive when they have been updated and they need to be taken back to school.
What makes a computer
What makes a computer
- Software programs are made up of data and instructions.
- Software programs are stored in secondary storage which is persistent but slow to read and write.
- Programs are copied into the memory (which is volatile) but have a high read and write speed.
- Then the CPU performs the fetch decode execute cycle to carry out each instruction.
Software
- Two types: system and application
- System software - programs that enable a computer to function. They include the operating system and utility programs.
- Application software - programs that the user interacts with most.
OS
The Operating System
-Its main function is to provide a platform for other software, so that this software can interact with the computer hardware.
What is an operating system?
Its job is to provide an interface between the hardware and other software, and the user.
Operating system responsibilities
1) Process management: organising instructions in memory so that they can be processed.
2) File management: organising the contents of secondary storage.
3) User management: providing a user interface and access levels.
4) Peripheral management: interfacing with device drivers to control physical devices.
OS definition
An operating system (OS) is system software that enables a computer’s hardware to communicate effectively with its software.
It provides a platform on which application software can run and an interface for users to interact with a computer.
Heiracgy
Hierarchy
- Most operating systems use a hierarchy of directories to organise all of the stored files.
- A directory refers to a folder containing other items- those can also be directories (sub-directories) or files.
Allocating space
- The OS is responsible for allocating space on the hard disk.
- Files are broken into blocks.
- Each block of a file is placed into an empty sector. Blocks may not be placed into contiguous sectors.
- If the whole sector is not filled, then wasted (slack) space is left.
Q: A file is 5.4MiB.
The block size of the disk is 512 bytes.
How many blocks are needed to store the
file?
A: ⌈ (5.4 × 1024 × 1024) ÷ 512 ⌉