Stored Program Concept
Instructions and data stored in the memory of the computer
Instructions retrieved from memory, executed in sequence
By processor that carries out logical + arithmetic operations from instructions
The Von Neumann Architecture
Main memory and central processing unit connected by buses
Data and instructions are stored in the same memory
Instructions can be treated as data and data can be treated as instructions
RAM
Stores data and instructions relating to running programs
Volatile
Directly accessible by CPU
Numeric address for each memory location
CPU
Control Unit
Synchronizes components of the CPU, managing flow of data between these components and memory
Arithmetic Logic Unit
Performs logical and arithmetical operations on data
Registers
Small, fast memory units storing values CPU is working on, some specialized some generalized
Clock
Electrical pulse syncs computer components (in Hz)
Modern computers can achieve ~1 instruction per cycle using pipelining
Address bus
Carries address of data/instruction to be read/written from CPU to memory unidirectionally
Data bus
Carries data/instruction from memory to CPU (reading data/instruction)
Or from CPU to memory (data write)
Hence bidirectional
Control bus
Control information e.g.
Read/write signals
Status
Interrupt signals
Bidirectional
Fetch in FDE Cycle
Address of next instruction placed on address bus
Control Unit issues read signal to read the next instruction from memory → places this signal on the control bus
Instruction at the address in RAM is placed on the data bus
Instruction travels from RAM to the CPU along the data bus
Decode
Control unit decodes the fetched instruction so that it can be executed
Execute
Instruction is carried out
Primary memory
Directly accessible by the CPU
Stores boot (start-up) instructions (ROM) or data/instructions for running programs (RAM)
Internal (inside the computer)
Faster access
Volatile (RAM) or non-volatile (ROM)
Secondary
Not directly accessible by the CPU
Internal or external
Stores files/software relating to programs that are (generally) not currently running
Slower access
Non-volatile
HDDs and SSDs
SSDs
Secondary memory
Faster read/write times
No moving parts
More expensive than HDD
Lower capacity than HDD (e.g. 500 GB)
Less power consumption
Less heat generation
Uses flash memory (transistors) (non-volatile)
Current passed through each transistor can store charge to represent 0 or 1
Limited number of read/write cycles so they slowly wear out after you've used them for a long time.
HDDs
Secondary memory-
Magnetic coating on surface can be changed to represent 1 or 0
High capacity (e.g. 2 TB)
Concentric tracks
Slower access (higher latency) due to moving parts
Higher power consumption due to moving parts
Optical disks
Secondary memory
Uses low-powered lasers to read and write data, causing different reflections interpreted as a 0 or 1
High-powered lasers etch Pits and lands to represent 0 or 1 on a reflective surface
Single spiral track (like a vinyl record)
Low capacity compared to SSD and HDD (e.g. 5-50 GB)
Embedded Systems
Designed for one specific function
Built-in to another machine
Inputs e.g. buttons, sensors
Outputs e.g. screens, audio, actuators
Has microcontroller with CPU for processing (and own memory)
Flash memory (ROM) is non-volatile so stores data and instructions: ‘firmware’
RAM is volatile and stores temporary input data from user and sensors
Internet of Things
Physical objects equipped with sensors, processors and software that are able to connect to the internet and exchange data
Concerns with security (e.g. vulnerability to hackers taking control/intercepting)
Concerns with privacy (e.g. Extent of data collection and consent, ethical usage)
Operating System
Controls hardware of a computer system and how other programs use it
Has a UI for human user communication and use
Composed of many separate programs with different functions
Also has utility programs for management
Operating System Functions: File Management
User permissions
File management functions
Organizing files into directories, folders, subfolders
Process Management
Deciding when and which processes use the CPU through scheduling
Hence can multitasking
Make sure a process does not overwrite the memory address of another process
Peripheral management
For devices that are not part of the main computer system
OS manages communication between computer and peripheral using a device driver (small program containing instructions)
Can allocate the device a small area of memory
Can be updated to remove bugs or incorporate new types of hardware
Memory management
OS allocates a separate address space to each running process
OS protects memory so one process cannot access the memory of another
Hence several programs can run simultaneously
Virtual Memory
The address space allocated to each running process is a virtual address
OS can swap data/instructions for a running process from RAM and store it temporarily on the disk even though the process is still running
Because the OS stores a table which maps virtual to physical addresses
When a process uses their virtual address to request data, the OS looks up the physical address using that table
Since processes only see their virtual address, the physical address can be in cache, RAM or the disk
This is done when the process has not been used for some time to make room for a new process.
The process can be swapped back into RAM when it is needed.
In this way the operating system can run more programs than it would be able to if it only used RAM to store process data.
User Interface
The means by which users easily interact with the OS
Command Line Interface: Typed commands so more difficult to use but more precise control and less memory/CPU usage
Graphical User Interface: Windows, buttons etc. so easier to use but less precise control and greater memory/CPU usage
Authentication
Mechanism for users to prove their identity
e.g. Username + password, biometrics, MFA
Scheduling
How the OS decides which processes can use CPU
OS Swaps processes in and out and give each a certain amount of time (time-slicing)
Time-slicing gives the process exclusive use of the CPU
Round-robin: Queue system, fair policy
First come first serve: Reduce total waiting time
Priority scheduling: Highest priority use first
Utilities
File repair: Detect and correct errors in files (if possible).
Backup: Creates a copy of files so that they can be restored if the original file is lost or damaged
Data compression: Creates a new version of files using fewer bits than the original.
Compression saves disk space, but it takes time to compress and decompress files.
Files need to be decompressed before they can be used again.
Disk defragmentation: Over time, data on disks becomes split up into on different parts of the disk. This slows the system down. A defragmentation utility reorganizes programs so all their parts are next to each other.
Anti-malware: Detect, and quarantine or remove malware threats.
Robust Software
Handle unexpected input without crashing
Does not reveal sensitive information, even when something goes wrong.
Methods of Developing robust software
Audit trails
Keep track of all changes made and who made them
More accountability
Can roll back to working version before an error
Code reviews
Peer review
More experienced programmer checks for bad practices, security vulnerabilities, inefficient code and adherence to requirements
Time consuming, labour intensive
Automated review
Special program, cheap
May not spot some times of problems
Consequences of security vulnerabilities
Criminals exploit vulnerabilities to:
Damage or destroy data or computer systems
Gain access to sensitive information such as passwords or credit card numbers
High-level Languages
Like human language → Easier to understand
Need compilation or interpretation before execution
More portable, runs on different architectures
Have libraries for common tasks e.g. UIs, buttons
Less control as one instruction can be several machine instructions
Good for general tasks when:
Efficiency and precision less important
Standard libraries are required
Low level would be complex for e.g. UIs
Low-level languages
Assembly/machine code
No translation needed
Each instruction is a machine instruction
Runs faster, uses less memory
Always needs many lines of code
Very difficult to understand
Not portable, code written for only one architecture
Good for real-time systems when:
Need efficiency and precision
Controlling hardware, device drivers
Compilation
Translated:
In one go
Before the program runs
Once
Produces a new (.exe) file
Runs faster
Needs to be recompiled if:
Run on different OS
Program is changed → less portable
Interpretation
Translated:
Line by line
Every time it is run
While the program runs
No new file
Runs slower
Can run on different OS if have interpreter → more portable