Professional Documents
Culture Documents
Highest priority interrupt is serviced first to avoid data loss/hardware damage The previous process may resume when all higher priority processes have finished (fetch data from the stack)
Process A
Sorting rules/algorithms include o Round Robin (RR): each job in the READY queue is allocated an equal time slice, allowing all jobs to gain processor time. If a job completes during its time slice, it will leave the system First Come First Served (FCFS): the first job runs until completion, then allowing the next job to run until completion... and so on. If a long job gets onto the processor, it will not leave until completed Shortest Job First (SJF): the OS places each job depending on the time expected to complete into the READY queue Shortest Remaining Time (SRT): sorts the jobs in the READY queue into shortest time remaining to complete. Long/large jobs may never run as they never get to the top of the queue Multi-level Feedback Queue (MFQ): uses many levels of priority. The job with the highest priority is allowed to run once, before being sent back to the READY queue with a new priority If the new priority is still the highest, it will run again If the new priority is lower than another job, that job will run When a job has the lowest priority, Round Robin is applied
Page 2
o o
A scheduler decides when a job may enter and must leave the processor o A pre-emptive scheme allows the Low Level Scheduler to remove a job from the running state so another job may be serviced A non-pre-emptive scheme will allow a job to continue running until it no longer needs the processor Useful in a small system where there are few jobs Not useful where there are many jobs, as there is a danger of a job monopolising the processor waiting on an input/output
High Level Scheduler (HLS): Places a job into the READY queue, whilst ensuring the system is not overloaded Medium Level Scheduler (MLS): Swaps jobs from the IAS onto the backing store and visa versa (see paging) Low Level Scheduler (LLS): Places and removes jobs in/from the running state. It places the job back in the READY queue in the correct position
A pre-emptive system
Page 3
Processor bound jobs are jobs that use the processor a lot, e.g o o Manipulating large images Calculating huge numbers
One way of holding jobs and data in main memory, is to split them into equal sized wordspaces called pages o o o o Splitting a (large) program into pages Only part of program needs to be in memory Some of program can stay on disk (virtual memory) Allows program to run when there is insufficient memory
Page 4
This system is subject to disk threshing, which will slow the entire system down and possibly cause failure or data loss o o o o Occurs when moving pages between memory & disk Disk is relatively slow High rate of disk access More time spent transferring pages than on processing
Direct/Absolute Addressing: a command is sent with the real address (e.g. ADD 10 means Add the data in address location 10) o The amount of memory that can be addressed is limited If using a 16-bit machine and the op-code ADD was 01101, this would leave 2048 address that could be addressed
To execute the same operation on a number of addresses, we would have to write the same instruction many times
Indirect Addressing: a command is sent with an indirect address (e.g. ADD 10 means the address 10 contains the address of the data to be used) o This allows all 16/32/64 bits to be used to address data (access more data)
Indexed Addressing: if we wanted to add together 100 items in an array, we would need 100 instructions (ADD 10, ADD 11, ADD12ADD100. o Indexed addressing includes a special register called the index register (IR) which is initially set to 0 When the first value is taken from 10, the IR becomes 0+10 For every other item, the IR is simply incremented This allows only one instruction to be executed with information it should be done 100 times
o o o
Page 5
Immediate Addressing: The real value is in the command to be executed (e.g. ADD 10 means add the value 10)
Spooling (3.1.5)
When a job needs to output to a slow peripheral, a spool will be used to make efficient use of the resources o The CPU outputs to the spool queue the address of the data needing to be output Allowing the CPU to service other jobs, whilst the output is dealt with
The spool queue normally uses First in First out ordering, however jobs can be added with different priorities When a peripheral is ready for the next job in the spool queue, it will read the address, fetch the data and begin to output Spooling allows many jobs/users to use a single output peripheral in turn
(Remember: a spool is different from a buffer, because a buffer allows only one job/user to access it at a time, and it requires the CPU to keep filling it up)
0x07
0x06
0x05
0x04
0x03
0x02
0x01
Output Peripheral
Page 6
The OS provides the user and programs with facilities to handle inputs and outputs, copy and move files, handle memory allocation and any other basic task Steps needed to boot a PC o Power-On-Self-Test (POST) routine is executed o Found in ROM Clears all registries and CPU of any left-over data Loads the first value of the boot program into the program counter
Boot program executes Stored in ROM Simplified version of the BIOS (Basic I/O System) Checks the POST routine and Boot program
The CPU now sends signals to hardware to check it is functioning properly System checks: Busses, System clock, RAM, Disk drive and Keyboard
The boot program now checks drive A (often a CD/Floppy Drive) for an OS. If there is no disk, it will check drive C (often a Hard Drive) Once found, the operating systems files are loaded
Page 7
The operating system manages the FAT table o o o o o o o Allocation of space on disk Deleting files Copying files Moving files Control file access rights Map logical file addresses to physical addresses on disk Creating shortcuts
Page 8
Low level languages (close to the language used by the computer) o Represent binary with mnemonics, such as o o ADD = 001 (a command) NUM1 = 00101 (an address)
The use of mnemonics in place of binary is called Assembly Language An Assembler translates the mnemonics (using a table) to produce machine code
High level languages (close to the language used by a human) o Because they are close the human language and far from machine code, a more complex translator is needed A Complier takes a high level language (source code) and translates it into a machine code (object code) equivalent A disadvantage of using a compiler is that it if very memory hungry o o o Source code needs to be in IAS Compiler needs to be in IAS Resultant object code is in IAS (to be copied to backing store)
Another disadvantage is that it is hard to pin-point an error in the source code A Interpreter reads the source code line by line, translating it and then executing Errors are easy to pin-point Less demanding on the system resources
Page 9
All keywords are replaced by a set of binary numbers called tokens It removes any white space and comments inserted by the programmer It will spot all names (variables/constants) it does not recognise and create a lookup table called a symbol table The symbol table contains the name, data type, memory location and any restrictions for the variable/constant
Syntax analysis o This parse checks the tokens generated by the lexical analyser to see if it is grammatically correct This is done by using Backus-Naur Form rules (see 3.7.2) If a token breaks a grammatical rule, it can output an error for that line of code
o o
Code generation o The compiler now takes the valid strings of tokens and changes them into lowlevel/intermediate code This process is One-to-Many as there are many low-level instructions needed to represent a single instruction in high-level Resulting in a larger resultant file than the original high-level file
Code optimisation o Simply removes the unnecessary code such as (A := A +0) to result in more efficient (faster) code
Page 10
The routines are loaded into memory when a utility program called a loader needs them and they are linked to the relevant places in the existing code by a utility routine called a linker
IAS
Loader
HDD
Linker
Page 11
Address Bus
Data Bus
PC > MAR > IAS > MDR > CIR > Accumulator
The control unit fetches instructions from memory, decodes and synchronises all operations The ALU is where data is processed both arithmetically and logically o o Arithmetical processing involves mathematical operations (add, sub) Logical processing involves logical operations (AND, OR, XOR)
Page 12
o o
When the instruction is needed, the content of the PC is copied to the MAR Causing the MDR to fetch the instruction from the IAS at the address specified by the MAR The content of the MDR is then placed in the CIR, ready to be executed
Decoding o The instruction is now split into two parts o o o The operation code The address of the data to be used Op code 0101 ADD Address 100110101001 #9A9
The address is then placed in the MAR Causing the MDR to fetch the data The operation is now decoded by referring to a table This table defines the binary for all operational codes (RISC & CISC) Refined Instruction Set Computer (RISC): is not able to recognise a lot of mnemonics, but greatly decreases process time as it is not spending as much time looking up a table o Some instructions will require a combination of simpler instructions to run
Complex Instruction Set Computer (CISC): can recognise any mnemonic which can make processing faster if there are a great range of different mnemonics being used
Page 13
Allow more complex calculations/processing to be given to a dedicated coprocessor which only processes these similar calculations Such as a GPU (graphical processing unit) Advantage of allowing the CPU to complete other instructions
Page 14
Disadvantages A more complex program must be developed, compared to the traditional sequential program, to allow execution of different parts at the same time
CPU A
CPU B
CPU C
IAS
Page 15
Pipelining o Uses the standard fetch-decode-execute cycle o An instruction can be in any one of these 3 stages
Pipelining allows the system resources to be used more effectively by making sure there is an instruction at each stage of the cycle:
If a JUMP instruction appears, the pipe is broken and a new instruction must be added
Page 16
Uses normal binary numbering with additional fractional numbers (4, 2, 1, 0.5, 0.25, 0.125) The greater the size of the mantissa, the larger the number you can represent The greater the size of the exponent, the greater degree of accuracy you can achieve
Denary: Binary:
Mantissa 01001
Exponent 010
Normalisation (3.4.2)
A number must be normalised before it can be stored as a floating point binary number o This means there should be only one leading 0 on the mantissa (unless its a negative number, where it leads with 1 followed by a 0) The exponent is found by moving the decimal place to normalise the mantissa
Page 17
Disadvantages: The programmer must estimate the amount of memory needed to store the structure It can waste a lot of memory
Dynamic data structures o o May change during execution (e.g. a linked list) Advantages: o Only uses the memory needed at any time Makes efficient use of memory
Disadvantages: Difficult to program Can be slow to implement searches Only allows serial access
Page 18
To pop (delete) data, the pointer is decremented. This allows new data to overwrite the current data
A Queue is a (FIFO) data structure o To insert data into a queue, it must first be checked it is not full If it is not full, the head pointer in incremented and data inserted at this location If it is full, the data may not be inserted
Before deleting, the queue must first be checked it is not empty If it is empty, the head pointer = the tail pointer If it is not empty, the data at the tail pointer is copied and the tail pointer is incremented
A Tree is a structure where each data item points to two other items depending on a rule
David
Barbra
Ed
Page 19
Report Error (Item not in list) Using this method on a large list, greatly increases search time However, the time taken to search a small list is increased compared to a serial search
Serial searching o o Simply compares each item in the array/file with a known value This is useful in a small file/array
To merge, we compare each item. The item with the least value is inserted to the new list first: 12 24 10 54 24 56 32 34
Page 20
Quick sort also sorts files, but if very efficient at sorting large files o o 2 pointers are used: a left pointer and a right pointer The left and right item values are compared, if the right item is less than the left, they swap o Move the left pointer +1 and repeat first step
If the left item value is less than the right item value, the right pointer moves -1 and repeats step 1
Page 21
The computer now backtracks to find any other instances returning any other true instances (e.g. Baz) Once all instances of DOG(x) have been found (true and false) the goal has been satisfied
Data Encapsulation is the concept that data/variables can only be accessed via the methods provided Inheritance is another concept that allows the re-use of variables and methods of a super class of which a new class is derived
Page 22
Super Class
Methods
Derived Classes
To plan and explain OOP structures, a method called Unified Modelling Language is used o o Use case diagrams show how users are related by a process State diagrams show how an object may behave through the various processes of a system (cross between a DFD and a flow diagram) Sequence diagrams show how the objects in the classes interact with one another Activity diagrams are like flow charts, but with the difference of showing the steps needed to get the object into a particular state
o o
Page 23
Page 24
Polish notation (Prefix) puts the operand at the start of an expression (e.g. + A B) This is unambiguous as there is no longer a need for brackets
Reverse Polish notation (Postfix) puts the operand at the end of the expression This too is unambiguous, but also allows the result to be worked out using techniques with stacks 2 * (A + B) in reverse polish is A B + 2 *
Page 25
Databases (3.8)
Design and Normalisation (3.8.1)
A database is a series of related tables o When files are part of a database they are called tracks
A table is a collection of sets of similar data called records o o An Attribute is a column containing a single item concerning multiple entities A Tuple is a row containing multiple items concerning a single entity Attribute A Tuple 1 Tuple 2 Tuple 3 Item 1A Item 2A Item 3A Attribute B Item 1B Item 2B Item 3B Attribute C Item 1C Item 2C Item 3C Attribute D Item 1D Item 2D Item 3D
An Attribute that holds an item that is unique from every other entity is called a primary key A table can be linked together to relate the data o A foreign key maintains the relationship between two tables
If all the data is held in one large table with data redundancy, then it is in UnNormalised Form (UNF) Data in the database can be arranged in 3 different ways o o o First Normal Form (1NF): all repeated data items are removed (data redundancy) Second Normal Form (2NF): ensures all data items are dependent on a primary key Third Normal Form (3NF): removes part key dependencies (an attribute that takes a certain value because of another attributes value)
Data Redundancy is the repeating the same data item for multiple tuples Data Integrity is the likeliness of a data item being correct (more likely if there is no data redundancy)
Page 26
User
Film
The following shows the database in 3NF with a new link table (Ticket) o A link table normally consists of the key attributes of the tables on both sides User Ticket Film
to ensure the rules of the database are not broken A DBMS includes software called Data Description Language (DLL) which defines o o o o Tables in the database Data types in the table Constrains on the data The structure within the database
The data dictionary is a file of descriptions, structure and storage of the data A database design is called a Schema o Each user is given a subschema which defines the rules about how they may access the data
Page 27
Operation
Table name
Column name
Value name
To insert a row in SQL o INSERT INTO Users VALUES (7BC, Mr Campbell, 21)
Operation
Table name
Values
Operation
All columns
Table name
Column name
Page 28
Index
The Function of Operating Systems (3.1) ............................................................................................... 1 Features of an Operating System (3.1.1) ............................................................................................ 1 Interrupt Handling (3.1.2) ................................................................................................................... 1 Scheduling, Job Queues & Priorities (3.1.3) ........................................................................................ 1 Memory Management (3.1.4)............................................................................................................. 4 Spooling (3.1.5) ................................................................................................................................... 6 Modern PC Operating System (3.1.6) ................................................................................................. 6 The Function and Purpose of Translators (3.2)....................................................................................... 9 Types of Translators & their Purposes (3.2.1) .................................................................................... 9 Lexical & Syntax Analysis, Code Generation & Optimisation (3.2.2) ................................................ 10 Library Routines (3.2.3) ..................................................................................................................... 11 Computer Architectures (3.3) ............................................................................................................... 12 Von Neumann Architecture (3.3.1)................................................................................................... 12 Registers & Fetch-execute Cycle (3.3.2) ........................................................................................... 12 Other Architectures (3.3.3) ............................................................................................................... 14 Data Representation (3.4)..................................................................................................................... 17 Floating Point Binary (3.4.1) ............................................................................................................. 17 Normalisation (3.4.2) ........................................................................................................................ 17 Data Structures and Data Manipulation (3.5) ....................................................................................... 18 Implementation of Data Structures (3.5.1)....................................................................................... 18 Searching, Merging & Sorting (3.5.2) ................................................................................................ 19 High-level Language Programming Paradigms (3.6) ............................................................................. 22 Declarative Programing (3.6.1) ......................................................................................................... 22 Object-orientated Programming (3.6.2) ........................................................................................... 22 Programming Techniques (3.7) ............................................................................................................. 24 Page 29
Page 30