Threads Flashcards

(89 cards)

1
Q

What is the flow of Multithreaded Server Architecture

A

CLIENT > requests to > SERVER > creates thread to service request >
SERVER > continues to listen for additional client requests

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

Four benefits of Threads

A

Resource sharing
Responsiveness
Scalability
Economy

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

A benefit of threading which may allow continued execution if part of the process is blocked ( which is important for UI)

A

Responsiveness

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

A benefit of threads wherein threads share resources of process
(Easier than shared memory or message passing)

A

Resource sharing

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

Benefit of threads since

thread creation is CHEAPER than process creation;
Thread switching has LOWER OVERHEAD than context switching

A

Economy

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

Beneift of thread wherein the process can take advantage of the multiprocessor architecture

A

Scalability

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

_______ systems putting pressure on the programmer

A

Multicore / multiprocessor

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

Challenges faced because of using multicore / multiprocessor systems

A
Dividing activities
Balancing
Dtaa dependency
Data splitting
Testing and debugging
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

____ implies that a system can perform more than one task SIMULTANEOUSLY

A

Parallelism

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

___ supports more than one task making progress
(Single processor only)
(Scheduler is responsible for this)

A

Concurrency

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

A type of parallelism wherein you distribute SUBSET of the SAME DATA and perform the SAME operation across multiple cores

A

Data parallelism

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

A type of parallelism wherein you distribute threads across cores and perform DIFFERENT OPERATIONS per thread

A

Task parallelism

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

An increase in the number of threads implies that ___

A

Architectural support for threading also grows

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

CPUs have cores and h____

Eg: oracle sparc t4

A

hardware threads

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

For every thread in a Mutithreaded processes, there is a unique ____

A

Stack

Registers

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

This identifies the PERFORMANCE GAINS from ADDING ADDITIONAL CORES to an applictaion which has serial and parallel components

A

Amdahl’s Law

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

The higher the serial portion of an application, the ___ the performance gained by adding additional cores

A

Lesser

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

Formula for amdahl’s law

A

Speed-up = 1 / s-((1-s) / no of cores )

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

As N reaches infinity, speedup approaches __

A

1/serial portion

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

A type of parallelism wherein you distribute SUBSET of the SAME DATA and perform the SAME operation across multiple cores

A

Data parallelism

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

A type of parallelism wherein you distribute threads across cores and perform DIFFERENT OPERATIONS per thread

A

Task parallelism

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

An increase in the number of threads implies that ___

A

Architectural support for threading also grows

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

CPUs have cores and h____

Eg: oracle sparc t4

A

hardware threads

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

For every thread in a Mutithreaded processes, there is a unique ____

A

Stack

Registers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
This identifies the PERFORMANCE GAINS from ADDING ADDITIONAL CORES to an applictaion which has serial and parallel components
Amdahl’s Law
26
The higher the serial portion of an application, the ___ the performance gained by adding additional cores
Lesser
27
Formula for amdahl’s law
Speed-up = 1 / s-((1-s) / no of cores )
28
As N reaches infinity, speedup approaches __
1/serial portion
29
A type of parallelism wherein you distribute SUBSET of the SAME DATA and perform the SAME operation across multiple cores
Data parallelism
30
A type of parallelism wherein you distribute threads across cores and perform DIFFERENT OPERATIONS per thread
Task parallelism
31
An increase in the number of threads implies that ___
Architectural support for threading also grows
32
CPUs have cores and h____ | Eg: oracle sparc t4
hardware threads
33
For every thread in a Mutithreaded processes, there is a unique ____
Stack | Registers
34
This identifies the PERFORMANCE GAINS from ADDING ADDITIONAL CORES to an applictaion which has serial and parallel components
Amdahl’s Law
35
The higher the serial portion of an application, the ___ the performance gained by adding additional cores
Lesser
36
Formula for amdahl’s law
Speed-up = 1 / s-((1-s) / no of cores )
37
As N reaches infinity, speedup approaches __
1/serial portion
38
Threads managed by USER LEVEL THREAD LIBRARIES
User threads
39
Three primary thread libraries
POSIX pthreads Windows threads Java threads
40
Threads supported by the kernel | Ex: all general purpose OS
Kernel threads
41
Example of kernel threads
Windows Mac OS tru64 Unix
42
A multi threading model wherein many user level threads are mapped to a single kernel thread Give examples
Many to one Solaris green thread GNU portable thread
43
A multithread model wherein creating a user level thread also creates a kernel thread This model has more concurrency than many to one model but the number of threads are RESTRICTED due to OVERHEAD Give examples
One to one model Windows, linux, solaris 9 or later
44
A mulithread model wherein many user threads are mapped to many kernel threads which allows the OS to create SUFFICIENT number of kernel threads Give examples
Solaris prior to ver 9 | Windows with ThreadFiber package
45
A multithread model which is similar to m:m except it allows a user thread to be BOUND to a kernel thread Give examples
IRIX HP-UX Tru64 UNIX Solaris 8 and earlier
46
___ provides programmers with API for creating and manageing threads
Thread library
47
Two ways of implementing thread libraries
Library is ENTIRELY in USER SPACE | KERNEL-LEVEL LIBRARY supported by the OS
48
A POSIX standard API for creating and synchronization of threads SPECIFIES behaviour of the thread library; IMPLEMENTATION is up to the development of the lirbary
Pthreads
49
Threads managed by the JVM What are two ways to imlement this?
Java Threads ``` Extend thread class Implement runnable interface ```
50
Creation and management of threads are done by compilers and run-time libraries rather than programmers What are three methods using this?
Implicit threading ThreadPool openMP grand central dispatch *other methods include Microsoft threading Building blocks (TBB) java.util.concurrent package
51
This method creates a number of threads IN A POOL where they await to work What are advantages of this method?
Thread Pools - slightly FASTER to service request with an existing thread than to create a new one - allows a number of threads to be BOUND to the size of the pool - CAN SEPARATE TASKS to be performed which allows strategies for running taskswh
52
What API supports thread pools
Windows API
53
A set of COMPILER DIRECTIVES and an API for c, c++, fortran which provides support for parallel programming in SHARED MEMORY environments
OpenMP
54
Blocks of that can run in parallel that is identified by OpenMP
Parallel regions
55
This compiler directive creates many threads as there are cores
#pragma omp parallel
56
This method is an apple technology for mac os x and ios which allows IDENTIFICATION OF PARALLEL SECTIONS and manages most of the details in THREADING Where is the block placed if you were to use this method?
Grand central dispatch ^{} which are placed in the dispatch queue
57
A type of dispatch queue wherein blocks are removed in FIFO order and queue is PER PROCESS called ___
Serial dispatch queues; main queue
58
Type of dispatch queue wherein blcoks are removed in FIFO order but several may be removed at a time There are three system wide queues with priorities __,__,__
Concurrent dispatch queue Low, default, high
59
5 Threading issues
``` Fork() and exec() system calls semantics Signal handling Thread cancellation Thread local storage Scheduler activations ```
60
What is the thread issue of fork() and exec()?
Fork() may: 1. Duplicate only the calling thread 2. Duplicate all threads Exec() replaces the running process including all threads
61
This are used in the UNIX system to notify a process that a particular event has occured What is used to process these?
Signals Signal handlers
62
How does a signal reach a signal handler?
Signal is generated by an event > signal is delivered to a process > signal is handled by 1 / 2 signal handlers (kernel or user defined)
63
Every signal has a __ that a kernel runs when handling signals, ___ can override these
Default handlers ; user defined signal handlers
64
What is the threading issue of signal handling?
Issue on where the signal should be delivered for multi-threaded - deliver to the thread which the signal applies - deliver to every thread in the process - deliver to certain threads in the process - assign specific thread to receive all incoming signals *if single threaded, signal is delivered to the process
65
A threading issue wherein you terminate a thread before it has finished wherein the thread to be cancelled is called the ___
Thread cancellation; target head
66
A general approach of thread cancellation wherein you terminate the target head immediately
Asynchronous cancellation
67
A general approach of thread cancellation wherein it allows the target head to periodically check if it should be cancelled
Deferred cancellation
68
What is the issue on thread cancellation?
Invoking thread cancellation only REQUESTS cancellation but actual cancellation depends on thread state If thread ‘s state for cancellation is disabled, cancellation remains pending until thread enables it
69
What is the default type of thread cancellation wherein thread cancels only if it reaches CANCELLATION POINT What handler is invoked by this type of cancellation? Give an example
Deferred cancellation Cleanup handler Pthread_testcancel()
70
This allows each thread to have its own copy of data which is useful if you do not have control over the creation of threads
Thread local storage
71
Difference of tls and local variables
TLS are visible across function invocations while local variables are only visible during a single function
72
A form of communication to MAINTAIN APPROPRIATE NUMBER OF KERNEL THREADS ALLOCATED TO AN APPLICATION
Scheduler activations
73
A communication mechanism used by scheduler activations from the kernel to the ___ in the thread library
Upcalls Upcall handler
74
What is the issue in scheduler activations?
Scheduler activations uses an intermediate data structure called LIGHTWEIGHT PROCESS (LWP) between user and kernel threads which serves as a VIRTUAL PROCESSOR - Does each kernel thread need an lwp attached to it? - how many lwp to create
75
The primary API for windows which implements 1:1 and kernel level thread
Windows API
76
Each thread contains
- thread id | - CONTEXT (register set, stacks, private storage area)
77
WHat does the register set reoresent in a thread
State of processor
78
What is the purpose of stacks in a thread?
Separate user and kernel stacks when thread runs user or kernel mode
79
Whatis the purpose of private data storage area in a thread?
This area is used by RUN-TIME LIBRARIES and DYNAMIC LINK LIBRARIES(DLLs)
80
A primary data structure of a thread which has a POINTER TO - the process to which thread belongs - to KTHREAD in kernel space
ETHREAD (executive thread block)
81
A primary data structure of a thread which handles SCHEDULING AND SYNC info, KERNEL MODE STACK, pointer to TEB in kernel space
KTHREAD (Kernel thread block)
82
A primary data structure of a thread which contains the thread id, USER MODE STACK, TLS, In user space
TEB (Thread environment block)
83
What is linux’s term for thread?
Task
84
Thread creation in linux is done by __ which allows child to share address space of parent task (process)
Clone() system call
85
Flag control for clone() where file system info is shared
Clone_fs
86
Flag control behaviour of clone same memory is shared
Clone_vm
87
Flag control behaviour of clone where signal handlers are shared
Clone_sighand
88
Flag control behaviour of clone() where set of open files are shared
Clone_files
89
In linux threads, ___ points to PROCESS DATA STRUCTURES (SHARED OR UNIQUE)
struct task_struct