Friday 28 June 2013

Chapter 13 of Concept of Programming Languages

Review Questions : 

7. What is the difference between physical and logical concurrency?
 Several program units from the same program executes simultaneously, this is called physical concurrency, while logical concurrency the actual execution of program is taking place in interlaved fashion on a single processor

8. What is the work of a scheduler?
 A scheduler manages the sharing of processors among the tasks.

9. Give some examples of languages which can be used for synchronization
 Ada, Java, C#, F#, Python

10. When a task in a blocked state?
 A task that is blocked has been running, but that execution was interrupted by one of several different events, the most common of which is an input or output operation.

18. What is the purpose of a task-ready queue?
  a ready task is ready to run but is not currently running, either it has not been given processor time by the scheduler, or it had run previously but was blocked

19. What are the two primary design issues for language support for concurrency?
 Competition and cooperation synchronization

20. Describe the actions of the wait and release operations for semaphores
 The wait semaphore subprogram is used to test the counter of a given semaphore variable. The release semaphore subprogram is used by a task to allow some other task to have one of whatever the counter of the specified semaphore variable counts

34. What does the Java sleep method do?
 Sleep method specify the number of milliseconds the thread want to be blocked and block the thread for that amount of milliseconds

35. What does the Java yield method do?
 Join method is used to force a method to delay its execution until the run method of another thread has completed its execution

36. What does the Java join method do?
  The join method puts the thread that calls it in the blocked state, which can be ended only by the completion of the thread on which join was called.

37. What does the Java interrupt method do?
 The interrupt method is one way to communicate to a thread that it should stop

48. What kind of methods can run in a C# threads?
 Any C# method can run in its own thread

49. Can C# threads be actor threads, server threads, or either?
 C# support both actor and server threads.

55. What is Concurrent ML?
 Concurrent 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 spawn primitive of CML?
 Creating a thread in CML

____________________________________________________________________________________________________________________________________

Problem Set  :


2. What are the different ways to handle deadlock?
 Deadlock handling :
  • Ignoring deadlock
  • Detection : Process Terimnation and Resource preemption
  • Prevention : preventing one of the four Coffman conitions from occuring
  • Avoidance

3. Busy waiting is a method whereby a task waits for a given event by continuously checking for that 
 event to occur. What is the main problem with this approach?
The main problem would be the CPU resources that area allocated to the waiting for the task, if it were to be suspended, the CPU can then be used for other purposes

No comments:

Post a Comment