1. Home
  2. Explore
  3. Computer Science
  4. Parallel Computing

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Parallel Computing

  • 49Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Parallelization Basics

If one person takes 10 days to complete a job, how long would 10 people take if they divide the work evenly and work in parallel?

49 questions

  1. 1

    If one person takes 10 days to complete a job, how long would 10 people take if they divide the work evenly and work in parallel?

    1. A

      Two days

    2. B

      Five days

    3. C

      One day

    4. D

      Ten days

    Correct answer
    C

    One day

    Explanation

    Each person can complete one-tenth of the job in 10 days, so the ten portions can be completed together in one day.

  2. 2

    What is the main purpose of parallelization in a computer system?

    1. A

      To replace a program's instructions with a smaller set of instructions

    2. B

      To ensure that every computing entity executes the entire job independently

    3. C

      To divide a large job among computing entities that work simultaneously

    4. D

      To make one computing entity perform every part of a job in sequence

    Correct answer
    C

    To divide a large job among computing entities that work simultaneously

    Explanation

    Parallelization divides a larger job into smaller portions that computing entities can execute at the same time, reducing completion time.

  3. 3

    Why can a GPU help complete certain large jobs quickly?

    1. A

      It can perform thousands of small tasks in parallel

    2. B

      It guarantees that each task uses a different process

    3. C

      It assigns every task to a separate operating system

    4. D

      It eliminates the need to divide work into smaller tasks

    Correct answer
    A

    It can perform thousands of small tasks in parallel

    Explanation

    The content describes GPUs as hardware capable of performing thousands of tasks in parallel, with each task contributing a small part of a larger job.

  4. 4

    A program runs as one process on a system with four processors. What may happen if the process contains only one sequential execution path?

    1. A

      It may run on one processor while the other processors remain unused by that program

    2. B

      It automatically divides itself into four independent processes

    3. C

      It alternates each instruction among all four processors

    4. D

      It must run on all four processors because they are available

    Correct answer
    A

    It may run on one processor while the other processors remain unused by that program

    Explanation

    The scheduler may assign the single process to one processor. Without parallel execution paths, the program does not automatically use all four processors for its work.

  5. 5

    How does dividing a 10-million-number summation among four workers enable parallel work?

    1. A

      Each worker sums the complete range independently

    2. B

      Each worker sums a distinct quarter of the range

    3. C

      Each worker waits for the previous worker to finish the full range

    4. D

      Each worker handles one number while the others remain idle

    Correct answer
    B

    Each worker sums a distinct quarter of the range

    Explanation

    The example divides the numbers into four sets of 2.5 million, so each worker can calculate a separate partial sum.

  6. 6

    If four equally sized portions of a job run at the same time on four processors, what speedup does the example expect?

    1. A

      The job must finish twice as fast

    2. B

      The job takes four times longer

    3. C

      The job may finish four times faster

    4. D

      The job's completion time cannot change

    Correct answer
    C

    The job may finish four times faster

    Explanation

    The example suggests that four processors handling four equal portions in parallel could complete the overall job four times faster.

  7. 7

    Which sequence describes how the example program becomes a running process?

    1. A

      A processor turns source code directly into a thread without an executable

    2. B

      The scheduler creates an executable, which a compiler runs as a process

    3. C

      A compiler creates an executable, which is then run to create a process

    4. D

      A process creates the compiler, which then generates an operating system

    Correct answer
    C

    A compiler creates an executable, which is then run to create a process

    Explanation

    The described sequence is to compile the program, such as with gcc, to produce an executable and then run that executable to create a process.

  8. 8

    Why might a process sometimes run on a different processor from the one to which it was initially assigned?

    1. A

      Its memory space is automatically copied into a new process

    2. B

      The process may migrate to another processor during execution

    3. C

      Its instructions are replaced whenever the scheduler runs

    4. D

      It must move processors after every function call

    Correct answer
    B

    The process may migrate to another processor during execution

    Explanation

    The content notes that a process may rarely migrate to another processor, although the example sets that possibility aside.

  9. 9

    In the process-based version of the summation example, how many fork system calls are needed to create four worker processes?

    1. A

      Two

    2. B

      Eight

    3. C

      One

    4. D

      Four

    Correct answer
    D

    Four

    Explanation

    The example states that creating the four processes requires four fork system calls, with each call creating one process.

  10. 10

    What is a key memory property of the four processes used in the process-based approach?

    1. A

      Each shares its entire memory map with every other process

    2. B

      Only the first process has instructions, data, heap, and stack

    3. C

      All four necessarily use one shared stack and one shared heap

    4. D

      Each has its own instructions, data, heap, and stack

    Correct answer
    D

    Each has its own instructions, data, heap, and stack

    Explanation

    Processes are isolated execution entities, each with its own instructions, data, heap, and stack.

  11. 11

    Why do separate worker processes need an interprocess communication mechanism to exchange results?

    1. A

      The operating system prevents processes from returning values

    2. B

      They cannot execute on different processors

    3. C

      Their memory spaces are isolated from one another

    4. D

      They do not have their own instructions

    Correct answer
    C

    Their memory spaces are isolated from one another

    Explanation

    Because each process has an isolated memory space, processes need IPC techniques to communicate with one another.

  12. 12

    Which pair of approaches is identified as a way for processes to communicate?

    1. A

      Thread stacks, or processor migration

    2. B

      Register saving, or changing the active page table

    3. C

      Message passing with send and receive, or shared memory

    4. D

      Function calls, or the compiler's executable output

    Correct answer
    C

    Message passing with send and receive, or shared memory

    Explanation

    The content describes IPC through send-and-receive message passing and through shared memory created using system calls.

  13. 13

    How does the operating system participate in the described send-and-receive IPC method?

    1. A

      It changes each message into a separate executable

    2. B

      It helps create a channel through which processes communicate

    3. C

      It combines the processes into one shared execution context

    4. D

      It copies each process's stack into the sender's registers

    Correct answer
    B

    It helps create a channel through which processes communicate

    Explanation

    For message passing, the operating system helps create a channel that enables communication between processes.

  14. 14

    Why do process creation, destruction, and file operations involve system calls?

    1. A

      They are operations that can only be performed by a thread stack

    2. B

      These are process-management activities handled through operating-system services

    3. C

      They are forms of parallel work that require a separate processor

    4. D

      They are instructions that every process must copy into its heap

    Correct answer
    B

    These are process-management activities handled through operating-system services

    Explanation

    The content identifies process creation, destruction, and file operations as management activities carried out through system calls.

  15. 15

    What happens when a process invokes a system call, according to the described mechanism?

    1. A

      The process immediately turns into a thread without operating-system involvement

    2. B

      The processor duplicates the process's data and resumes without a handler

    3. C

      A software trap triggers operating-system execution and the relevant handler runs

    4. D

      The system call is executed only after all other processes terminate

    Correct answer
    C

    A software trap triggers operating-system execution and the relevant handler runs

    Explanation

    A system call causes a software trap, after which the operating system identifies the call and executes its corresponding handler.

  16. 16

    Why can using several similar processes create unnecessary duplication?

    1. A

      The processes may repeat the same instructions and access the same data

    2. B

      Each process performs only operating-system work rather than the job

    3. C

      Each process must use a different program and different global data

    4. D

      The processes share all of their memory, so every instruction is skipped

    Correct answer
    A

    The processes may repeat the same instructions and access the same data

    Explanation

    The example notes that processes doing similar work can duplicate instructions and data, such as a shared array or global data.

  17. 17

    What is the central idea of using threads instead of four processes for the summation?

    1. A

      Use one process containing four execution entities that divide the work

    2. B

      Use one thread that performs four sequential copies of the entire job

    3. C

      Use four processes, each containing a separate copy of the operating system

    4. D

      Use four processors without creating any execution entities

    Correct answer
    A

    Use one process containing four execution entities that divide the work

    Explanation

    The thread-based approach creates one process and four threads within it, with each thread handling one quarter of the work.

  18. 18

    Which description best captures how threads within one process share resources?

    1. A

      They share the process's code, global data, heap, and open files

    2. B

      They share only their stacks, while keeping separate heaps and code

    3. C

      They share the processor but cannot access the process's data

    4. D

      They each have separate copies of the process's code and global data

    Correct answer
    A

    They share the process's code, global data, heap, and open files

    Explanation

    Threads in one process share its code, global data, heap, and open files.

  19. 19

    Which resource distinguishes one thread from another within the same process?

    1. A

      Its own set of open files

    2. B

      Its own copy of the global data segment

    3. C

      Its own process-wide heap

    4. D

      Its own stack

    Correct answer
    D

    Its own stack

    Explanation

    Each thread has its own stack, while the threads share the process's code, data, heap, and open files.

  20. 20

    Why does each thread need its own stack?

    1. A

      The stack supports thread-specific local variables and function-call information

    2. B

      The stack stores the process's shared global data for all threads

    3. C

      The stack gives the thread a separate copy of every open file

    4. D

      The stack lets the thread execute without being attached to a process

    Correct answer
    A

    The stack supports thread-specific local variables and function-call information

    Explanation

    A thread's own stack provides space for its local variables and information about its function calls.

  21. 21

    What is included in a thread's execution context as described in the content?

    1. A

      A separate process identifier, heap, and complete page table

    2. B

      Register values, including the EIP and ESP, along with its stack

    3. C

      The code segment and every other thread's stack

    4. D

      Only the shared global data and open files of the process

    Correct answer
    B

    Register values, including the EIP and ESP, along with its stack

    Explanation

    The thread's execution context includes its stack and register values, with EIP and ESP given as examples of registers.

  22. 22

    How can threads in one process be scheduled on a multiprocessor system?

    1. A

      They must each create a separate process before being scheduled

    2. B

      They must all run on the same processor at the same time

    3. C

      They can run only on the processor that first ran the process

    4. D

      They may run on different processors or take turns on the same processor

    Correct answer
    D

    They may run on different processors or take turns on the same processor

    Explanation

    Threads may be scheduled on different processors, or multiple threads may take turns running on the same processor at different times.

  23. 23

    Which statement correctly describes the relationship between a thread and a process?

    1. A

      A thread must belong to a process, while a process can execute with one thread

    2. B

      A process must belong to a thread, while a thread can execute alone

    3. C

      A thread and a process are both independent of any other execution entity

    4. D

      A process cannot execute unless it contains at least four threads

    Correct answer
    A

    A thread must belong to a process, while a process can execute with one thread

    Explanation

    A thread cannot execute on its own and must be attached to a process. A process can execute with a single thread.

  24. 24

    What happens to a process's threads when the process terminates?

    1. A

      All threads belonging to that process also terminate

    2. B

      The threads move automatically into another process

    3. C

      The threads continue running as independent processes

    4. D

      Only the thread with the lowest identifier terminates

    Correct answer
    A

    All threads belonging to that process also terminate

    Explanation

    Threads depend on their process, so termination of the process also terminates all its threads.

  25. 25

    What happens when one thread terminates but its process remains active?

    1. A

      The entire process must terminate, but the thread's stack remains in use

    2. B

      All remaining threads become separate processes with copied stacks

    3. C

      The remaining threads can continue, and the terminated thread's stack is reclaimed

    4. D

      The process must restart every thread before doing any further work

    Correct answer
    C

    The remaining threads can continue, and the terminated thread's stack is reclaimed

    Explanation

    A thread can terminate while the process and its other threads continue. The terminated thread's stack is reclaimed.

  26. 26

    What comparison does the example give for creating 50,000 processes versus 50,000 threads on one machine?

    1. A

      Creating the processes took 8.1 units of time, while creating the threads took 0.9

    2. B

      Creating the processes took 0.9 units of time, while creating the threads took 8.1

    3. C

      Both creation operations took 8.1 units of time

    4. D

      Both creation operations took 0.9 units of time

    Correct answer
    A

    Creating the processes took 8.1 units of time, while creating the threads took 0.9

    Explanation

    For one machine in the comparison, creating 50,000 processes took 8.1 units of time, while creating 50,000 threads took 0.9, illustrating the lower creation cost of threads.

  27. 27

    Why is communication between threads in the same process usually simpler than communication between separate processes?

    1. A

      Threads communicate only by changing the active page table

    2. B

      Threads have separate memory spaces that require no coordination

    3. C

      Threads can communicate through shared global data or the shared heap

    4. D

      Threads automatically send operating-system messages for every variable

    Correct answer
    C

    Threads can communicate through shared global data or the shared heap

    Explanation

    Threads in one process can access its shared global data and heap, allowing communication without the IPC mechanisms needed between isolated processes.

  28. 28

    Why can process-based message passing add communication overhead?

    1. A

      Each message requires a separate processor to be created

    2. B

      Each send operation duplicates every process's stack

    3. C

      Each send and receive operation is a system call

    4. D

      Message passing prevents the operating system from running

    Correct answer
    C

    Each send and receive operation is a system call

    Explanation

    The content notes that send and receive operations for message-passing IPC are system calls and therefore have overhead.

  29. 29

    Why can setting up shared-memory IPC between processes still involve overhead?

    1. A

      Shared memory requires every process to use a separate thread stack

    2. B

      Creating and managing the shared memory requires system calls

    3. C

      Shared memory cannot be used for communication between processes

    4. D

      Processes must duplicate all instructions after each shared-memory access

    Correct answer
    B

    Creating and managing the shared memory requires system calls

    Explanation

    Although shared memory enables communication, creating and managing it between processes is done through system calls and has overhead.

  30. 30

    Why can switching between threads of one process be faster than switching between processes?

    1. A

      A thread switch always terminates the previously running thread

    2. B

      Threads have no execution context and require no register values

    3. C

      A thread's context is smaller, so less state needs to be saved and restored

    4. D

      Process switching never involves saving any execution state

    Correct answer
    C

    A thread's context is smaller, so less state needs to be saved and restored

    Explanation

    A thread has a smaller execution context than a process, so switching between threads requires saving and restoring less state.

  31. 31

    What memory-management advantage can a context switch between threads in one process have?

    1. A

      The operating system must replace the process's code segment

    2. B

      The thread switch requires every TLB entry to be discarded

    3. C

      Each thread activates a newly created page table

    4. D

      The same page tables remain active, so a page-table change is unnecessary

    Correct answer
    D

    The same page tables remain active, so a page-table change is unnecessary

    Explanation

    Threads in the same process use the same process page tables, so switching between them does not require changing the active page tables.

  32. 32

    How does keeping the same page tables during a thread switch affect the TLB?

    1. A

      Cached TLB entries can remain valid because the address space has not changed

    2. B

      The TLB becomes unnecessary because threads have no memory accesses

    3. C

      The TLB must be flushed whenever a thread changes its stack

    4. D

      Every cached TLB entry must be replaced by entries from another process

    Correct answer
    A

    Cached TLB entries can remain valid because the address space has not changed

    Explanation

    Since the threads share one process address space, the page tables do not change during a thread switch, so cached TLB entries remain valid.

  33. 33

    Which contrast between a process and a thread is accurate?

    1. A

      A thread has its own heap and data, while its process shares the thread's stack

    2. B

      A process shares its code with other processes, while a thread owns separate code

    3. C

      A process and each of its threads have entirely separate memory maps

    4. D

      A process has its own data and heap, while its threads use those shared process regions

    Correct answer
    D

    A process has its own data and heap, while its threads use those shared process regions

    Explanation

    A process has its own memory regions, including data and heap; threads within it share those process regions but have their own stacks.

  34. 34

    Which function is used by the pthread library to create a thread?

    1. A

      pthread_exit

    2. B

      pthread_create

    3. C

      pthread_join

    4. D

      fork

    Correct answer
    B

    pthread_create

    Explanation

    The pthread library uses pthread_create to create a new thread context in a process.

  35. 35

    What is the purpose of the first argument to pthread_create?

    1. A

      To provide the return value of a thread that has exited

    2. B

      To specify the function that the new thread will execute

    3. C

      To select the processor on which the thread must run

    4. D

      To provide a location for the new thread's identifier

    Correct answer
    D

    To provide a location for the new thread's identifier

    Explanation

    The first argument is a pointer to a pthread_t variable that receives the newly created thread's identifier, or TID.

  36. 36

    What information can the attributes argument to pthread_create specify?

    1. A

      The return status of a thread that has already exited

    2. B

      The final sum computed by the thread

    3. C

      The process identifier of the calling process

    4. D

      Properties of the thread being created

    Correct answer
    D

    Properties of the thread being created

    Explanation

    The attributes argument can specify various properties of the thread being created.

  37. 37

    What does the start-routine argument to pthread_create identify?

    1. A

      A function from which the new thread begins executing

    2. B

      A system call that destroys the calling process

    3. C

      A shared-memory channel between two processes

    4. D

      A thread identifier to wait for before creating the thread

    Correct answer
    A

    A function from which the new thread begins executing

    Explanation

    The start routine is a function pointer, and the newly created thread begins execution in that function.

  38. 38

    What is the role of the final argument to pthread_create?

    1. A

      It provides the argument passed to the start-routine function

    2. B

      It stores the thread's identifier after the thread exits

    3. C

      It selects the thread's private heap

    4. D

      It specifies which process will be terminated

    Correct answer
    A

    It provides the argument passed to the start-routine function

    Explanation

    The final argument is a pointer to the arguments supplied to the start routine.

  39. 39

    Which pthread function is used to terminate a thread and provide its return status?

    1. A

      pthread_create

    2. B

      pthread_exit

    3. C

      pthread_join

    4. D

      send

    Correct answer
    B

    pthread_exit

    Explanation

    A thread can use pthread_exit to terminate and pass a pointer to its return value or status.

  40. 40

    What does pthread_join do when given a thread identifier?

    1. A

      It blocks the calling thread until the specified thread exits

    2. B

      It creates a new thread with the specified identifier

    3. C

      It immediately terminates the specified thread

    4. D

      It copies the specified thread's stack into the calling thread

    Correct answer
    A

    It blocks the calling thread until the specified thread exits

    Explanation

    pthread_join waits for the thread identified by its argument; the calling thread blocks until that thread exits.

  41. 41

    After the thread specified to pthread_join exits, what can the calling thread obtain?

    1. A

      A new process identifier for the exited thread

    2. B

      The exited thread's status or return value

    3. C

      The processor's next scheduling decision

    4. D

      A separate copy of the exited thread's heap

    Correct answer
    B

    The exited thread's status or return value

    Explanation

    When the specified thread exits, pthread_join completes and can provide the thread's exit status.

  42. 42

    In the four-thread summation example, why are four pthread_t variables declared?

    1. A

      To hold the identifiers of the four created threads

    2. B

      To provide four separate heaps for the process

    3. C

      To identify four different start-routine functions

    4. D

      To store the four partial sums before they are calculated

    Correct answer
    A

    To hold the identifiers of the four created threads

    Explanation

    The variables t1, t2, t3, and t4 are used by pthread_create to receive the identifiers of the four newly created threads.

  43. 43

    In the example, what does passing a different argument to each thread's start routine accomplish?

    1. A

      It assigns each thread a separate process and address space

    2. B

      It gives each thread a different copy of the program's code

    3. C

      It tells each thread which other thread must terminate first

    4. D

      It lets the shared routine identify which portion of the numbers that thread should sum

    Correct answer
    D

    It lets the shared routine identify which portion of the numbers that thread should sum

    Explanation

    Each thread runs the same start routine, but its argument identifies its portion of the summation work.

  44. 44

    What does the example's global sum array store?

    1. A

      The return status of the main process

    2. B

      A separate partial sum computed by each thread

    3. C

      A separate process identifier for each worker

    4. D

      A copy of every number in the full range

    Correct answer
    B

    A separate partial sum computed by each thread

    Explanation

    The global array has four elements, and each thread stores its partial sum in the element assigned to it.

  45. 45

    Why can the four threads write their partial sums to the shared global array?

    1. A

      The operating system merges separate process arrays automatically

    2. B

      Each thread has a private copy of the global array

    3. C

      Threads in one process can access that process's global data

    4. D

      The array is stored only in the thread identifiers

    Correct answer
    C

    Threads in one process can access that process's global data

    Explanation

    Threads in one process share access to the process's global data, allowing each to write its result to the shared array.

  46. 46

    Why does the main thread call pthread_join for each worker thread?

    1. A

      To create a replacement thread for each worker

    2. B

      To ensure every partial sum is ready before calculating the final result

    3. C

      To divide each partial sum into smaller portions

    4. D

      To stop the workers before they begin their calculations

    Correct answer
    B

    To ensure every partial sum is ready before calculating the final result

    Explanation

    Each join waits for its worker to finish, ensuring the partial sums are complete before the main thread adds them.

  47. 47

    How does the example produce the final sum after all worker threads finish?

    1. A

      It adds the four partial sums stored in the shared array

    2. B

      It repeats the full range once for each thread

    3. C

      It adds the thread identifiers together

    4. D

      It takes the result from only the first thread

    Correct answer
    A

    It adds the four partial sums stored in the shared array

    Explanation

    Once all four joins complete, the program adds the four partial sums to obtain the sum of the full range.

  48. 48

    What is needed when compiling the pthread example with gcc, as described?

    1. A

      The pthread library must be linked, for example with -lpthread

    2. B

      The program must be compiled once for every thread

    3. C

      The compiler must be replaced by the operating system scheduler

    4. D

      The fork library must be linked instead of the pthread library

    Correct answer
    A

    The pthread library must be linked, for example with -lpthread

    Explanation

    The example compiles with gcc and links the pthread library using an option such as -lpthread.

  49. 49

    Which set lists other threading libraries or library families mentioned in the content?

    1. A

      Fork, send-and-receive, and shared memory

    2. B

      Pthread, gcc, and the process scheduler

    3. C

      Windows threads, Boost, and Linux threads

    4. D

      EIP, ESP, and the translation lookaside buffer

    Correct answer
    C

    Windows threads, Boost, and Linux threads

    Explanation

    Besides pthreads, the content mentions the Windows threads library, Boost for C++, and Linux threads.

Question 1 of 49
Question 1 of 49

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent