Exceptions, Interrupts, and Signals Flashcards

1
Q

Process

A

Executing instance of a program. Separate mem address spaces. Resource heavy-weight

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

Thread

A

Entity within a process that can be schedules for code execution. Each process has at least one thread. Share mem address space, opened files, and more. Resource light-weight

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

Thread Pros and Cons

A

PROS: Cheaper to create thread. Cheaper task switch. cheaper data sharing
CONS: One bug or attack in thread makes whole process unstable (bc of data sharing).

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

Exceptions

A

Event that interrupt the normal execution of a program or a system, causes mode switch

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

Types of Exceptions

A
  1. Programmed exception (traps)
  2. Anomalous executions (faults)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Programmed Exceptions (traps)

A

‘int 0x80’ (system call), ‘int 3’ (single-step debugging)

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

Anomalous Executions (faults)

A

Divide by zero, dereference null pointer.

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

How is ‘divide by zero’ handled?

A
  1. CPU executing division triggers exception
  2. Mode switch to kernel, divide by zero handler invoked automatically
  3. Handler sends SIGFPE to faulty process, mode switch back to user space
  4. If process has SIGFPE handler then executes it. Otherwise default handler in libc kills the process
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Signal Causes

A
  1. “kill -signame pid”
  2. “pthread_kill()”, sends signals to specific thread within sender’s process
  3. “tgkill(pid, tid, sig)”, send signal to thread ‘tid’ in process ‘pid’
  4. “sigqueue(pid, sig, value)”, sends signal and associated value to process ‘pid’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When does SIGCHLD happen?

A

What a process exits, the parent process receives a SIGSHLD.

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

Thread Signal Handler

A

Handlers are shared among threads of a process, while signal mask is per thread.

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

sigaction()

A

Used to change default signal handler to be customized.

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

signal()

A

Like sigaction(). After invocation of your handler, default is restored, so not reliable.

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

Vector

A

Number in [0,255] used to identify an interrupt or exception. Can be specified by programmer

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

IDT

A

Interrupt Descriptor Table. Each entry is a descriptor that refers to an interrupt or exception handler.

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

Interrupt/Exception Hander

A
  1. Mode switch to kernel mode in is currently in user mode
  2. Save current context
  3. Invoke corresponding handler function using IDT and interrupt/exception vector
  4. Restore context
  5. Mode switch back to user mode in needed
17
Q

fork()

A

Parent process receives child process id and child receives 0 (but child id isn’t actually 0)

18
Q

exec()

A

Changes the program that is being executed. All code is overwritten with new program.

19
Q

wait()

A

Suspends execution of the calling process until one of its children terminate.

20
Q

How does computer HARDWARE respond to a keystroke?

A
  • Interrupt generated by keyboard
  • CPU notices interrupt and sets program counter to corresponding interrupt handler
21
Q

Zombie

A

Occurs once a child process exits. Occupies important resources. Cleaned up by:
- parent waiting w wait()
- parent explicitly ignores SIGCHLD by setting handler to SIG_IGN
- if parent exits, zombie gets reaped by init()

22
Q

How does computer SOFTWARE-KERNEL respond to a keystroke?

A
  • interrupt handler executes the device driver for the keyboard
  • handler then reads character from keyboard buffer to kernel-space buffer
23
Q

How does computer SOFTWARE-USER/KERNEL respond to a keystroke?

A
  • process that waits for input is waken up
  • kernel copies character from the kernel space to the user-space buffer