Вы находитесь на странице: 1из 3

Answer to Tutorial Thread Concept 1.

.What key advantage is there by running a multithreaded application on a multiprocessor system than running it on a uniprocessor system? The key advantage is that multiple threads of the application which performs parallel tasks could run simultaneously on separate processors thus speeding application execution. 2. Why are traditional process called heavyweight processes? The main distinction is that the address spaces are allocated differently when a process is created; it is allocated its own address space. When a thread is created, it shares the process address space. Thus the threads are lighter weight and processes are heavy weight. 3. Why is it difficult to write portable multithreaded applications? This is difficult because there is no standard threading library that is implemented on all platforms. 4. How does improved software design help to make multithreaded applications execute faster? Many applications contain segments of code which can execute independently of one another. When their segments of code are assigned to separate threads, they can execute on multiple processors simultaneously. 5. Why is it typically more efficient for threads of the same process to communicate than it is for separate processes to communicate? Thread of the same process can communicate via their shared address space and do not have to rely on an Interprocess Communication (IPC) mechanism that involve the kernel. 6. How can a thread enter the dead state? A thread enters the dead state when it completes its tasks or when another thread terminates it. 7. How are the waiting, blocked and sleeping states similar? How are they different? Similar in the sense that the threads in them could not use a processor, even if one is available. A blocked thread cannot be dispatch because it is waiting on an I/O operation that it requested. Here the OS is responsible for ensuring that it eventually unblocks the thread. A waiting thread cannot be dispatched until it receives an event from the hardware or software that the OS does not initiate. Here the OS cannot control whether or when a waiting thread will eventually be awarded. A sleeping thread cannot execute because it has notify the system that it should not execute until its sleep interval expires. 8. Why does thread creation typically require fewer processor cycles than process creation? Unlike process creation, thread creation requires that the OS initialize only resources that are local to the thread of control. Global resources can be shared using pointers which requires fewer processor cycles than initialization. 9. Explain why user-level thread implementations promote portability? User level threads present an API to application that is independent of the OS API; thus can be portable to different platforms.

Qu.10 In many-to-one threads mappings, why does the OS block the entire multi-threaded process when a single thread blocks? To the OS, the entire multithread process is a single thread of control. Therefore when the OS receives a blocking I/O request, it blocks the entire process. 11. In what scenarios are kernel-level threads more efficient than user-level threads? If an application contains a thread that block or that can perform their instructions in parallel, kernel-level thread are more efficient than user-level thread. 12. Why is application software written for kernel-level threads less portable than software written for user-level threads? Application software written using kernel-level threads depend on a particular OS API; application software written using user-level thread depends on the threads API. 13. What is the primary reason to create standard thread interfaces such as Pthreads? Standard threading interface allow applications to be portable which reduces software development time for applications that must operate on multiple platforms. 14. Which threading model does the POSIX standard require? POSIX standard does not require a specific implementation. Here threads can be implemented as user-level thread, kernel thread or hybrid thread. 15. Discuss briefly the thread local storage (TLS) in Windows. A thread can share its address with other threads of that process but hides its private data in its Thread Local Storage (TLS).

Answer to Tutorial - Asynchronous Concurrent Execution Qu.1 Why is it important for a thread to execute a critical section as quickly as possible? If other threads are waiting to execute critical section, they will be delayed from doing so while any thread is in its critical section. If critical section do not execute quickly, the overall system performance could suffer. Qu.2 What might happen if the OS did not perform termination housekeeping? Whenever we consider mutual exclusion algorithm, termination house-keeping is the task performed by the OS to ensure that mutual exclusion is not violated and that threads can continue to execute if a thread terminates while executing its critical section. A thread could terminate while in its critical section and never release mutual exclusion. The thread waiting to enter their critical sections would never be able to enter. These threads will be deadlock. Qu.3 Why is it difficult to predict the relative speeds of asynchronous concurrent threads? Mainly because of hardware interrupts which may be randomly distributed. This can be disrupting thread execution at any time. Over any given time period, these interrupts may allow some threads to execute longer than others. Also, certain algorithms may favor only some kind of thread. Qu.4 How can an improperly coded thread cause indefinite postponement or deadlock? A thread that never left its critical section would eventually indefinitely postpone or deadlock all other threads as they try to enter their critical sections.