Lesson 2: Syscalls and interrupts Flashcards

1
Q

Privileged instructions

A

The way the OS talks with the hardware and storage. Only the OS can give these instructions and not a user.

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

Interrupts

A

The wat the hardware speaks to the OS

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

User mode

A

When the CPU is running the user’s code

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

Kernel mode

A

When the CPU is running the OS’s code

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

System calls

A

Moves from user mode to kernel mode

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

Privileged mode

A

= Kernel mode

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

How can user programs access or alter internal OS data structures or hardware?

A

Through system calls only (protection)

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

Difference between system calls and other internal OS functions

A

System calls check the validity of the parameters, whereas other internal OS functions don’t.

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

What’s the name of the process moving from the user to the kernel mode?

A

Trap

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

Trap

A

The process of switching between user and kernel mode

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

Mode bit

A

Provides ability to distinguish when system is running user code or kernel code. This way some instructions that are privileged can only be executed in the kernel mode.

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

What causes the mode to change from user to kernel?

A

System call

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

What causes the mode to change from kernel to user?

A

The return from the system call

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

What can cause a transition from user to kernel mode?

A
  1. A system call

2. An exception (e.g., divide by 0) - handled as part of the CPU architecture.

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

Is “echo”, “grep” and other functions in the shell part of the OS?

A

No. They are applications that run above the OS but can be considered as OS services.

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

What are the 6 layers of the computer system?

A
  1. Apps
  2. User interface - shell or windows
  3. Libraries - the interface the OS gives us so we can use it with other applications
  4. OS abstractions - file systems, jobs/processes/threads, sockets
  5. Drivers - interface to hardware
  6. Hardware
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How does the computer communicate with IO devices?

A

Via busses

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

What are busses?

A

The way to connect to IO devices

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

Advantages of busses

A
  1. Versatility - easy to add new devices and move them between computer systems
  2. Low cost - share a single set of ways in multiple ways
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Disadvantages of busses

A
  1. Communication bottleneck - the bandwidth of the bus limits the maximum IO throughput
  2. Max bus speed is limited by length of bus, number of devices on the bus, and the need to support a range of devices with varying latencies and data transfer rates.
21
Q

Interrupts (hardware interrupts)

פסיקה

A

Way that devices can communicate with OS.

For example: The way the screen tells the OS that it finished writing something, the disk finished reading a file, etc.

22
Q

IRQ

A

Interrupt request lines - special line that the interrupts travel through to get to the CPU.

23
Q

Interrupt vector table (interrupt description table)

A

Every interrupt has a code that says what needs to happen with the interrupt occurs. The table saves the address where this code resides.

24
Q

What does system calls cause?

A

A trap - aka software (or internal) interrupt.

25
Q

Software interrupts

A

Either a system call or an exception

26
Q

Exceptions are ____ interrupts

A

Exceptions are internal interrupts

27
Q

Periodic vs aperiodic interrupts

A

Periodic - the clock (part of the CPU) does an interrupt periodically so the control can pass over to the OS.

Aperiodic - all the other types of interrupts we spoke about

28
Q

Software vs hardware interrupts

A

Software: causes by a software, this includes traps and exceptions.

Hardware: caused by hardware, this includes interrupts from external devices.

29
Q

Internal vs external interrupts

A

Generally: Internal=Software, External=Hardware

30
Q

Synchronous vs. asynchronous interrupts

A

Synchronous: happens with the clock ticks (software, timer/clock interrupts).

Asynchronous: More tricky because you don’t know which command you need to go back to

31
Q

Maskable vs. non-maskable interrupts

A

Maskable: hardware interrupts that can be delayed if more important interrupts is currently handled.

32
Q

Where is there more overhead: in user mode vs kernel mode?

A

User, since you don’t have traps.

33
Q

What are advantages of having a smaller kernel?

A
  1. Fewer traps –> less overhead –> higher throughput
  2. Smaller memory footprint
  3. More functions outside of kernel, so if they change, there’s no need to recompile the kernel.
34
Q

What are disadvantages of having a smaller kernel?

A

Less protection

35
Q

Monolithic kernel

A

The kernel has basic functions and you can load other modules into the memory when necessary

36
Q

Microkernels

A

A few different kernels that work together

37
Q

Difference between Monolithic kernels and Microkernels?

A

If they work on the same address space or not.

Single address space - monolithic.

38
Q

Are system calls privileged?

A

No.

39
Q

Interrupt controller

A

Serves a an intermediate between the hardware devices and the processor. it can take input from different devices, and alerts the processor.

40
Q

APC

A

Asynchronous procedure call

For example: an interrupt, because the program can’t control it.

41
Q

Why are interrupts characterized as APCs (Asynchronous procedure call)?

A

Because they aren’t part of the regular, pre-planned code. The program can’t control when it’ll be.

42
Q

Mechanism of interrupts

A

(Similar to functions)

  1. Getting the interrupt
  2. Saving current state
  3. Transfer control & service the request (using an “interrupt vector”)
  4. Previous state is restored
  5. Return control (back to user mode)
43
Q

Internal interrupts

A

Internal interruption (exception) occurs when the processor detects an error condition while executing an instruction (unlike external interrupts, which occur at random times during the execution of a program)

44
Q

Examples of internal interrupts

A
Division by zero
Segmentation fault
Privileged instruction
Invalid instruction
Page fault
45
Q

What happens when an exception occures?

A
  • When an exception occurs, the address of the instruction which generated the exception is saved.
  • Then the OS gives the exception handler a chance to fix the problem.
  • If there was an handler, the program is restarted at the address of the fault and continue normally
    Otherwise, the program is aborted.
46
Q

What type of interrupt can happen between clock cycles?

A

Only external interrupts (and not internal ones)

47
Q

Trap

A

A trap is a type of exception (internal interrupt), which occurs in the usual run of the program, but unlike it, it is not product of some error.
Trap causes switching to OS code and to kernel mode. Once in kernel mode, a trap handler is executed to service the request.

48
Q

Breakpoints in debuggers are created by using ____.

A

Breakpoints in debuggers are created by using traps.

49
Q

The system call is a wrapper function that runs in ____ mode which calls the interrupt which is handled in ____ mode.

A

The system call is a wrapper function that runs in user mode which calls the interrupt which is handled in kernel mode.