Process vs. Thread: Differences, Use Cases, and Communication Quiz Quiz

  1. Core Distinction

    Which of the following best describes the primary difference between a process and a thread?

    1. A process has its own memory space, while threads within the same process share memory.
    2. Threads always execute on different CPUs, while processes run on the same CPU.
    3. Processes can only run one at a time, while multiple threads can run in parallel.
    4. Threads cannot communicate with each other, but processes can.
    5. A process is just a lightweight version of a thread.
  2. Thread Communication

    Which mechanism do threads within the same process commonly use to share data?

    1. Shared variables
    2. File system
    3. Socket communication
    4. Remote procedure calls
    5. DNS lookup
  3. OS Resource Handling

    What is one key resource difference between processes and threads in terms of OS management?

    1. Threads share most OS resources with their parent process, while processes have separate resources.
    2. Processes do not consume any CPU time, while threads do.
    3. Threads have their own independent file descriptors, while processes do not.
    4. Threads must have a separate virtual memory, while processes share virtual memory.
    5. Both processes and threads always share registers.
  4. Scenario: Web Server

    A web server wants to handle multiple client requests simultaneously but efficiently shares data and cache between workers. Which would be preferable?

    1. Use multiple threads within a single process.
    2. Run one process for each client, no threads.
    3. Fork a new process without any shared cache.
    4. Use stateless client-only operations.
    5. Spawn a new virtual machine per request.
  5. Interprocess Communication (IPC)

    Which of the following is a common method for processes to communicate with each other?

    1. Pipes
    2. Global variables
    3. Direct function call
    4. Register swapping
    5. Thread forking
  6. Concurrency Overhead

    What is a significant overhead when creating a new process compared to creating a new thread?

    1. Allocating separate memory space for the process
    2. Failing to initialize a stack pointer
    3. Copying the OS kernel code
    4. Resetting user permissions each time
    5. Assigning the same process ID to multiple instances
  7. Thread Safety

    In a multithreaded program, which issue is most likely to occur if shared data is not properly protected?

    1. Race condition
    2. Dead socket
    3. Stack underrun
    4. Page thrashing
    5. Kernel panic typo
  8. Python Example

    Given the following Python snippet, what is being created: 'threading.Thread(target=my_func).start()'?

    1. A new thread
    2. A new process
    3. A socket connection
    4. A timer event
    5. A global semaphore
  9. Thread vs. Process Isolation

    Why are processes considered more secure in terms of fault isolation compared to threads?

    1. Crashing one process does not directly affect others due to separate memory space.
    2. Processes always have higher priority in the OS scheduler.
    3. Threads are always blocked if any thread dies.
    4. Processes can only execute kernel code, making them safer.
    5. Threads cannot be paused by the OS.
  10. Use Case: Video Encoding

    A video encoding application needs to process several videos independently at the same time, with minimal data sharing. Which parallelism model is most appropriate?

    1. Launch each encoding job as a separate process.
    2. Create threads that all write to the same video file.
    3. Run all jobs in a single thread with time slicing.
    4. Spawn threads within a single process for all jobs.
    5. Share the same memory-mapped file between threads and processes.