Chapter 6 - Mechanism: Limited Direct Execution Flashcards

1
Q

what is direct execution

A

OS runs your program directly on the CPU without emulation or interpretation

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

why is direct execution fast

A

almost nothing between program and CPU

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

why is it called limited direct execution

A

programs run directly on the cpu, but OS limits what they can do for safety and fairness

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

What is time sharing?

A

The OS switches between programs so they share CPU fairly and efficiently.

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

What are the goals of limited direct execution?

A

Fast execution, security, and hardware sharing

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

What is user mode vs. kernel mode?

A
  • User mode: Limited privileges (can’t access hardware or OS memory)
  • Kernel mode: Full access to system resources
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why do we need two CPU modes?

A

To prevent user programs from performing dangerous or privileged operations

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

How does a user program perform a privileged action?

A

triggers a trap, switching to kernel mode to run OS code - save all neccessary info on the kernel stack

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

what is a trap table

A

A table that tells the CPU what code to run for each kind of trap

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

How can the OS regain control of the CPU from a running process?

A

Cooperative approach + Non-Cooperative approach

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

cooperative approach

A

Process gives up control voluntarily (by a system call or crashing)

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

non-cooperative approach

A

The OS uses a timer interrupt

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

what is a timer interrupt

A

pauses the running program and gives control to the OS

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

What is a context switch?

A

The process of saving one process’s state and loading another’s

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

what happens during context switch

A

save current process registers and program counter - load next prosess saved state - resume with return-from-trap

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

What’s the difference between hardware and software state saving?

A
  • Timer interrupt: Saves user registers (hardware), stored in kernel stack
  • Context switch: Saves kernel registers (software), stored in process structure
17
Q

What is the role of the scheduler?

A

It decides which process should run next after a trap or interrupt

18
Q

Define; trap, system call, return-from-trap

A
  • trap: CPU switches to kernel mode due to an event
  • system call: a request from a user program for a privileged operation
  • return-from-trap: instructions that resumes a user process and switches back to user mode
19
Q

concurrency

A

when multiple things happen at the same time

20
Q

What is a downside of disabling interrupts for too long?

A

The system might miss important events like keyboard inputs or network packets

21
Q

Why does the OS use locks?

A

To prevent multiple parts of the kernel from accessing shared data at the same time

22
Q

What is careful interrupt nesting?

A

Allowing high-priority interrupts while blocking lower-priority ones — used for safety and responsiveness