Chapter Notes on Computing Part 4

Embed Size (px)

Citation preview

  • 8/6/2019 Chapter Notes on Computing Part 4

    1/17

  • 8/6/2019 Chapter Notes on Computing Part 4

    2/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page2of17

    Making sure that the user can interact with the computer by providing aninterface

    Ensuring that any errors in the computer are reported to the user, usuallywith messages on the VDU

    Managing files on the hard drive and in memory and allowing the user tomanage files by providing a file management utility program

    Providing utility programs such as FORMAT DISK, or DEFRAG

    Scheduling. The OS provides programs that ensure the resources of thecomputer such as CPU time, are used as efficiently as possible by all thedifferent users and the different jobs.

    Memory management (including virtual memory, paging, segmentation,threshing)Purpose of Memory Management

    Allocate memory to allow separate processes to run at the same time Deals with allocation when paging Reallocates memory when necessary

    Protects processes from each other

    Protects the operating system Enables memory to be shared

    Virtual memory

    Use of backing store As if it were additional memory

    Uses paging/fixed size units

    Swap pages between memory & backing store to make space for pages needed

    Holds part of program not in use

    Allows programs to run that need more memory than is availablePaging and segmentation

    Similaro Splitting a (large) program into smaller sectionso Only part of program needs to be in memoryo Some of program can stay on disko Allows program to run when there is insufficient memoryo Virtual memory

    o Splitting memory into smaller sectionso Both need indexingo Sections of program need not be all together

    Differenceso Segments may be variable size, pages are fixed sizeo Pages are smaller

    Disk threshing

    occurs when moving pages between memory & disk disk is relatively slow

    high rate of disk access

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    3/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page3of17

    more time spent transferring pages than on processing

    Scheduling to make efficient use of resources; job queues, priorities

    Purpose efficient use of processor time efficient use of resources

    maximise number of users no apparent delay for users

    maximise throughput of CPU.Round robin

    Each task allocated a time slice in turnSystem of priorities

    Highest priority first

    Interrupts a signal

    that causes a break in the execution of the current routine/requestsprocessing time

    the current routine can be resumed after the interruptPriorities for interrupts

    more than one interrupt can occur at a time

    deal with the more urgent interrupt first

    because a more urgent interrupt has a higher priority

    to avoid loss of data

    Interrupt in I/O bound and processor bound

    Program A is Processor bound has low priority Program B is I/O bound

    has high priority Program B starts

    Once data is being printed, program A has processor time until an interrupt requests more data for printing

    Program B is given processor time

    as it has higher priority

    This is repeated until one program is complete

    Otherwise if program A had priority it would stop B from runningInterrupt in FDE cycle

    Interrupt flag is set Current instruction/cycle is completed

    Interrupt is identified Interrupt priority is compared with current task

    High priority

    So current values are placed on a stack Start address of interrupt service routine is placed in PC

    ISR (Interrupt Service Routine) is run

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    4/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page4of17

    To avoid loss of data/store data

    Spooling

    Output data To slow peripheral/disk drive E.g. for printing later/when appropriate

    when processor is not busy/after interrupt To avoid delays Some peripherals (e.g.) printers) are relatively slow/speed mismatch References to jobs stored in a queue/buffer

    each job called by its reference jobs can be prioritised.

    Network operating systems and their main features; transparency,

    directory services, security, network printingNetwork Operating System (NOS)

    is an operating system that gives computers the ability to communicatewith other computers on a network.

    Features

    Controls communication between workstations themselves and betweenworkstations and servers

    Allows and manages file sharing

    Allows and manages printing and other resources Controls internet access amongst stations

    Manages user accounts Manage security Manages automate system back-ups

    Manage and reports on the use of the systems resources, such as eachusers hard disk allocation and how many prints they are allowed to do

    Provides a number of different user interfaces.Transparency

    Users are unaware of the hardware actions Users are unaware of the software actions

    Users do not need to understand the NOS tasks Each user is unaware of other users

    Privacy

    restrict data access to certain people. Maintain

    o passwords (accessing system; accessing files)o physical protection (some data at certain terminals only)o allow authorised accesso according to access rightso encryption.

    Security Risks

    Hardware failure

    Fire

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    5/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page5of17

    Theft

    Disgruntled employees

    Hackers trying to break into the system Computer viruses

    Methods for safety

    Backups Physical security

    Passwords Anti-virus

    Network Printing

    Packets from different users arrive at the print server and are stored in different files for different users Spooling (as above) When a file is complete it is added to the print queue and files are printed in turn

    4.2 Translators (Compilers and interpreters)

    Compilers and interpretersTranslator

    (Convert) from high level language/source code/language used bypeople

    to low level object code/machine code/binary/language used by

    computerInterpreter

    software

    that translates & executes a program

    one instruction at a time/line by line

    each time the program is run / without generating an executableprogram

    stops at first error found

    Find erroro Used during program developmento

    to debug (sections of) codeo Translates one lineo then allows it to be run before translation of next lineo Errors found more easily/quicklyo Starts to run program from any point

    Compiler Used when program is completed

    Executable program runs quickly

    Executable program prevents purchaser from re-using code Translates the whole program as a unit

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    6/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page6of17

    and creates an executable programAdvantages of using an interpreter rather than a compiler

    Errors are reported as they occur rather than together

    easier to correct errors

    Less memory is needed as only the object code from a single source code instruction in use is

    held

    interpreters are usually smaller programs than compilers Program can be restarted from any point

    after correcting an error Can insert breakpoints (for debugging) to halt the program Can trace variable values which are displayed as the program is running Can set variable values while running the program

    Disadvantages

    the user needs an interpreter / the program runs more slowly

    because the program has to be translated each time it is run

    the stages : lexical analysis, syntax analysis; How are errors detected andreported?Lexical -> Syntax -> Code generation

    Lexical analysis Reserved words/standard components are replaced by tokens

    a token is a string of binary digits

    of fixed length

    Variable names are checked Variable names are entered in the symbol table

    Constants are entered in the symbol table Data type (/space) required is entered in the symbol table

    Error reporting occurs Unnecessary characters (white space, comments) are removed

    Program is formatted ready for the next stage/syntax analysisSyntax analysis

    The stream of tokens is split up (or parsed) into expressions

    Check the database of the syntax rules Check the semantics

    Syntax error

    During syntax analysis

    Statements are checked against the rules of the language Uses symbol table

    (if statements are not valid) errors are reported To alert the user/programmer

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    7/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page7of17

    Code generation and optimisationCode generation

    Produces machine code/executable code Several instructions for each high level language instruction

    All variables are given addresses All constants are given addresses Relative addresses are calculated

    Optimisation Makes code as efficient as possible

    Speed of processing is improved Number of instruction is reduced

    Source code High level language (version of program)

    Written by user Easy for people to understand

    Translated by (input to) compiler (accept translator)Object code

    Low level/machine code/binary code

    Used by computer Runs without further translation/executable

    Produced by (output from) compiler (accept translator)Executable code

    a complete program

    ..that the computer can run without further translation/has been compiled

    machine code / low level language

    Linkers and loadersLinker

    combines modules/library routines

    that are already compiled/in object code/in executable form

    Loader

    copies modules into memory

    from backing store

    ready for execution

    completes address links to program.

    4.3 Computer Architectures and the fetch-execute cycle (see also 4.5)

    What is Von Neumann Architecture? Why are registers needed?Von Neumann

    Instructions and data stored together.. in the same format

    Instructions fetched and executed one after another

    A single processor (control unit)Registers

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    8/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page8of17

    LocationsusedforspecificpurposesThe fetch-decode-execute-reset cycle and the use of registers

    Registers using in a FDE cycle Program counter holds address of next instruction MAR points to the data/instruction to be used

    MDR holds data/instruction when copying from/to memory CIR (Current Instruction Register) hold a copy of the instruction to be

    executed

    Copy contents of PC to MAR Increment PC

    Load instruction pointed to by the MAR to MDR

    Copy instruction from MDR to CIR Decode instruction (in CIR)

    Execute instruction

    Check for interrupt

    Features of a processor that determine its performance (Clock) speed/pulse rate/in MHz more instructions executed at faster clock speed

    Word size number of bits processed together

    Bus size (data bus) number of bits processed/transferred together

    Architecture e.g. single or multiple processor/pipelining

    Cache size to allow faster access (to part of program and data)

    Other machine architectures (eg parallel processor systems), pros andconsParallel processor system

    Multiple processors used together/simultaneously

    To perform a single job/different parts of the same program (at the sametime)

    Program may be split into a number of tasks each of which may be processed by any available processor Pros

    o Increased processing speed/multiple instructions processed at thesame time

    o Different parts of program performed at the same timeo Performs complex tasks efficiently

    Conso Not suitable for all programso Program may need to be rewritten

    E.g. Weather forecasting/expert system

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    9/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page9of17

    Pipelining

    processor is split into parts

    each part handles one of fetch, decode, execute (reset)

    Conso Change in instruction sequence/e.g. jump instruction: requires pipe

    to be cleared

    4.4 Data representation, data structures and manipulation

    All topics from 1.4, plus

    floating point binary representation using mantissa and exponent;normalisation; the trade-off between accuracy and range

    data structures: (for each, how to add, change, delete)

    list (linear, linked?)

    Stack

    LIFO Two pointers

    Queue

    FIFO One pointer

    Add

    Check for full queue Error if it is full

    Move rear pointer to point to new item

    insert data at rear of queueDelete

    Check for empty queue

    Error if it is empty Take data pointed to by front pointer

    and move front pointer to next item

    TreeIn-order

    traverse left subtree

    visit root

    traverse right subtree

    Delete

    traverse tree until item is found..

    and remove elements below item

    store them

    delete item (accept only if in correct place)

    transfer stored items back onto tree

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    10/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page10of17

    (static and dynamic implementation of the above, pros and cons)Static

    Pros Storage needed is known Easier to write program

    Fewer errorsCons

    Size restricted (to that declared when structure is created)

    May waste memory

    Searching binary, serialSerial Search

    Start at the first item Look at each item in turn

    Until it is foundBinary Search

    Look at middle word Repeated halving

    Until it is found Pros

    o Faster for large set of data/fewer values need to be checked

    Conso Data must be in order/more complex algorithm

    Sorting insertion*, quick*

    Insertion Sort Start with the second item If it is smaller the than number one, swap

    Go to the third item, insert it into the correct position Repeat until all items in the list have been inserted into the correct

    positionsQuick Sort

    Select an item at random, the pivot

    Create two new lists, one with all items less than pivot, other with itemsgreater than pivot

    Repeat until lists only have one item

    Merging*

    * algorithms needed

    ** error at start of algorithmCheck empty(underflow) or full(overflow)

    4.5 Programming paradigms

    Pseudocode for writing algorithms

    The nature and purpose of 3rd and 4th generation languages (?)

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    11/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page11of17

    Third Generation

    Imperative

    (The programmer must) give a step by step description of solution toproblemFourth Generation

    Declarative Knowledge base/facts and rules

    User can state what they want to achieve without giving detailed steps

    Programming paradigms : low-level, object-oriented, declarative,procedural, functional. Explain with examples how they are typically used.Low level language

    close to design of computer/lack of portability

    machine-oriented language assembly language used for tasks connected with running the computer

    uses mnemonics for instructions

    uses variable names for addresses uses labels

    1-1 correspondence between low-level language and machine codeObject-oriented

    If must contain objects that have methods and data, with the data onlybeing accessible via the methods

    The objects must be instantiate from a class, making use of polymorphismProcedural

    3rd generation

    step by step instructions to solve a problem to explain how to solve the problem

    Declarative

    4th generation state what to achieve

    without giving detailed steps

    uses facts and rulesFunctional

    Breaking a maths problem down to the smallest possible units then writing a set of functions for those units Each function then receives parameters from outside the function,

    manipulates the parameters mathematically and then outputs parametersto other functions

    Characteristicso An instruction set geared towards handling maths problemso Being excellent at handling recursiono You can write mathematically-reliable programs

    Structured programming techniques : use of functions and procedures;

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    12/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page12of17

    use of Jackson Structured Programming and Top-Down Design (Stepwiserefinement)

    Procedure A subprogram that performs a task is given an identifier

    ..the identifier can be used as a program instructionParameter

    An item of data/value (of a variable)

    supplied to a function or procedureTop-down

    Successively break task into simpler tasks

    until tasks can be programmed Clear program structure

    Easier to write program as a series of modules Identify common or standard modules

    Tasks can be shared between many programmers according to their expertise

    easier to de-bug.

    How are parameters (value and variable) and variables (global and local)used?Global variable

    May be used throughout program

    including all proceduresLocal variable

    Restricted to one procedure

    Same variable name may be used for different values in different procedures

    Problems with global variables

    Difficult to trace errors not sure which module has changed a value or conflict between

    variables

    Different programmers may change them independently

    Modules are not independent

    How is the stack used? (return addresses, variables)Passing parameters between modules

    Values

    Addresses pushes on to stack

    when module is called

    Popped off stack

    ,by called module Need to be popped in reverse order (last in, first out)

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    13/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page13of17

    to allow successive calls

    Recursion

    Object-oriented languages : data encapsulation, classes and derivedclasses, inheritanceData encapsulation

    Data can only be accessed via methods provided by objects.Class

    Describes shared attributes and methods

    A template for A set of objects

    that have state and behaviourObject

    An object is one instance of a class

    ..is an actual real-world entityInheritance

    Class has its own attributes and methods

    and those from its super classDerived class

    A class has all the features of its superclass/class its come from

    and has additional features of its own Inheritance

    A class that uses another class

    Declarative languages: backtracking, instantiation, predicate logic,

    satisfying goalsDeclarative language

    A programming language uses facts and rules Fact

    o Predicateo which may have argumentso Something that is always (unconditionally) true

    Ruleo May be used to define a relationship between factso Simple statement store in knowledge baseo A rule is true depending on a given condition

    Goalo a query to be solved

    E.g. expert system/medical diagnosis/equipment fault-finding/oilexploration/robot control

    Reasons:o Further data can be added when availableo Large amount of informationo Order of storage irrelevanto Can explain how they have arrived at their solution

    Backtracking

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    14/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page14of17

    Follow rules

    towards goal

    If goal fails go back to previous match and

    start again from this point

    towards an alternative goalInstantiation

    If B is an instant of A, then A is instantiated to B

    Functional languages: list processing, head and tail recursionSee Programming paradigmsTail recursion

    The function call is at the end of the expression

    Low-level languages: use of accumulator(s), registers, program counter,direct, indirect and indexed addressing of memoryAccumulator

    temporary storage (in the ALU)

    holds data being processed/result of calculation

    deals with the input and output in the processorMemory address register (MAR)

    Address of the data (instruction) to be fetched/of the next location to be accessed

    Memory data register (MDR)

    Temporary store for data/instruction being transferred to/from memory

    Acts as a buffer

    to compensate for different speedsProgram counter

    Address of next instruction

    increment to address of next instruction every time an instruction is fetched

    change to address part of instruction/change to start of ISR when it is a jump instruction/when an interrupt occurs

    Immediate addressing

    Using constantDirect addressing

    E.g. Store the contents of the accumulator at address 0101 Cons

    o uses fixed memory location/not relocatable/limited address rangeIndirect addressing

    go to vector address which holds location of the real address needed

    Indexed addressing

    modifies the address

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    15/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page15of17

    by adding the number

    from the index register

    Proso easy to alter the index registero easy to access a range of memory locations(eg for an array)

    Backus-Naur form and syntax diagrams. How are they used?BNF:::= is defined by| means or< > means the meta variablee.g.::=0|1|2|3|4|5|6|7|8|9::==+|-

    The terminal symbols are symbols which cannot be broken down any further4.6 Databases

    Types of database : flat-file, network, hierarchical, relational; (all the rest ison relational database management systems - RDBMS)Flat-file

    all the records are held in one table

    each row in the table corresponds to one record each column in the table corresponds to a different field.

    Tables are two-dimensional structuresRelational

    Is kept as a number of related tablesHierarchical

    Using a tree structure

    Get more detailed information as you go to a lower levelNetwork

    Records are cross-linked as well as linked above and below in a networkdatabase

    Design a simple (?) relational database to 3rd normal form, defining tablesand views, and drawing Entity-relationship models and entity life historiesNormalisation

    many-many relationships are not allowed

    avoid duplicate dataThird normal form

    Contains no functional dependencies between attributes other than the primary key (or a candidate key)

    Limits duplication of data

    Removes multi-valued attributes

    Design forms for input, deletion, modification, querying of database

    RDBMS compared to flat-fileFlat-file

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    16/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page16of17

    Duplicate data stored

    so storage wasted/data redundancy

    Inconsistent data more than one version of the data item

    Program-data dependence so difficult to change data format

    Change of data

    may require rewriting file Lack of flexibility difficult to obtain new types of reports

    RDBMS avoid data duplication

    avoid inconsistent data

    easier to change data easier to change data format

    data can be added easily

    easier to control access to data.

    Primary, secondary and foreign keysEntity

    A thing about which there is a need to record dataAttribute

    A property of an entityPrimary Key

    Unique value To indentify a record

    Foreign Key

    Primary key from one table

    used as an attribute in another table Used to link tables

    Access to the database for different users, at different timesAccess rights

    Security

    senior staff update data, others have read only access Privacy

    financial data not seen by all staff Access data needed for their job

    e.g. financial data only seen by those who need to Why it may change temporarily

    o Data may become read onlyo while being used/updated by another usero to avoid inconsistent updates

    to avoid attempts to sell the same car twice

    www.revision-notes.co.cc

    http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/http://www.revision-notes.co.cc/
  • 8/6/2019 Chapter Notes on Computing Part 4

    17/17

    Computing Revision Guide 2509

    2008JimTang dOverbroecksCollege Page17of17

    Structure of a RDBMS : data dictionary, data description language, datamanipulation language

    Information stored in the data dictionary Names of tables/columns Characteristics of data (e.g. length, data type)

    Restrictions on values in columns Meaning of data columns

    Relationships between data Which programs can access data

    Data Definition Language (DDL)

    A language used to define the data structure (for a database)

    Defines the schema Create attributes

    Define data types Define primary/foreign keys

    Define validation rules HLL/4GL

    Data manipulation language (DML)

    high level language/4GL part of DBMS

    To access/query data To store data

    To update data

    http://www.revision-notes.co.cc/