Lecture 6: Intro to Signals & Brief Intro to Threads Flashcards
Define: Signal
A mechanism for notifying a process that an event has occurred.
Where can a signal originate from?
From within a process (running into a divide-by-zero) or from outside a process (ex. keyboard)
What can happen when a process receives a signal?
Can either: take a default action OR use a pre-defined signal handler that is programmer-specified ( signal(par1,par2); ) OR Ignore
What handles the sending and receiving of signals?
The OS Kernel:
Sending: OS Kernel updates info for destination process
Receiving: OS Kernel forces target process to handle signal
Does each signal have a system-defined default action or does each action have to be defined by the user.
Each signal type has a system-defined default action
What must you include first before being able to use the system signal call?
Include signal.h header
Define: Thread
A thread is a basic unit of CPU utilization where threads of a process share memory but can execute independently
What is wrong with using fork() to create multiple processes?
Process creation is time consuming and resource intensive.
What do threads share?
1) Process address space
2) OS State
Define: Process address space in terms of what threads share
- text
- data (global variables)
- heap (dynamically allocated data)
Define: OS State in terms of what threads share
- open files
- sockets
- locks
What do threads uniquely possess?
Their own CPU context:
- Program Counter (PC)
- Stack Pointer (SP)
- Registers & Register State
- Stack
List the benefits of threads:
1) Responsiveness
2) Resources Sharing
3) Allocating memory and resources for process creation is costly
4) Context-swtiching is faster
Define: Thread Libraries
A thread library provides the programmer with an API for creating and managing threads
List 3 main thread libraries:
1) POSIX PThreads
2) Win32
3) Java