Wednesday, June 26, 2013

Concepts of Programming Languages ---- Chapter 13 Concurrency

Concepts of Programming Languages ---- Chapter 13 Concurrency

Name : Fandy Limardi
NIM : 1601210713
Lecture : Tri Djoko Wahjono, Ir., M.Sc. (D0206)
Assignment : Concept of programming languages ---- Chapter 13 Concurrency


Review Questions
1.   What are the three possible levels of concurrency in programs?
·         Instruction level (executing two or more machine instructions simultaneously)
·         Statement level (executing two or more high-level language statements simultaneously)
·         Unit level (executing two or more subprogram units simultaneously)
4.   What level of program concurrency is best supported by SIMD computers?
Statement-level concurrency
5.   What level of program concurrency is best supported by MIMD computers?
      Unit-level concurrency is best supported by MIMD computers.
7.   What is the difference between physical and logical concurrency?
·         Physical concurrency is several program units from the same program that literally execute simultaneously.
·         Logical concurrency is multiple processors providing actual concurrency, when in fact the actual execution of programs is taking place in interleaved fashion on a single processor.
8.   What is the work of a scheduler?
Scheduler manages the sharing of processors among the tasks.
12. What is a heavyweight task? What is a lightweight task?
Heavy weight task executes in its own address space. Lightweight task all run in the same address space.
16. What is a task descriptor?
Task descriptor is a data structure that stores all of the relevant information about the execution state of a task.
21. What is a binary semaphore? What is a counting semaphore?
A binary semaphore is  a semaphore that requires only a binary-valued counter. A counting semaphore is a synchronization object that can have an arbitrarily large number of states.
35. what does the Java yield method do?
The yield method, which takes no parameters, is a request from the running thread to surrender the  voluntarily. The thread is put immediately in the task-ready queue, making it ready to run. The scheduler then chooses the highest-priority thread from the task-ready queue. If there are no other ready threads with priority higher than the one that just yielded the processor, it may also be the next thread to get the processor.
36. What does the Java join method do?
Java forces a method to delay its execution until the run method of another thread has completed its execution.
37. What does the Java interrupt method do?
Interrupt becomes one way to communicate to a thread that it should stop.
42. What kind of Java object is a monitor?
In Java, a monitor can be implemented in a class designed as an abstract data type, with the shared data being the type. Accesses to objects of the class are controlled by adding the synchronized modifier to the access methods.
55. What is Concurrent ML?
ML is an extension to ML that includes a form of threads and a form of synchronous message passing to support concurrency.
56. What is the use of the spawn primitive of CML?
The use of Spawn primitive of CML is to create a thread.
60. What is the type of an F# heap-allocated mutatable variable?
A mutable heap-allocated variable is of type ref

Problem Set
1.   Explain clearly why a race condition can create problems for a system.
Because two or more tasks are racing to use the shared resource and the behavior of the program depends on which task arrives first (and wins the race). The importance of competition synchronization should now be clear.
2.   What are the different ways to handle deadlock?
·         Ignoring deadlock
·         Detection
·         Prevention
·         Avoidance
4.   In the producer-consumer example of Section 13.3, suppose that we incorrectly replaced the release(access) in the consumer process with wait(access). What woud be the result of this error on execution of the system?
      Deadlock would occur if the release(access) were replaced by a wait(access) in the 
       consumer process, because instead of relinquishing access control, the consumer 
       would wait for control that it already had.

No comments:

Post a Comment