1/42
Flashcards to help review key concepts about processes and threads.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is a Process?
A process is an active execution of a program stored in memory.
When does a program become a process?
When it is loaded into memory.
What does a process's context include?
Information and data maintained for an executing program.
What is PID 0?
The swapper/scheduler process in the kernel responsible for memory management.
What is PID 1?
The init process responsible for starting up and shutting down the system.
What is the state of a process when it is initially created?
New.
What state is a process in when it is ready for execution?
Ready.
What is a context switch?
The process of switching the CPU from one process to another.
What happens during a context switch?
The OS saves the PCB of the old process and loads the PCB of the new process.
How long does a typical context switch take?
About 1 millisecond.
What are wait() and waitpid() system calls used for?
To force the parent process to suspend execution until the child process has completed.
What is multithreading?
Allowing multiple threads per process.
What are the benefits of multithreading?
Responsiveness, resource sharing, economy, scalability.
What does a thread represent?
A lightweight process associated with a particular process.
What is an independent stream of instructions in terms of operating systems?
A thread.
What do threads share within the same process?
Resources such as address space, variables, and files.
What is the pthreads library used for?
To create, manage, and synchronize threads on Linux.
What does pthread_create() do?
Creates a new thread.
What is the function of pthread_join()?
Wait for a specified thread to terminate.
What happens if a process issues an exit() system call?
All threads within that process are terminated.
What is pthread_exit() used for?
To terminate the calling thread without terminating the process.
What is memory sharing like between processes and threads?
Processes do not share memory; threads within the same process do.
What differentiates threads from processes regarding operation cost?
Threads have lower operational costs for communication due to shared memory.
What does the execution environment include for a process?
Files, memory space, and resources shared by threads.
How do changes in shared resources by one thread affect other threads?
All other threads will see changes made to shared resources.
What is a key consequence of threads sharing resources?
Requires explicit synchronization by the programmer.
What happens when a thread closes a file?
Other threads will also see that file as closed unless explicitly kept open.
What is the library call to detach a thread?
pthread_detach.
What is the result of failing to join or detach threads?
Memory and other resources will leak until the process ends.
How can you create a new thread?
By calling pthread_create with appropriate arguments.
What is the purpose of the 'arg' parameter in pthread_create?
To pass an argument to the function that the thread starts executing.
What does 'detaching a thread' mean?
System resources for the thread are reclaimed when it ends.
What is the major difference of context switching between threads versus processes?
Context switching between threads is less expensive compared to processes.
How is communication between threads achieved?
Through shared memory space.
What is the main advantage of using threads over processes?
Threads have lower overhead and faster context switching.
What does the 'exit status' parameter in pthread_exit() refer to?
The status passed to the pthread_join() function waiting for the thread.
What are the implications of two pointers pointing to the same data?
Changes in one thread can affect the data visible to other threads.
What library must be included to use pthreads?
What can the pthread_equal() function check?
It compares thread IDs.
What is the significance of context switches in terms of CPU utilization?
The system does no useful work while switching.
How can multithreading enhance system performance?
By minimizing response time and supporting concurrency.
What is the effect of one thread terminating in a process?
If the process terminates, all threads also terminate.
What resource types can threads share, which processes cannot?
Address space and file descriptors.