Chapter 3: Processes Threads Resources Flashcards

1
Q
\_\_\_\_ is a thread library for Solaris that maps many user-level threads to one kernel thread.
A) Pthreads 
B) Green threads 
C) Sthreads 
D) Java threads
A

B- GREEN THREADS

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

Pthreads refers to ____.
A) the POSTFIX standard.
B) an implementation for thread behavior.
C) a specification for thread behavior.
D) an API for process creation and synchronization

A

C- A SPECIFICATION FOR THREAD BEHAVIOR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
The \_\_\_\_ multithreading model multiplexes many user-level threads to a smaller or equal number of kernel threads.
A) many-to-one model 
B) one-to-one model 
C) many-to-many model
D) many-to-some model
A

C- MANY-TO-MANY MODEL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
Cancellation points are associated with \_\_\_\_ cancellation.
A) asynchronous 
B) deferred 
C) synchronous 
D) non-deferred
A

B- DEFERRED

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

Which of the following would be an acceptable signal handling scheme for a multithreaded program?
A) Deliver the signal to the thread to which the signal applies.
B) Deliver the signal to every thread in the process.
C) Deliver the signal to only certain threads in the process.
D) All of the above

A

D- ALL OF THE ABOVE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
Signals can be emulated in windows through \_\_\_\_.
A) asynchronous procedure calls  
B) local procedure calls 
C) remote procedure
D) none of the above
A

A- ASYNCHRONOUS PROCEDURE CALLS

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

Thread-specific data is data that ____.
A) is not associated with any process
B) has been modified by the thread but not yet updated to the parent process
C) is generated by the thread independent of the thread’s process
D) is copied and not shared with the parent process

A

D- IS COPIED AND NOT SHARED W/THE PARENT PROCESS

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

LWP is ____.
A) short for lightweight processor
B) placed between system and kernel threads
C) placed between user and kernel threads
D) common in systems implementing one-to-one multithreading models

A

C- PLACED BETWEEN USER AND KERNEL THREADS (LIGHTWEIGHT PROCESS)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Windows XP uses the \_\_\_\_.
A) one-to-one model 
B) many-to-one model 
C) one-to many-model
D) many-to-many model
A

A- ONE-TO-ONE MODEL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
In multithreaded programs, the kernel informs an application about certain events using a procedure known as a(n) \_\_\_\_.
A) signal 
B) upcall 
C) event handler 
D) pool
A

B- UPCALL

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

Why should a web server not run as a single-threaded process?

A

For a web server that runs as a single-threaded process, only one client can be serviced at a time. This could result in potentially enormous wait times for a busy server.

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

List the four major categories of the benefits of multithreaded programming. Briefly explain each

A

The benefits of multithreaded programming fall into the categories: responsiveness, resource sharing, economy, and utilization of multiprocessor architectures. Responsiveness means that a multithreaded program can allow a program to run even if part of it is blocked. Resource sharing occurs when an application has several different threads of activity within the same address space. Threads share the resources of the process to which they belong. As a result, it is more economical to create new threads than new processes. Finally, a single threaded process can only execute on one processor regardless of the number of processors actually present. Multiple threads can run on multiple processors, thereby increasing efficiency

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

What are the two different ways in which a thread library could be implemented?

A

The first technique of implementing the library involves ensuring that all code and data structures for the library reside in user space with no kernel support. The other approach is to implement a kernel-level library supported directly by the operating system so that the code and data structures exist in kernel space

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

Describe two techniques for creating Thread objects in Java

A

One approach is to create a new class that is derived from the Thread class and to override its run() method. An alternative – and more commonly used – technique is to define a class that implements the Runnable interface. When a class implements Runnable, it must define a run() method. The code implementing the run() method is what runs as a separate thread

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

In Java, what two things does calling the start() method for a new Thread object accomplish?

A

Calling the start() method for a new Thread object first allocates memory and initializes a new thread in the JVM. Next, it calls the run() method, making the thread eligible to be run by the JVM. Note that the run() method is never called directly. Rather, the start() method is called, which then calls the run() method.

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

Some UNIX systems have two versions of fork(). Describe the function of each version, as well as how to decide which version to use.

A

One version of fork() duplicates all threads and the other duplicates only the thread that invoked the fork() system call. Which of the two versions of fork() to use depends on the application. If exec() is called immediately after forking, then duplicating all threads is unnecessary, as the program specified in the parameters to exec() will replace the process.

vfork(): The vfork() function also creates a new child process, but it differs from fork() in one important aspect. In vfork(), the child process shares the memory space with the parent process until it calls either exec() or _exit(). This means the child process executes in the same memory space as the parent, without duplicating the entire memory.
vfork() is useful when the child process intends to immediately call exec() to load a new program. Since vfork() does not create a separate memory space, it avoids the overhead of duplicating memory, which can be significant for large processes.

17
Q

How can deferred cancellation ensure that thread termination occurs in an orderly manner as compared to asynchronous cancellation?

A

In asynchronous cancellation, the thread is immediately cancelled in response to a cancellation request. There is no insurance that it did not quit in the middle of a data update or other potentially dangerous situation. In deferred cancellation, the thread polls whether or not it should terminate. This way, the thread can be made to cancel at a convenient time

18
Q

What is a thread pool and why is it used?

A

A thread pool is a collection of threads, created at process startup, that sit and wait for work to be allocated to them. This allows one to place a bound on the number of concurrent threads associated with a process and reduce the overhead of creating new threads and destroying them at termination

19
Q

In Windows XP, what are the general components of a thread?

A

he thread consists of a unique ID, a register set that represents the status of the processor, a user stack for user mode, a kernel stack for kernel mode, and a private storage area used by run-time libraries and dynamic link libraries.

20
Q

Describe the difference between the fork() and clone() Linux system calls.

A

The fork() system call is used to duplicate a process. The clone() system call behaves similarly except that, instead of creating a copy of the process, it creates a separate process that shares the address space of the calling process.

With clone(), the programmer can specify which resources to share between the parent and child processes, unlike fork(), where all resources are duplicated. This level of control enables customized process creation for specific requirements.

21
Q
 A traditional (or heavyweight) process has a single thread of control (T/F)
A

TRUE

22
Q

A thread is composed of a thread ID, program counter, register set, and heap. (T/F)

A

FALSE

Stack: Each thread has its own stack, which is used to store local variables, function call information, and return addresses. The stack grows and shrinks dynamically as functions are called and return.

The heap, on the other hand, is a region of memory used for dynamic memory allocation. It is typically shared among threads within a process and is not exclusive to any particular thread

23
Q

Virtually all contemporary operating systems support kernel threads. (T/F)

A

TRUE

24
Q

Linux distinguishes between processes and threads (T/F)

A

FALSE

Linux treats both in the same way allowing a task to be more akin to a process or a thread depending on the set of flags passed to the clone() system call. However, other operating systems, such as Windows, treat processes and threads differently.

25
Q

In Java, data shared between threads is simply declared globally (T/F)

A

FALSE

Declaring data as global variables can lead to concurrency issues and data races, where multiple threads try to access or modify shared data simultaneously, resulting in unpredictable and incorrect behavior.