Processes and Threads Flashcards
A program in execution has at least a ______ counter, ____, and ___section
program, stack, data
The stack in a process contains local _______ and function _______ ________
variables, return, addresses
The ______ in a process is dynamically allocated
heap
The data section in a process contains _______ variables
global
A ___ process was just created
new
A _____ process is waiting for CPU to become available
ready
A running process is having its ________ being executed by the CPU
instructions
A waiting process is waiting for ___ or an ______
I/O, event
A ________ process is done executing
finished
A ______ ______ ______ allows the OS to maintain info about a process
Process control block
A PCB contains info about…
- Process state
- Program counter
- CPU registers
- CPU scheduling info
- Memory-management info
- Accounting info
- I/O status info
A PCB is used to switch the _____ from one process to another
CPU
The PCB in linux the represented by the ________
task_struct
The processor _______ job is the switch between processes onto the CPU for time sharing
schedulers
What two scheduling queues are processes maintained in?
Ready queue and device queue
The _____ queue contains processes residing in main memory that are ready to execute
ready
The device queue contains processes waiting for an ___ _______
I/O device
What are the four reasons a process may be kicked out of been currently executed?
- I/O request
- Time slice expired
- Fork a child
- Wait for an interrupt
A _____ ______ is when the CPU core switches from one process to another
context switch
____ describes the values of the CPU register
state
When a context switch occurs, P0’s state is stored in _____ and P1’s ____ is loaded from PCB 1 into registers
PCB0, state
The time it takes for a context switch is pure ______
overhead
Some hardware supports very quick context switches by simply change the value of a ______
pointer
_____ processes can create children processes using the _____ syscall
parent, fork
each process has an associated _________ id
process
A child process as an exact _____ of its parent
copy
Typically, a child loads another program using the ____ syscall while the parent _____
exec(), waits
The syscall ____ returns twice. It returns 0 for a _____ process and is otherwise a _____ process
fork, child, parent
A process can be terminated if there are no more _______ or the parents terminates it
instructions
A parent may terminate a child when the child has exceeded ______, is no longer ______, is is exiting itself
resources, required
A _____ process is a terminated process, but the parent hasn’t called wait()
zombie
An _____ process is a running process, but the parent exited without calling wait
orphan
A _____ is a basic unit if CPU utilization
thread
A thread is a sequence of _______ in a function which the CPU can execute as a unit
instructions
A thread is composed of a PC, _____ set, and ______
register, stack
A _____ is composed of one or more _____
process, threads
Threads belonging to the same process share….
code section, data section, OS resources
What are some example of multithreading?
- Web browsers: parallel downloads
- Web servers: handle multiple concurrent clients
- Word processors: spell check in the background
____ level threads are maintained in the user level, performed in user mode, is hidden from the kernel, and is provided by user-level libraries
User
_____ level threads have their operation in kernel mode and are provided by the OS
kernel
What are the 3 different mapping from user-level threads to kernel-level threads?
Many-to-one, One-to-one, and Many-to-many
In a Many-to-one mapping, many _______ threads are mapped to a single _____ thread
user-level, kernel
A __________ mapping makes managing user threads faster because there are no syscalls and no switching to kernel mode
Many-to-one
A con of the Many-to-one thread mapping is that when one thread ______, the entire process ______
blocks, blocks
In a _________ mapping, each user-level thread maps to a kernel thread
One-to-one
A benefit of the one-to-one mapping is that there is increased _________, and when one thread _____, others can run
concurrency, blocks
A con of the _________ mapping is that creating too many kernel threads may degrade performance since they consume OS resources, and thread management overheads
one-to-one
In a Many-to-many mapping, _____ user threads map to _______ kernel threads
multiple, multiple
Some benefits of the Many-to-many mapping is increased ________ and ______, as the user can create as many user threads they want
concurrency, flexibility
A con of the ________ mapping is that it is complex to implement
many-to-many
_________ ________ is a common thread library found in UNIX systems
POSIX Pthreads
The windows threads is an implementation of the _______ mapping in the kernel
one-to-one
_____ threads are managed by the JVM which is run on top of an OS
Java
What are 3 issues of threading?
- Semantics of fork() and exec() system calls
- Signal handling
- Thread pools
When should a fork() duplicate only the calling thread? Why?
If exec() is called, because exec() overrides all existing threads anyways
When should a fork() duplicate the entire process?
When exec() is not called
What is the difference between a synchronous and asynchronous signal?
A synchronous signal is delivered to the same process that performed the operation that caused the signal. An asynchronous signal is generated by an external event, usually delivered to a different process
____ are used in Unix to notify a process that an event has occurred
Signals
What is an example of a synchronous signal?
illegal memory access
What is an example of an asynchronous signal?
Ctrl-c
Describe the life cycle of a signal (3 steps)
- Signal is generated by an event
- Signal is delivered to a process
- Signal handler processes the signal (default by OS, or user-defined)
______ can choose to block signals
threads
A _______ signal should be sent to the thread that performed an an operation that caused the signal to be generated
synchronous
A _______ signal sent to all threads belonging to the process
asynchronous
An _______ is initiated by the CPU, I/O devices, or software while a _______ is initiated by the kernel or a process
interrupt, signal
Interrupts are handled by a very simple ____ in the _____
ISR, kernel
Signals are managed by the _______ or ____ process
kernel, user
The kernel map map some _______ to ________
interrupts, signals
A _____ _______ can be complex and call other functions in the kernel
signal handler
A ______ _____ is a set of threads that wait for work
thread pool
a web server serving many ______ may have a thread pool
requests
Servicing a request with an existing thread is ______ than creating a new one
faster
By ______ the number of threads in an application to a pool size, it is easier to manage _______
limiting, resources
In ______, all threads and processes are called tasks
Linux
In Linux, thread ______ is done though the clone system call
creation
The Linux clone can be changed to allow different _____ _______ possibilities
resource sharing
A benefit of Linux referring to all processes and threads as _____, is that it simplifies _________
tasks, scheduling
It is complex to correlate threads with their ________ when they are all referred to as tasks
processes