210 likes | 373 Views
COMPUTING. 1.1 – System Architecture. Computer architecture - the internal, logical structure of computer hardware CPU (Central Processing Unit) – carries out the fetch-decode-execute cycle Fetch instructions from memory – control unit fetches data and copies it to the Memory Data Register
E N D
1.1 – System Architecture Computer architecture - the internal, logical structure of computer hardware CPU (Central Processing Unit) – carries out the fetch-decode-execute cycle Fetch instructions from memory – control unit fetches data and copies it to the Memory Data Register Decode – the control unit decodes instructions in the MDR Execute – data moved from MDR to memory Arithmetic & Logic Unit (ALU) – performs the arithmetic and logical operations Control Unit (CU) – controls the flow of data and decodes instructions Accumulator (ACC) – temporary store of ALU results Program Counter (PC) – stores address of the next instruction Memory Address Register (MAR) – stores address of data to be fetched from/to memory. Memory Data Register (MDR) – stores data fetched/sent to memory Address bus – carries addresses from the processor (MAR) to main menu Data bus – carries data/instructions from main menu back to CPU (MDR) Cache – fast memory used by CPU for frequently used data. More cache = faster computer Clock speed –higher clock speed = more instructions processed per second = faster Multi-core CPU – instructions are processed simultaneously. More cores = more instructions processed = faster Embedded system - dedicated computer system (single chip) part of electronic device (washing machine) Low power = small power source Small = fit inside band Robust = used in car Low cost = mass produced. Dedicated to one task = special software
1.2 – Memory RAM (Main Memory) – volatile memory = loses data when no power. Holds operating system, applications and data being working on. CPU can access RAM quickly. More RAM = improved performance and more programs/data is available ROM – non-volatile memory = data not lost when power is off. Provides data and instructions for boot process. Cannot be overwritten. Programmed by manufacturer. Virtual memory – Section of hard disk used as RAM temporarily. Virtual memory = slower than RAM Flash memory/solid-state memory – special type of ROM written to by computer. Flash memory = faster than magnetic hard disk but slower than RAM.
1.3 – Storage Secondary storage – stores operating system, application and data Magnetic hard drives – reliable, cost-effective, high capacity, low cost Solid-state drives (SSD) –flash memory. No moving parts = robust and portable. Faster to access data, lower power and lightweight = hand-held devices. Smaller capacity than hard disks + higher cost (e.g. USB pen/camera) Hybrid drives – low-cost storage capacity of magnetic hard disks + access speeds of solid-state memory = cost-effective and fast secondary storage. Frequently used data stored on magnetic disk is transferred to solid-state device. Optical Drives – low cost and robust CD-ROM(700MB)/DVD(4.7GB) – ROM – Read-only media = 700MB CD-R/DVD-R – Write-once/read-many-times media CD-RW/DVD-RW – rewritable media Blu-ray DiscTM(25GB per layer) – uses blue light, data stored at higher density than red light (CD/DVD). Up to 4 layers = large amounts of data at low cost Choosing: Capacity – how much? Access speed – how quickly? Portability –transported? Size and weight? Durability – hostile environment? External shocks/extreme conditions? Reliability – repeated use, without failure? Cost – cost per unit of storage related to value of data?
1.4 – Wired and Wireless Networks (1 of 4) Network – collection of linked computer systems Easy communication between users Files can be shared Peripherals can be shared Centralised administration and updates User activity can be monitored Users can login to any connected computer Wide Area Network – covers large geographical area = many cities/countries Local Area Network – covers small geographical area= single/many buildings Network Interface Cards (NIC) – connect device to network Provides electronic signals to send and receive data Uses network protocol to send and receive data Network switches – connect devices by sending data packets to destination Self-learning= creates table of connected devices Uses MAC (Media Access Control) address to identify connections Routers – sends data packets between networks Connect networks to Internet Creates tables of destinations routes and chooses which path to use
1.4 – Wired and Wireless Networks (2 of 4) Client-server Network – most common LAN organisation. Servers = high specification computers – provide services (logins, security, file handling and Internet access) for rest of the network gPeer-to-peer Network – no server All computers have equal status = computers can share files with the others Small home installations/large peer-to-peer systems to share files, often illegally using the Internet.
1.4 – Wired and Wireless Networks (3 of 4) Wireless networks – uses wifi (radio signals) to connect devices Wireless access points (WAP) + wireless router connect wireless devices to a network Wired networks – uses copper Ethernet cable to physically connect devices Cat 5/Cat 6 cables (UTP (unshielded twisted pair) cable) Coaxial cable – bulkier and more difficult to install Fibre-optic networks – transmits signals as light along glass fibres Signal deteriorates slowly = good over long distances No interference from neighbouring cables Suited to use in exposed locations Internet – worldwide collection of networks + use of agreed standards World Wide Web – collection of websites hosted on servers connected to Internet Location of websites = IP addresses, e.g. 68.172.201.167 Domain Name Server (DNS) – translates IP address into URL (Uniform Resource Locator) = www.hodder.co.uk = easier to remember URL – typed forwarded to DNS to look up IP address If DNS does not know IP address for URL it is forward on to next DNS
1.4 – Wired and Wireless Networks (4 of 4) The cloud – remote provision of storage and software resources. Uses servers and data centres located worldwide + connected to Internet.
2.1 Algorithms (1 of 6) Pseudo code key terms variable/constant=input(“string”) print(variable/constant + “string”) if variable/constant (comparison e.g. ==) value else if else for i in range 0 to 5 while variable = condition Flow chart symbols Abstraction – making a model of a situation so that it can be analysed. E.g. maps are a representation of the earths surface Decomposition – breaking a problem down into sub-problems. Linear search - looks at each item in turn until it finds the target or until it reaches the end of the list: Start/Stop Process Input/Output Decision
2.1 Algorithms (2 of 6) Linear search - Looks at each item in turn until it finds the target or until it reaches the end of the list. position=0 len=lengthof list while position<len AND list[position]!=itemsearchedfor add 1 to position end while if position>=len then print(“item not found”) else print(“item found at position”+position end if If searching for Gloves, the algorithm will look at positions 0, 1 then 2. It will return “Item found at position 2
2.1 Algorithms (3 of 6) Binary search - Requires all data to be ordered before it can search for an item: Item=input(“enter the item wanted”) lowerbound=0 upperbound=lengthoflist-1 Found=false while found==false AND lowerbound!=upperbound midpoint=round((lowerbound+upperbound)/2) if list[midpoint]==item then found=true elseif list[midpoint]<item then lowerbound=midpoint+1 else upperbound=midpoint-1 endif end while if found==true then print(“item found at”+midpoint) else print(“item not present”) end if Searching for C: C in lower half of list so top half discarded C is later in list than midpoint so discard lower section
2.1 Algorithms (4 of 6) Bubble sort - Easiest method but very inefficient. swapflag=true while swapflag==true swapflag=false position=0 for position=0 to listlength-2 compare the item at current position AND position +1 if out of order swap them AND set swapflag next position End while
2.1 Algorithms (5 of 6) Merge sort - is more efficient than bubble sort, but slow for small lists. while list1 !=empty AND list2 != empty if first item list1<list2 then move first item from list1 to newlist else move first item from list2 to newlist end if end while if list1 == empty add remainder of list2 to newlist else add remainder of list1 to newlist end if If there is an unordered list we can create an ordered set of lists by: Having just one item per list Merging the one-item lists into two-item list, then four-item lists etc. it will eventually sort the data Takes the same time for any list regardless of how unordered it is Takes up a lot of memory creating so many lists
2.1 Algorithms (6 of 6) Insertion sort - is easy to code and good for small lists, but not efficient with large lists. first item = sorted list AND remaining items = unsorted list while unsortedlist != empty item from unsorted list < item from sorted list swap end while end while
2.2 Programming Techniques Data types - Real numbers (10.1), integer (10), string (hello!1), char (a) & boolean (TRUE) Casting – changing a variable from one data type to another Declaration – Identifying a variable or constant so that a suitable memory location can be assigned to it. Constant – data value is set when declared Variable – data value is set while program is running Array – data structure = several variables stored under one name & an individual variable = index Sequence – an algorithm putting instructions in order (INPUT, OUTPUT and calculation) Selection – an algorithm with a decision or choice (IF, ELSE, END IF) Iteration – an algorithm with a loop (FOR, END FOR, REPEAT, END REPEAT, WHILE, END WHILE) Functions – add +, subtract - , multiply * , divide / , to the power of ** (e.g. 42 = 4**2) DIV or // (Quotient) – division giving the answer as an integer, ignoring the remainder (e.g. 14/3 = 4 rem 2) MOD or % (Modulus)– finds the remainder, of a division (e.g. 14/3=4 rem 2) Assignment – one = sets the values of a constants/variables (e.g. total = 10 – makes the variable total be equal to the value 10) Comparison – equal to ==, not equal to <> or !=, less than <, greater than >, <= less than or equal to, >= greater than or equal to Boolean operators – AND (e.g. 3<5 AND 2>1), OR (e.g. 1>8 OR 2==2), NOT(10>6) – these will return a TRUE or FALSE result String – string.length = returns the length, string+string = concatenates two strings, string.upper/string.loweer = upper and lowercase Array - collection of several variables under one name. Each individual variable has an index to refer to it (e.g. Names[7]) File – stored data saved. A file can be read or write. (e.g. newFile=openRead(“newFile.txt”) or newFile=openWrite(“newFile.txt”)
2.3 – Producing Robust Techniques Logic errors – doesn’t prevent a program from running + doesn’t produce expected output. Syntax errors – error in rules. Validation checks – follow a rule. Range check – within a range (e.g. age > 18) Presence check – data is entered (e.g. password) Type check – right data type (e.g. integer, real, string, Boolean) Format check – right format (e.g. dd/mm/yy) Length check – right length (e.g. 11 digits long) Input sanitisation– check and change input before passing Whitelist – all acceptable inputs = long setup, restrictive, but secure. Blacklist – all unacceptable inputs = less restrictive & less secure. Maintainability – test logs simplify tracking down bugs & indenting provides a clear structure. Iterative/white box testing – testing each stage of development. Final/black box testing – testing final program functions as expected. Test data – (e.g. age >=5 AND age<=16) Valid – typical (e.g. 10) Valid extreme – end of range (e.g. 16 or 5) Invalid – out of range (e.g. 25) Invalid extreme – just outside of range (e.g. 17 or 4) Erroneous – wrong type of input (e.g. cat)
2.4 – Computation Logic Logic gate – circuit that produces an output based on inputs. Truth table – all possible input combinations and their output. Examples
2.5 – IDE & Translators Integrated Development Environment – software with functions to develop a program. Editor – for source code. Highlights key words + variables, auto-indents + highlights potential errors. Error diagnostics – inspect variables + step-by-step progression through program Build feature – compile + link other elements into program. Translator, compiler + interpreter. Virtual machine – emulation of particular computer system. No tools to change program. High-level language – like human language = writing is easier. One high-level instruction = several machine code instructions. High-level language –needs to be translated into machine code to be executed. Machine code instruction – binary code read and executed by computer. Specific to particular computer. Assembly language – low-level language that uses mnemonics. Translator – converts high-level or low-level commands into machine code. Assembler – translates assembly language programs into machine code. Interpreter – translates one line of high-level code at a time and executes it. Stops when it finds an error. Compiler – translated whole program from source code into object code. Gives list of errors at end. Source code – high-level language before it is converted into machine code. Object code – machine code produced by translator to be run on the computer. Opcode – instruction to tell CPU which operation to do. Operand – instruction to tell CPU which data to apply operation to.
2.6 Data Representation (1 of 2) Binary format – computer uses switches which are on or off.Instruction – opcode (unique bit pattern) + operand (bit pattern)Bit – binary digit = 0 or 1. 4 bits = nibble, 8 bits (b) = 1 byte (B), 1000 bytes (B) = 1 kilobyte (kB), 1000 kilobytes (kB) = 1 megabyte (MB), 1000 megabytes (MB) = 1 gigabyte (GB), 1000 gigabytes (GB) = 1 terabyte (TB), 1000 terabytes (TB) = 1 petabyte (PB) 128 64 32 16 8 4 2 1 = binary Hexadecimal – 4 bits = shorter to remember, quicker to enter & less error prone | 8 4 2 1 | 8 4 2 1 = hexadecimal A=10 B=11 C=12 | D=13 E=14 F=15 Binary addition 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0 carry 1 1 + 1 + 1 = 1 carry 1 Binary shift – moving the binary digit left or right. Left shift – multiplies the number by 2 for each place. Right shift – divides the number by 2 for each place. Parity bit – binary data check digit Examples
2.6 Data Representation (2 of 2) Even parity bit – added to make even number of 1’s. Odd parity bit – added to make odd number of 1’s. ASCII – each character assigned a unique character code (binary number of 7 bits = 128 distinct characters). Extended ASCII – 8 bits = 256 characters. Character set – complete set of characters available to a compute Unicode – character set using code pages to give a range of language symbols (16 or 32-bit binary number = several billion character codes = most languages) Sound – amplitude of sound wave is measured at regular intervals and converted to binary. If interval is smaller, sample more often = better quality, but more data to store = larger file. Sample rate – number of audio samples captured every second. Bit depth – number of bits available for each clip. Bit rate = sample rate x bit depth Images – stored as pixels (smallest picture element in an image). Colour depth – number of bits used to represent each pixel Resolution – number of pixels per inch Metadata – information stored with image file so computer can recreate image from the binary data Compression – Reduces the file size + download times and storage needed Lossless – no data is removed, only reorganized so original file can be restored (e.g. tiff) Lossy – some data is removed so original file cannot be restored. Smaller file size, but some quality is lost. (e.g. mp3) Examples