Computer Science Flashcards
What does the address bus do?
Carries a memory address of an instruction in the main memory to be read and carried back to the CPU
What does the control bus do?
Directs and monitors components in the computer by sends signals from the CPU such as read/ write signals to the RAM.
What does the ALU do?
Arithmetic operations, logical comparisons, boolean logic and logical shifts. Include examples of each
How is an instruction split up?
Opcode: what needs to be done (add)
Operand: what it is being done to (data)
What happens in fetch part of the cycle
Next instruction copied from PC to MAR
CU loads it onto the address bus and sends a read signal through the control bus
Instruction sent from RAM to MDR by data bus
Copied to CIR
PC incremented by 1
What happens in the decode part of the cycle?
CU checks that the instruction is recognised, reads it and prepares the CPU for execute
What happens in the execute part of the cycle?
Uses the ALU to manipulate data and might store in the accumulator
May write to RAM, load more data from RAM etc
What does the clock do?
Constantly ticks by varying power to the CPU to synchronise actions in the CPU. Higher clock speed means more instructions per second
What does multicore mean?
Multiple processing units on a single Cpu chip that can process instructions separately at the same time.
What is pipelining?
When cores are assigned fetch, decode and execute. Each instruction is passed through each core for each stage of the FDE cycle
What is the difference between SRAM and DRAM?
Static RAM is more expensive and faster found in cache
Dynamic RAM is used in main memory and needs a constant refresh signal to keep capacitors charged
What characterises a Von Neumann computer?
Data and software stored together sharing bus
CU, ALU, registers
Way to input and output information
What characterises harvard architecture?
Separate memory for data and instructions
Data and instructions can be fetched at the same time with separate busses
More physical space needed
More expensive
Harder to handle two blocks of RAM
CISC vs RISC
Larger vs smaller instruction set More vs fewer transistors required More vs less heat More vs less like 1 to 1 with machine code Many vs one cycle per instruction Worse vs better for pipelining
What causes the CPU to flush the pipe?
When the CPU doesn’t precict a branch in code, the pipe is flushed to process the new instruction
What is SIMD processing?
Single instruction multiple data.
When data is arranged into an array or matrix and multiple ALUs perform the same or similar tasks on each of them. Cannot be done on sequential programs.
What is MIMD?
Multiple instruction multiple data.
A job scheduler assigns each processing core part of a task to do. It isn’t always possible to split every problem into as many parts as there are cores.
Storage device vs storage media
Storage device:
Writes data (DVD writer)
Storage media:
Stores data (DVD)
Attributes of magnetic storage:
Magnetic particles store data and read/write heads float over spinning platters. High capacity, low cost per gb, random access, good longevity.
Not that portable, moving parts, slow, loss of data in strong magnetic fields
Attributes of optical storage:
Laser burns puts into a disc and another laser reads it.
reflected/ scattered light represents 1s and 0s.
Cheap, good capacity for intended use, portable. Expensive for high capacity, slow read/ write easily scratched, no random access, cannot write over data.
Attributes of flash storage:
Electronic switches hold electric charge. Fast, high capacity, portable and durable, silent. Expensive, wears out after lots of use.
What is virtual storage?
When many storage devices are put together and a virtual storage controller makes them appear as one location. Used for high capacity requirements.
Purpose of an OS
Scheduling
Manages memory- loads programs, reuses memory and creates VRAM
Manages peripherals- handles I/O reqs, drivers
Utility programs
Security- logins, access to other user’s files
Provides a UI
What does the kernel do?
Loads/unloads programs from RAM Scheduling tasks for the CPU Memory management Handles files in/ out of secondary storage Data security File management
What are device drivers
system software that allows devices to interact with the OS. Separate driver per component. Different driver for each OS.
Utility program examples
File manager Antivirus Disk defragmentation Encryption software File compression Installers Clipboard manager System monitor
What are segments and why are they used?
Segments store each process in the CPU so they don’t write over each other. They don’t have the same size and are not next to each other.
How are segments split up?
Stack segment: stores addresses of instructions being interrupted by subroutines
Free memory: memory that is left free to allow the segment to expand
Data segment: space for variables to be stored
Code segment: stores all the instructions of a process
How does pagination work?
When VRAM is in use, memory is split up into FIXED UNITS next to each other.
The memory manager numbers them and records them in a page table.
When something needs to be fetched, the least used page is moved into VRAM and if its part of a segment, the pages holding the rest of the segment are moved too.
Free space is renumbered and marked as free.
What is a memory leak?
When poorly written programs don’t clear data from memory and or mark it as free
What is polling?
An alternative to interrupts, the CPU regularly checks if events/ peripherals need attention
What happens with an interrupt?
If the interrupt is of higher priority, the CPU runs the interrupt service routine after copying existing values in the registers to the stack.
What is a multitasking OS?
Allows many applications to run concurrently. Good for general purpose machines
What is a multi-user OS?
Allows many workstations to access a single powerful computer through a network. The OS keeps users secure from each other and shares CPU time. Example: self checkout machines.
What is a real-time OS?
Handles inputs within a guarenteed time. Reliable and consistent timings. Used in production lines, hospitals etc.
What is an embedded OS?
Designed for the specific function of the embedded system
What is a batch OS?
Does the same job for many inputs, different program for input, process and output. No user interaction necessary after setup.
What happens when a computer powers on?
Power supply stablilises
PSU tells CPU to execute hardware reset instruction in BIOS
Instruction jumps to start up program
POSTs
Checks for storage, GPUs and the OS
Finds the boot loader, holding the OS which runs the boot file
What is bytecode?
Code translated from source code before being interpreted into machine code by a VM. Allows programs to run on any PC.
What are applications?
Programs that don’t run in the background and provide a UI.
What is the difference between custom and bespoke software?
Custom software is when software is altered to fit the client’s needs whereas bespoke software is built from scratch, possible requiring experts from the client’s company to help develop it.
What happens in lexical analysis?
Identifies lexemes stored in the lexicon
Finds identifiers and adds them to the lexicon
White space and comments are removed
Lexemes are converted to binary tokens and are stored in the token table.
What happens in syntactical analysis?
Syntax analysis makes sure code follows the grammar rules of the language.
Semantic analysis makes sure that all declarations are semantically correct ie a string isn’t declared as an integer.
Mistakes are summarised in the compiler report
What happens in code generation?
Converts tokens into machine code stored in an object file, allocated memory addresses, records relative addresses of where code might jump to.
Optimisation: removes redundant code to maximise time/ memory efficiency
What are modules?
Different parts of a program that can be worked on by seperate programmers and are made into seperate object files.
what do static and dynamic linkers do?
Makes an executable file from object files and libraries (that may not be installed on the user’s machine). Static linkers create a new file with everything in it; dynamic linkers references external files so the loader retrieves it in runtime.
What do loaders do?
Make segments in memory and loads the program into them.
How to convert a positive to negative and a negative to positive in two’s compliment?
Pos to neg: flip bits and add 1
Neg to pos: minus 1 and flip bits
How do you do a signed right shift?
Numbers move right of the decimal point.
If the MSB is a 0, pad with 0s, if it’s a 1, pad with 1s
What is thinking ahead?
Identifying inputs and outputs
Deciding on data types
Researching information prior
Thinking about how to make program efficient before writing