Multithreading Flashcards
Learn concepts that the understanding of multithreading
What does the preprocessor do in the program creation process?
It processes directives (e.g., macros, file inclusions, conditional compilations) to transform the source code before compilation.
What is the role of the compiler in program creation?
The compiler translates source code into machine code by performing syntax and semantic analysis, optimizations, and code generation.
What does an assembler do in the program creation process?
It converts assembly language code into machine code by translating mnemonic instructions into binary representations.
What is the function of the linker in program creation?
The linker combines object files into a single executable by resolving external symbols and organizing the memory layout.
What is a thread?
A thread is the smallest unit of execution within a process, managed by the scheduler.
How is parallelism defined in computing?
Parallelism is the simultaneous execution of multiple computations or processes to improve performance.
What does concurrency mean in computing?
Ability to manage multiple tasks at the same time and switch between them as needed
What is data parallelism?
It is the execution of the same operation concurrently on different pieces of distributed data.
What is task parallelism?
Task parallelism is the concurrent execution of different tasks or functions that perform distinct operations independently.
What are kernel threads?
Kernel threads are threads managed directly by the operating system, which handles their scheduling and resource allocation.
What are user threads?
User threads are threads managed by a user-level library rather than directly by the operating system.
What is the many-to-one threading model?
It is a model where many user-level threads are mapped to a single kernel thread.
What is the purpose of the many-to-one threading model?
Its purpose is to simplify thread management at the user level.
What is one advantage of the many-to-one threading model?
It offers efficient context switching with less overhead.
What is one disadvantage of the many-to-one threading model?
A blocking system call can block all threads, and it cannot utilize multiple processors concurrently.
What is the one-to-one threading model?
It is a model where each user-level thread is mapped to a unique kernel thread.
What is the purpose of the one-to-one threading model?
Its purpose is to allow true parallel execution on multiprocessor systems.
What is one advantage of the one-to-one threading model?
It provides better concurrency and true parallelism.
What is one disadvantage of the one-to-one threading model?
It increases overhead and consumes more system resources due to managing many kernel threads.
What is the many-to-many threading model?
It is a model where many user threads are mapped to many kernel threads.
What is the purpose of the many-to-many threading model?
Its purpose is to combine the benefits of user-level and kernel-level threading by providing flexible scheduling.
What is one advantage of the many-to-many threading model?
It allows efficient resource use and flexible scheduling of threads.
What is one disadvantage of the many-to-many threading model?
Its implementation is more complex and may introduce mapping overhead.
What are Pthreads?
Pthreads (POSIX Threads) is a standardized API for creating and managing threads in UNIX-like operating systems.
What are threading directives?
They are compiler-specific instructions (such as those used in OpenMP) that guide the compiler in parallelizing code.
What is implicit threading?
Implicit threading automatically handles thread creation and workload distribution, reducing the need for explicit thread management by the programmer.
What is a thread pool?
A thread pool is a collection of pre-created threads that are available to execute tasks, reducing the overhead of thread creation.
What is OpenMP?
OpenMP is an API that supports shared-memory parallel programming in C, C++, and Fortran through compiler directives, runtime routines, and environment variables.
What is a signal in computing?
A signal is a notification sent to a process to inform it of an event like an interrupt, exception, or other system condition.
What is a synchronous signal?
It is a signal generated as a direct result of a process’s actions, such as an arithmetic error.
What is an asynchronous signal?
It is a signal generated by external events (e.g., hardware interrupts or user actions) that can occur at any time during execution.
What is the default signal handler?
It is the system-provided function that handles signals when no custom handler is specified.
What is a user-defined signal handler?
It is a custom function written by the programmer to handle specific signals in a tailored manner.
What is thread cancellation?
Thread cancellation is the process of terminating a thread before its natural completion.
What is a targeted thread in the context of cancellation?
It is the specific thread chosen to be terminated during a cancellation request.
What is asynchronous thread cancellation?
It terminates a thread immediately, regardless of its current state, without waiting for a safe termination point.
What is deferred thread cancellation?
It allows a thread to periodically check for cancellation requests at designated safe points before terminating.
What is a cancellation point in thread cancellation?
It is a designated point in a thread’s execution where it checks for any pending cancellation requests.
What is a cleanup handler in the context of thread cancellation?
It is a function that performs resource deallocation or other necessary cleanup when a thread is cancelled.
What is thread local storage?
It provides each thread with its own private storage area, ensuring that data is not shared inadvertently among threads.
What is a lightweight process (LWP)?
A lightweight process is similar to a thread; it shares resources with other LWPs but maintains its own execution context for efficiency.
What are scheduler activations?
They are a technique that allows the kernel to notify a user-space thread scheduler about events like I/O completions, bridging kernel and user-level thread management.
What is an upcall?
It is a callback mechanism where the kernel notifies a user-level process or scheduler about events requiring intervention, such as I/O events.