Multi-Threading Flashcards
What is a Thread in Java?
A thread in Java is an independent path of execution in an application. JVM gives
each thread its own method-call stack.
When we start JVM, Java starts one thread. This thread calls the main method of the class passed in argument to java call.
What is the priority of a Thread and how it is used in scheduling?
In Java, every Thread has a priority. This priority is specified as a number between 1 to 10.
Scheduler in Java schedules different threads based on the priority of a thread. It is also known as pre-emptive scheduling.
The thread with higher priority gets preference in execution over a thread with lower priority.
What is the default priority of a thread in Java?
In Java, a new thread gets the same priority as the priority of the parent thread that creates it.
Default priority of a thread is 5 (NORM_PRIORITY).
What are the three different priorities that can be set on a Thread in Java?
- MIN_PRIORITY: This is the minimum priority that a thread can have.
- NORM_PRIORITY: This is the default priority that is assigned to a thread.
- MAX_PRIORITY: This is the maximum priority that a thread can have.
Default priority of a thread is 5 NORM_PRIORITY. The value of
MIN_PRIORITY is 1 and the value of MAX_PRIORITY is 10.
What are the Four classes of computer architecture based on Instructions streams and Data Streams
SISD- Single Instruction Single data
SIMD- Single Instruction Multiple data
MISD - Multiple Instruction Single data
MIMD- Multiple Instruction Multiple data
What is SISD?
It only perfroms one series of Instruction and also act on one element of data at a time.
eg- A chief Chopping carrot
What is SIMD?
A parallel computer with multiple processing units. All processors execute the same Instruction but operate on different data element.
eg- Two chiefs chopping different things in sync.
Good for image processing
What is MISD?
Each processing unit independently process its own separate set of instructions. But all of the processors are working on a single data stream.
ps. doesn’t make practical sense
What is MIMD?
Every processing unit can be executing a different set of instructions and also all the operations can be done on a different set of data element.
eg- one chief peeling carrot the other chopping onions
What are the sub categories for the programming model of MIMD
SPMD- Single program multiple data
MPMD- Multiple program Multiple Data
What is SPMD?
Multiple processing units are executing a copy of the same single program simultaneously. However they can each use different data.
This is the most commonly used architecture
eg- Using same recipee
What is MPMD?
Processors can be executing different independent programs at the same time and also be operating on a different data
Not as common as SPMD
eg - using different data
What are the Memory Architectures?
Shared memory
Distributed memory
What is a shared memory?
It is a memory in which all processors access the same memory with global address space.
Whenever their is a change in a memory space, all the processors are updated of the change.
What are the different type of Shared memory architectures?
uniform memory access(UMA)
non uniform memory access(NUMA)