Lecture 6: Intro to Signals & Brief Intro to Threads Flashcards

1
Q

Define: Signal

A

A mechanism for notifying a process that an event has occurred.

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

Where can a signal originate from?

A

From within a process (running into a divide-by-zero) or from outside a process (ex. keyboard)

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

What can happen when a process receives a signal?

A

Can either: take a default action OR use a pre-defined signal handler that is programmer-specified ( signal(par1,par2); ) OR Ignore

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

What handles the sending and receiving of signals?

A

The OS Kernel:
Sending: OS Kernel updates info for destination process
Receiving: OS Kernel forces target process to handle signal

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

Does each signal have a system-defined default action or does each action have to be defined by the user.

A

Each signal type has a system-defined default action

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

What must you include first before being able to use the system signal call?

A

Include signal.h header

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

Define: Thread

A

A thread is a basic unit of CPU utilization where threads of a process share memory but can execute independently

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

What is wrong with using fork() to create multiple processes?

A

Process creation is time consuming and resource intensive.

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

What do threads share?

A

1) Process address space

2) OS State

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

Define: Process address space in terms of what threads share

A
  • text
  • data (global variables)
  • heap (dynamically allocated data)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define: OS State in terms of what threads share

A
  • open files
  • sockets
  • locks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What do threads uniquely possess?

A

Their own CPU context:

  • Program Counter (PC)
  • Stack Pointer (SP)
  • Registers & Register State
  • Stack
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

List the benefits of threads:

A

1) Responsiveness
2) Resources Sharing
3) Allocating memory and resources for process creation is costly
4) Context-swtiching is faster

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

Define: Thread Libraries

A

A thread library provides the programmer with an API for creating and managing threads

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

List 3 main thread libraries:

A

1) POSIX PThreads
2) Win32
3) Java

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

State potential problem(s) with threads:

A

Sharing global variables is dangerous because 2 threads may attempt to modify the same variable at the same time. Solution is to lock when in use and unlock when done with variable.