10. Processor Exceptions Flashcards

1
Q

What is the difference between interrupts and traps?

A

Interrupts are external (not caused by program execution), such as a keyboard interrupt.

Traps are internal (caused by program execution), such as syscall or a TLB miss.

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

What is the OS?

A

The system software that manages resources.

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

What is the kernel?

A

The ‘nucleus’ of the OS. It’s first to be loaded on booting up, and manages interrupts, fork processes, schedules processes and manages memory.

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

How is syscall() used in MIPS?

A

$v0 is set to the special value denoting the particular syscall exception and $a0 is set to the argument of the call.

Control is then passed to the exception handler.

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

What is the exception mechanism?

A
  1. Save the address of current instruction into the EPC (exception program counter)
  2. Transfer control to the OS at a known address.
  3. Handle the exception (all registers are preserved by the callee)
  4. Return to program execution (uses the ‘eret’ instruction to restore user program’s registers and jumps back via EPC)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the two approaches to finding the exception handler?

A
  1. Jump to a predefined address, and use the ‘cause’ register to branch to the right handler.
  2. Directly jump to a specific handler depending on the exception (vectored interrupt)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the options for the exception?

A

Take corrective action and use EPC to return.
OR
Terminate program and report error using EPC and cause.

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

How are further interrupts prevented during an interrupt?

A

Interrupts are masked by setting the exception level (EXL) in the status register.

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

Why do we use syscall, eret … instead of j, jr…?

A

The OS needs to guarantee safe and orderly access to critical system resources.

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

What is kernel mode?

A

Kernel mode is where privileged instructions have to be executed (i.e. accessing I/O devices, handling TLB updates, changing voltage of processor.)

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

How can kernel mode be entered/exited?

A

Entered through an exception, and left via ‘eret’. It is indicated by a bit in the process status register.

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

What are the benefits of dual-mode architecture?

A

Guarantees that control is transferred to the OS when the user is performing dangerous tasks.

Allows OS to ensure programs don’t interfere with each other.

Allows OS to ensure programs don’t have access to resources for which they don’t have permission.

Ensures that user programs do not have indefinite control of the processor.

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

How do we avoid one program taking up the processor or stalling the processor?

A

We time-share the CPU by switching from one process to another when it performs I/O or when its time slice expires.

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

Give the stages involved in switching to a new process.

A

The process calls the OS or a time-interrupt occurs.

The OS’ dispatcher performs a context switch:
- context is saved (registers, etc.) in PCB (process control block)
- Dispatcher chooses new process to run
- Processes’ states are updated

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

How do we solve the issue of not having enough physical memory for all processes?

A

Processes can be swapped out from memory to disk, and placed in an inactive state.

PCB of inactive processes are still kept in OS memory.
Inactive processes are resumed by swapping in the data from disk back to memory.

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