Get ahead with a $300 test prep scholarship
| Enter to win by Tuesday 9/24
Terms in this set (9)
1. What is a thread?
A thread is an execution of code as a part of a process. A process can be single-threaded - only one path of execution, or multi-threaded - multiple paths of execution.
2. What is the PCB like for a multi-threaded process?
a. The PCB has only one block of memory for Code, Data, File. Used by all threads.
b. The PCB also has multiple thread entries. Each entry for a thread has Program Counter, registers, stack
3. List and describe the benefits of multi-threading? (provide several sentences on each benefit)
a. Responsiveness - a multi-threaded application can continue to run even if one thread is blocked or takes a long time, so for example the application can still accept user input.
b. Resource Sharing - processes can only share resources through processes explicitly arranged by the programmer, with thread the programmer does not have to do this because they are shared by default.
c. Economy - create a process is more expensive in time and memory than creating a thread.
d. Scalability - have a program designed to use multiple threads allows it to take advantage of the available CPU power in multiple CPUs or multiple cores.
4. List and describe five programming challenges listed in the book for of multi-threading?
a. Identifying Tasks - It is not easy to design a program/algorithm that can broken into separate piece that can be executed in parallel.
b. Balance - It is not easy to design a set of task that can be done in parallel that are of the same size so they all finish about the same time or of the same value so it is worth splitting them up.
c. Data Splitting - It is not easy to determine how to split up the data so each task can work on a separate set of data.
d. Data dependence - It is not easy to determine the dependency of each process on data so that the data is ready when the task needs the data.
e. Testing and Debugging - It is not easy to test multiple tasks running at the same time or that have many more execution paths, or that require synchronization. Test case creation for this is more difficult.
5. List and describe two types of parallelism
a. Data parallelism - divide the work up based on doing the same task to different sets of data.
b. Task Parallelism - divide the work up into separated different unique tasks that can be done in parallel.
6. List and describe (tell issues with) three models of mapping application threads to kernel threads
a. Many to One - where all the thread in the process use the same kernel thread. If one thread needs a kernel function then all the other threads that need a kernel function are blocked, but you don't have to have lots of kernel threads.
b. One to One - where all the threads in the process get their own Kernel thread. There is no blocking between threads but you have to have lots of Kernel threads and creating them is overhead.
c. Many to Many - where all the threads in the process use one of a fixed number of Kernel threads (pool). This provides a nice balance between blocking and overhead issues. However this is much more complex to implement
i. Two level - version of many to many but allows a application thread to be bound to a kernel thread.
7. List and describe five threading issues
a. Fork and exec - what resources should be shared or duplicated on fork, options to share all or duplicate all. Should all threads be duplicated?
b. Signal Handling - which thread should receive the signals, options are to deliver to a specific thread, every thread or threads that are interested.
c. Thread Cancellation - when and how do you cancel a thread, asynchronously does immediate termination, differed the thread is responsible to check to see if it should be terminated
d. Thread Local Storage - should the thread have its own local storage, this is like static data for a thread
e. Scheduler Activations - how to communicate between threads and the kernel, how are user threads attached to kernel threads. Often us a lightweight process data structure to make the connection.
8. Determine if the following programs exhibit task or data parallelism: (4.13)
a. Multi-threaded statistical program described in Exercise 4.21
i. Task - multiple threads doing different things
b. Multi-threaded Sudoku validator describe in Project 1 in this chapter.
i. Task - multiple threads doing different things
ii. Data - multiple threads doing the same thing on different data
c. Multi-threaded sorting program describe in Project 2 in this chapter.
i. Data - each task does the same thing on different data
d. Multi-threaded web server described in section 4.1.
i. Task - multiple task doing different things
ii. Data - each request
9. Consider a multi-core system and a multi-threaded program written using the mana-to-many threading model. Let the number of user-level threads in the program be greater than the number of processing cores in the system. Discuss the performance implications of the following scenarios. (4.18)
a. The number of kernel threads allocated to the program is less than the number of processing cores.
i. Means that some executing threads may have to wait to get a kernel process when needed. Would slow the system.
b. The number of kernel threads allocated to the program is equal to the number of processing cores.
i. Means that all executing process will have a kernel thread they can access when needed. But when a kernel thread is blocked then the next thread that get schedules it will not have a kernel thread available and it could execute but will have to wait. So this too will slow performance
c. The number of kernel threads allocated to the program is greater than the number of processing cores but less than the number of user-level threads.
i. Means that all executing threads and others will have assigned kernel threads so it increase the likelihood that an executing thread will have a kernel thread to use when needed. This will improve performance.
YOU MIGHT ALSO LIKE...
Test Preparation TOEIC, SAT, TOEFL, GRE
[SYCS 401] HW4 - Threads
Chapter 4 Threads
CPE 453 Chapter 4
OTHER SETS BY THIS CREATOR
Region VI Muscles
Lab Exam 1