• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/6

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

6 Cards in this Set

  • Front
  • Back

Provide two programming examples in which multi-threading provides better performance than a single-threaded solution.

(1) A Web server that services each request in a separate thread.


(2) A parallelized
application such as matrix multiplication where different parts of the matrix may be
worked on in parallel.


(3) An interactive GUI program such as a debugger where a
thread is used to monitor user input, another thread represents the running application,
and a third thread monitors performance.

Describe the actions taken by a kernel to context-switch between kernel level threads.

Context switching between kernel threads typically requires saving the value of the CPU registers fromthe thread being switched out and restoring the CPU registers of the new thread being scheduled.

?What resources are used when a thread is created? How do they differ from those used when a process is created?

A context must be created, including a register set storage location for storage during context switching, and a local stack to record the procedure call arguments, return values, and return addresses, and thread-local storage. A process creation results in memory being allocated for program instructions and data, as well as thread-like storage. Code may also be loaded into the allocated memory.

Provide two programming examples in which multi-threading does not provide better performance than a single-threaded solution.

Any kind of sequential program is not a good candidate to be threaded. An example
of this is a program that calculates an individual tax return. (2) Another example is a
“shell” program such as the C-shell or Korn shell. Such a program must closely
monitor its own working space such as open files, environment variables, and
current working directory.


Under what circumstances does a multi-threaded solution using multiple kernel threads provide better performance than a single-threaded
solution on a single-processor system?

When a kernel thread suffers a page fault, another kernel thread can be switched in to
use the interleaving time in a useful manner. A single-threaded process, on the other
hand, will not be capable of performing useful work when a page fault takes place.
Therefore, in scenarios where a program might suffer from frequent page faults or has
to wait for other system events, a multithreaded solution would perform better even
on a single-processor system.

Can a multi-threaded solution using multiple user-level threads achieve better performance on a multiprocessor system than on a single processor system? Explain.

No. The kernel is not aware of the user-level threads that are created. Therefore, it is not able to run the user-level threads on different processors.