Revision - exceptions, virtual memory, cache etc Flashcards

1
Q

two types of exceptions

A

internal - traps
external - interrupts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is an exception

A

an event that disrupts the normal program flow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

high level exception mechanism

A
  1. save address of current register
  2. transfer control to the OS at a known address
  3. handle the exception
  4. return to program execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how is the address of the current register saved (exception mechanism)

A

use the EPC (exception program counter)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how is the exception handled (exception mechanism)

A

the exception handler is found
cause is dealt with

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how is the program returned to program execution (exception mechanism)

A

restore user program registers
jump back using the EPC
this relies on eret

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

two approaches to finding the exception handler

A
  1. cause register
  2. vectored interrupt
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

cause register

A

jump to predefined address
use the cause register to branch to the right handler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

vectored interrupt

A

jump directly to the specific handler depending on the exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how is an exception dealt with (if restartable)

A
  1. determine the action needed
    - inspect the cause register or opcode
  2. take corrective action
  3. use the EPC (exception program counter) to return
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

how is an exception dealt with (if not restartable)

A
  1. determine the action needed
    - inspect the cause register or defined opcode
  2. terminate the program using the EPC (exception program counter)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what should happen to other interrupts whilst the exception is being dealt with (and how)

A

other interrupts should not occur
interrupts are masked by setting the EXL (exception level) in the status register

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

4 advantages of dual mode

A
  1. user programs do not have indefinite control
  2. ensures programs do not have access to resources which they do not have permission for
  3. ensures programs do not interfere with each other
  4. control is transferred to OS when user programs perform dangerous tasks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

why are system resources protected

A

to provide safe and orderly access to resources (such as hardware and memory)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is kernel mode

A

a mode where the OS takes control
it can only be accessed through exceptions
(the kernel is the nucleus of the OS)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

differences between kernel and user mode

A

some instructions (such as accessing I/O devices and handling TLB misses) are only accessible in kernel mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

how is the current mode identified

A

a bit in special status register

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

how do you set the mode back to the previous mode

A

use eret

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

problems that CPU time sharing solves

A
  • I/O takes too long - leaves the processor idle
  • user programs can crash or use all of the CPU
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How does CPU time sharing work

A

switch from one process to another when it performs I/O or when time allocation expires

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

what is the kernel

A

the core of the CPU that controls software and hardware resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

three active states

A

ready
running
blocked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

five steps of process managing

A
  1. exception occurs
  2. process calls OS
  3. process info saved in PCB
  4. new process runs
  5. process states updated

(1. process calls the OS when interrupt / trap occurs
2. OS dispatcher performs a context switch
3. process info is saved in the Process Control Block (PCB)
4. Dispatcher chooses new process to run
5. process states are updated)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Two inactive states

A

suspended ready
suspended block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
how does suspending and resuming processes occur
processes are moved from memory to disk. the PCB (process control block) of inactive processes are kept in the OS inactive processes may be resumed by returning data from disk to memory
26
what are 4 things contained in the PCB (process control block)
process id process state process priority process permission
27
what is temporal locality
the tendency to reuse recently accessed data items
28
what is spatial locality
the tendency to reference data items that are close to other recently accesses items
29
how do memory hierarchies take advantage of temporal locality
by keeping more recently assessed data items closer to the processor
30
how do memory hierarchies take advantage of spatial locality
by moving blocks consisting of multiple continuous words in memory to upper levels of the hierarchy
31
how can the miss rate be lowered
by making larger blocks (which exploit spatial locality
32
principle of locality
a program accesses a relatively small portion of its addresses at any instant of time
33
block / line
minimum unit of information that can be present in the cache
34
hit rate
fraction of memory accesses in a particular level of memory hierarchy that are a hit
35
miss rate
fraction of memory accesses in a particular level of memory hierarchy that are a miss
36
miss rate
fraction of memory accesses in a particular level of memory hierarchy that are a missm
37
miss penalty
time used to fetch a block from lower hierarchy. this time includes the access of the block , copying and writing it to a new location
38
memory hierarchy (from least to greatest)
disk / ssd, main memory, cache, registers
39
fully associative cache
a block can be placed anywhere in the cache
40
fully associative cache replacement techniques
LRU - least recently used FIFO - first in, first out
41
direct mapped cache
each memory location is mapped to exactly one location in the cache
42
valid bit
field in a table of memory that indicates whether the associated block in hierarchy contains valid data
43
tag
field in a table of memory that contains the info required to identify the block in hierarchy that corresponds to the main memory block that it holds
44
write to cache (hit - write through)
write to both cache and memory (slow but memory and cache are always synchronised)
45
write to cache (hit - write back)
write to cache only memory is replaced when the dirty cache block is replaced
46
when is the dirty bit set
if a block has been written to
47
write to cache (write allocate - miss)
bring the block into the cache and modify in cache only
48
write to cache (write - no allocate - miss)
modify block in the memory only
49
two issues that virtual memory addresses
capacity safety
50
physical address space
main memory
51
name for cache line or block in virtual memory (virtual memory)
page or virtual page
52
name for cache line or block in virtual memory (physical memory)
page frame or physical page
53
when does a page fault occur
when the valid address is not in memory
54
what are the page table permission bits for
control whether a process can - access a page - modification (read + write / read only / execute only) - enables memory protection
55
what can change page tables
operating system
56
where is the page table located
in the system portion of the main memory
57
what is used as a cache for VM
physical memory is used as a cache for virtual memory
58
what problem does TLB (translation look-aside buffer)
as page tables are stored in the main memory, every memory access requires one access to obtain the physical address and second one to get the data hence large latency
59
permission bits of TLB
– V (valid) bit indicates a valid entry – D (dirty) bit indicates whether page has been modified
60
what is the TLB
a small, fully-associative cache of page table entries
61
how is the TLB accessed
– Accessed with Virtual Page Number (VPN)
62
how is the physical address formed by the TLB
– Each entry stores the translation (PPN) for a given VPN – Physical address formed from PPN and Page Offset
63
What is accessed on a TLB miss
– Page table accessed on a TLB miss
64
three advantages of having a ISA
- hides hardware details from the programmer - enables multiple microarchitectures of the same ISA - defines the set of allowed instructions
65
what happens after a cache miss
a cache block containing the requested word is copied from memory to cache (hence both the cache and memory have the block)
66
name three things involved in MIPS processor exception handling mechanism
vectored interrupt interrupt mask cause register
67
name two features of twos complement representation
add / subtract operations do not depend on the sign of the operands sign extension is trivial to perform (right shift - logical or arithmetic)
68
the operating system protects the following systems resources
the processors TLB
69
what limits performance of a mulitcycle processor
number of cycles needed to complete an instruction clock frequency of the processor propagation delay incurred in each cycle
70
name four things that will trigger an MIPS exception
TLB miss disk I/O completion syscall instruction user clicking a mouse
71
what is required to build a ripple adder carry
requires and, or and not or nand
72
what is required to be maintained in a page table
bit indicating if 1. the page has been recently accessed 2. the page had been modified after it was loaded to memory 3. the page is resident in memory
73
name three triggers for context switching
multi-tasking interrupt handling user and kernel mode switching
74
what is context switching
storing the context or state of a process so that it can be reloaded when required and execution can be resumed from the same point as earlier
75
4gb
2^32
76
1KB
2^10
77
2gb
2^31
78
1gb
2^30