6. Mechanism: Limited Direct Execution Flashcards

1
Q

How is performance aspect achieved in LDE mechanism?

A

By running program directly on CPU.

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

How is system call different from simple procedure call?

A

It is in fact procedure call, but inside it has a trap instruction.

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

What program needs to do to execute a system call? What happens after system call is executed?

A

It needs to execute trap instruction. After call is finished, the return-from-trap instruction is executed.

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

What does trap instruction do?

A

It raises privilege level and jumps into kernel (changes program counter to kernel-specific code). Hardware also saves program counter, flags and a few other registers onto kernel stack to save process state.

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

How does the trap know which code to run inside OS?

A

Before executing trap, a system call is placed into the CPU register. When trap is executed, hardware determines which trap handler to dispath request to based on trap type (exception, system call, etc.) with the help of trap table which kernel sets up at boot time. Then specific trap handler determines what to piece of logic to run (handled by kernel) based on the exception type or system call number

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

What else does program need to do before executing trap and doing system call?

A

The system call interfaces (such as ones in C), also place the system call number and arguments for it onto CPU registers so kernel knows what procedure exactly to run when gains control

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

How does OS gain control of system in cooperative approach?

A

When system call or illegal operation occurs. Such system often introduced yield system call which did nothing but transferred control to OS

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

How does OS gain control of system in non-cooperative approach?

A

With help of timer interrupt

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

What happens during context switch?

A

OS saves general-purpose registers, PC, and kernel stack pointer of currently running process . Then it restores the registers of another process and switches pointer to its kernel stack

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

In a scenario when timer interrupt and context switch occurs, what are the two types of registers saves that occur?

A
  1. By hardware (timer interrupt). The user registers are saved to the kernel stack, it’s a fast operation that occurs upon every interrupt or system call so the process can be resumed when return from kernel mode happens.
  2. By OS (context switch). The kernel registers are saved to PCB, this save has more overhead as it saves the full state of a process to provide isolation and a complete switch to a different process
How well did you know this?
1
Not at all
2
3
4
5
Perfectly