Process | Multi-Processing | Thread | Multi-Threading Flashcards

1
Q

What is a Process?

A

A Process is an instance of a program in execution. It has its own memory space, resources, and state. Each process is independent of other processes.

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

What are the components of a Process?

A

A Process consists of: 1) Code (text section), 2) Data (variables), 3) Heap (dynamic memory), 4) Stack (function calls and local variables), and 5) Process Control Block (PCB).

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

What is a Process Control Block (PCB)?

A

The PCB is a data structure used by the OS to store information about a process, such as Process ID (PID), program counter, CPU registers, memory limits, and process state.

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

What are the states of a Process?

A

The states of a Process are: 1) New, 2) Ready, 3) Running, 4) Waiting (or Blocked), and 5) Terminated.

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

What is Context Switching?

A

Context Switching is the process of saving the state of a running process and loading the state of another process so that the CPU can execute it. It is essential for multitasking.

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

What is the difference between a Process and a Program?

A

A Program is a static set of instructions stored on disk, while a Process is a dynamic instance of a program being executed in memory.

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

What is a Thread?

A

A Thread is the smallest unit of execution within a process. It shares the same memory space and resources as other threads in the same process but has its own stack and program counter.

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

What is the difference between a Process and a Thread?

A

A Process is independent and has its own memory space, while a Thread is a lightweight unit of execution within a process and shares memory with other threads in the same process.

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

What are the advantages of using Threads?

A

Advantages of Threads include: 1) Faster creation and context switching, 2) Efficient communication (shared memory), 3) Better resource utilization, and 4) Improved responsiveness in applications.

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

What are the disadvantages of using Threads?

A

Disadvantages of Threads include: 1) Complexity in synchronization, 2) Risk of race conditions, 3) Debugging difficulties, and 4) Potential for deadlocks.

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

What is Multithreading?

A

Multithreading is the ability of a CPU to execute multiple threads concurrently within a single process. It allows parallel execution of tasks and improves application performance.

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

What are the types of Multithreading?

A

The types of Multithreading are: 1) User-Level Threads (managed by user libraries) and 2) Kernel-Level Threads (managed by the OS).

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

What is the difference between User-Level Threads and Kernel-Level Threads?

A

User-Level Threads are managed by user libraries and are faster to create, but they cannot leverage multiple CPUs. Kernel-Level Threads are managed by the OS and can run on multiple CPUs but have higher overhead.

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

What is a Race Condition?

A

A Race Condition occurs when two or more threads access shared data simultaneously, leading to unpredictable results due to improper synchronization.

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

What is Synchronization in Multithreading?

A

Synchronization ensures that only one thread can access a shared resource at a time. It is achieved using tools like mutexes, semaphores, and monitors.

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

What is a Mutex?

A

A Mutex (Mutual Exclusion) is a synchronization primitive that ensures only one thread can access a shared resource at a time. It prevents race conditions.

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

What is a Semaphore?

A

A Semaphore is a synchronization tool that controls access to shared resources using a counter. It can allow multiple threads to access a resource up to a specified limit.

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

What is a Deadlock?

A

A Deadlock occurs when two or more threads are blocked forever, waiting for each other to release resources. The four conditions for deadlock are: 1) Mutual Exclusion, 2) Hold and Wait, 3) No Preemption, and 4) Circular Wait.

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

How can Deadlocks be prevented?

A

Deadlocks can be prevented by breaking one of the four conditions: 1) Avoid Mutual Exclusion, 2) Eliminate Hold and Wait, 3) Allow Preemption, or 4) Break Circular Wait.

20
Q

What is the Banker’s Algorithm?

A

The Banker’s Algorithm is a deadlock avoidance algorithm that checks if allocating resources to a process will leave the system in a safe state (where all processes can complete without causing a deadlock).

21
Q

What is Multiprocessing?

A

Multiprocessing refers to the use of multiple CPUs or cores within a single computer system to execute multiple processes simultaneously. It enables true parallel execution.

22
Q

What is the difference between Multiprocessing and Multithreading?

A

Multiprocessing uses multiple CPUs/cores to execute processes independently, while Multithreading uses a single CPU/core to execute multiple threads within a process concurrently.

23
Q

What are the advantages of Multiprocessing?

A

Advantages of Multiprocessing include: 1) High performance, 2) Fault tolerance (if one CPU fails, others continue), and 3) Scalability (more CPUs can be added).

24
Q

What are the disadvantages of Multiprocessing?

A

Disadvantages of Multiprocessing include: 1) High cost, 2) Complexity in managing shared resources, and 3) Increased power consumption.

25
Q

What is the difference between Symmetric Multiprocessing (SMP) and Asymmetric Multiprocessing (AMP)?

A

In SMP, all CPUs are equal and share the same memory. In AMP, CPUs have specific roles (e.g., one master CPU controls others).

26
Q

What is a Thread Pool?

A

A Thread Pool is a collection of pre-initialized threads that are ready to execute tasks. It improves performance by reducing the overhead of creating and destroying threads.

27
Q

What is the difference between Preemptive and Non-Preemptive Scheduling?

A

In Preemptive Scheduling, the OS can interrupt a running task to allocate the CPU to another task. In Non-Preemptive Scheduling, a task retains the CPU until it completes or voluntarily releases it.

28
Q

What is a Critical Section?

A

A Critical Section is a segment of code where shared resources are accessed. Only one thread can execute the critical section at a time to prevent race conditions.

29
Q

What is a Monitor?

A

A Monitor is a synchronization construct that allows threads to wait for certain conditions to be met. It combines mutual exclusion with the ability to wait and signal.

30
Q

What is the Producer-Consumer Problem?

A

The Producer-Consumer Problem is a classic synchronization problem where a producer generates data and a consumer processes it. It requires proper synchronization to avoid race conditions.

31
Q

How does the OS handle Thread Scheduling?

A

The OS uses scheduling algorithms (e.g., Round Robin, Priority Scheduling) to allocate CPU time to threads. It ensures fair and efficient execution of threads.

32
Q

What is the difference between Parallelism and Concurrency?

A

Parallelism involves executing multiple tasks simultaneously using multiple CPUs/cores. Concurrency involves managing multiple tasks at the same time, but not necessarily executing them simultaneously.

33
Q

What is Amdahl’s Law?

A

Amdahl’s Law states that the speedup of a program using multiple processors is limited by the portion of the program that cannot be parallelized.

34
Q

What is a Zombie Process?

A

A Zombie Process is a process that has completed execution but still has an entry in the process table to report its status to the parent process.

35
Q

What is an Orphan Process?

A

An Orphan Process is a process whose parent process has terminated, leaving it to be adopted by the init process (PID 1).

36
Q

What is the difference between a Daemon Process and a Normal Process?

A

A Daemon Process runs in the background and provides services (e.g., web servers), while a Normal Process runs in the foreground and interacts with the user.

37
Q

What is Thread Safety?

A

Thread Safety means that a piece of code or data structure can be safely accessed by multiple threads without causing race conditions or inconsistencies.

38
Q

What is the difference between a Process and a Thread in terms of Memory?

A

A Process has its own memory space, while a Thread shares memory with other threads in the same process.

39
Q

What is the GIL (Global Interpreter Lock) in Python?

A

The GIL is a mutex that allows only one thread to execute Python bytecode at a time, limiting the performance of multithreaded Python programs.

40
Q

What is the difference between Multiprogramming and Multiprocessing?

A

Multiprogramming maximizes CPU utilization by switching between programs on a single CPU, while Multiprocessing uses multiple CPUs/cores to execute processes simultaneously.

41
Q

What is the difference between Multitasking and Multithreading?

A

Multitasking involves running multiple processes concurrently, while Multithreading involves running multiple threads within a single process concurrently.

42
Q

What is the difference between a Heavyweight Process and a Lightweight Process?

A

A Heavyweight Process has its own memory space and resources, while a Lightweight Process (Thread) shares memory and resources with other threads in the same process.

43
Q

What is the difference between a Kernel Thread and a User Thread?

A

A Kernel Thread is managed by the OS and can run on multiple CPUs, while a User Thread is managed by a user library and is limited to a single CPU.

44
Q

What is the difference between a Process and a Thread in terms of Overhead?

A

Creating and managing a Process has higher overhead than a Thread because a Process has its own memory space, while a Thread shares memory with other threads.

45
Q

What is the difference between a Process and a Thread in terms of Communication?

A

Processes communicate using Inter-Process Communication (IPC) mechanisms like pipes or shared memory, while Threads communicate directly through shared memory.

46
Q

What is the difference between a Process and a Thread in terms of Fault Tolerance?

A

If a Process crashes, it does not affect other Processes. If a Thread crashes, it can affect other Threads in the same Process.

47
Q

What is the difference between a Process and a Thread in terms of Scalability?

A

Threads are more scalable than Processes because they require fewer resources and have lower overhead.