CPUs Microcode Protection and Protection Modes Flashcards

1
Q

When CPU runs in Kernel mode, it can:-

  • run any ___
  • modify any ___ in ___
  • access and modify any ___ in CPU and devices
  • full control of the computer
A

instruction; location, memory; register

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

The OS services runs in ___ mode.

Kernel/User

A

Kernel

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

When CPU runs in User mode, it can:-

  • use a limited set of ___
  • modify only sections of ___ assigned to the process running the program
  • access only ___, and cannot access ___ in ___
  • limited access to the resources of the computer
A

instructions;
memory;
a subset of registers in CPU, registers, devices

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

The user programs run in ___ mode.

Kernel/User

A

User

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

Kernel/User Mode:

1. When the OS boots, it starts in ___ mode.

A

kernel

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

Kernel/User Mode:

2. In ___ mode, the OS sets up the ___ and ___ all the devices.

A

kernel, interrupt vector, initializes

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

Kernel/User Mode:

3. Then it starts the first process and switches to ___ mode.

A

user

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

Kernel/User Mode:

4. In ___ mode, the OS runs all the ___.

A

user, background system processes (daemons)

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

Kernel/User Mode:

5. Then it runs the ___ or ___.

A

user shell, windows manager

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

Kernel/User Mode:

6. While running in ___ mode, the program switches to ___ mode to request OS services (___).

A

user, kernel, system calls

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

Kernel/User Mode:

7. User programs also switch to ___ mode when ___ arrives.

A

kernel, interrupt

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

The interrupts are executed in kernel mode.

True/False

A

True

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

The interrupt vector can be modified in both kernel and user mode.
True/False

A

False. Only in kernel mode

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

Most of the CPU time is spent in __ mode.

A

User

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

Separation of user/kernel mode is for:-
___ (make sure user have enough privileges to run the call)
___ (Killing bugs and crashing)
___ (OS calling in kernel mode for fair access)

A

Security; Robustness; Fairness

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

If a process that tries to write to an invalid memory location, the OS will ___ the program, but the OS ___.

A

kill, continue to run

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

Which of the following is false?
A. A crash in the process will not crash the OS
B. A bug in user mode causes program to crash, OS will also crash
C. A bug in kernel mode may cause OS and system to crash

A

B.

A bug in user mode causes program to crash, but OS will still run.

18
Q

An interrupt is an event that requires ___.

Little/moderate/immediate attention

A

immediate attention

19
Q

In hardware, a device sets the interrupt line to ___.

low/medium/high

A

high

20
Q

When an interrupt is received, the CPU will stop whatever it is doing and jump to the ___ that handles that specific interrupt.

A

Interrupt handler

21
Q

After executing the handler, the CPU ___ and the program continues.

A

return to the same place where the interrupt happened

22
Q

Arrange the steps of servicing an interrupt.

  1. CPU jumps to interrupt handler and run it
  2. CPU restores the registers and return back to the place in the program that was interrupted. The program continues execution as if nothing happened
  3. CPU saves the program counter and registers in execution stack
  4. CPU looks up the corresponding interrupt handler in the interrupt vector
A

3, 4, 1, 2

23
Q

Interrupts allow CPU and devices to run in parallel without waiting for each other.
True/False

A

True

24
Q

Which of the following about poling is false?
A. Poling is also called “busy waiting”.
B. During poling, OS decides not to use interrupts for some devices and wait in a busy loop until completion.
C. Poling is used to print debug messages in the kernel.
D. Poling saves CPU cycles.

A

D.

Poling wastes a lot of CPU cycles.

25
Q

Poling is called ___ processing since the execution of the device is ___ with the program.

A

synchronous, synchronous

26
Q

An interrupt is also called ___ processing because the execution of the device is not ____ with the execution of the program.

A

asynchronous, synchronized

27
Q

___ is an array of pointers that point to the different interrupt handlers of the different types of interrupts.

A

Interrupt vector

28
Q

Interrupts run in kernel mode. Why?

A

An interrupt handler must read device/CPU registers and execute instructions only available in kernel mode.

29
Q

Interrupt vector can be modified only in kernel mode.

True/False

A

True

30
Q

Interrupt vector is initialized when drivers added to the system.
True/False

A

False.

Interrupt vector is initialized on bootup, and modified when drivers are added to the system.

31
Q

Types of interrupts:-

____ is generated by devices when a request is complete or an event that requires CPU attention happens.

A

Devices interrupts

32
Q

Types of interrupts:-

___ generated by the CPU when there is a math error.

A

Math exceptions

33
Q

Types of interrupts:-

___ generated by the MMU (___) that converts virtual memory addresses to physical memory addresses.

A

Page faults; Memory Management Units

34
Q

Types of interrupts:-

___ generated by software with a special assembly instruction.

A

Software interrupt

35
Q

Match the reasons to their description for the MMU interrupt:-
___ : interrupt prompts a SEGV signal to the process.
___ : Access to a valid address but there is not page in memory. This causes the CPU to load the page from disk.
___ : (trying to write on a read only page) causes a SEGV signal to the process.

A

Invalid address;
Page not resident;
Invalid permission

36
Q

System calls use ___.

A

software interrupts

37
Q

Why do we use software interrupts for syscalls instead of function calls?

  • Software interrupts will switch into ___ mode.
  • OS services need to run in ____ mode because they need ___, accessing devices and ____, they need to enforce ___.
A

kernel; kernel; privileged instructions; kernel data structures; security in kernel mode

38
Q

Only operations that need to be executed by the OS in kernel mode are part of the system calls.
True/False

A

True

39
Q

Libc calls system calls directly.

True/False

A

False.

Libc provices wrappers for the system calls that eventually generate the system calls.

40
Q

Which of the following about system calls is false?
A. The software interrupt handler for system calls has entries for all system calls.
B. The handler checks that the arguments are valid and that the operation can be executed.
C. The arguments of the syscall are not checked for quicker operations.

A

C.

The arguments of the syscall are checked to enforce the security and protections.

41
Q

When an error in a system call occurs, the OS sets a global variable called ___ defined in libc.so with the ___ of the error that gives the reason for failure.

A

errno; number

42
Q

Arrange the sequence of system calls and interrupt handler:-

  1. The OS in the interrupt handler checks the arguments. It verifies that fd is a file descriptor for a file opened in write mode, and [buff, buff+n] is a valid memory range. If any of the checks fail, write return -1 and sets errno to the error value.
  2. The interrupt handler puts the process calling write into ready state.
  3. The OS puts the current process in wait state until the disk operation is complete. The OS switches to another process.
  4. The User program calls the write(fd, buff, n) system call to write to disk.
  5. The Disk completes the write operation and generates an interrupt.
  6. The OS tells the hard drive to write the buffer in [buff, buff+n] to disk to the file specified by fd.
  7. The write wrapper in libc generates a software interrupt for the system call.
A

4, 7, 1, 6, 3, 5, 2