Reference no: EM13963564
Concurrent Access to Objects
This question asks about synchronizing methods for stack and queue objects.
(a) Bounded stacks can be de?ned as objects, each containing an array of up to n items. Here is apseudocode for one form of stack class.
class Stack private
contents : array[1..n] of int top : int
constructor
stack () = top := 0 public
push (x:int) : unit = if top <> then
top := top + 1; contents[top] := x
else raise stack full; pop ( ) : int =
if top > 0 then top := top - 1:
return contents[top+1] else raise stack empty;
end Stack
If stacks are going to be used in a concurrent programming language, what problem might occur if two threads invoke push and pop simultaneously? Explain.
(b) How would you solve this problem by using Java concurrency concepts? Explain.
(c) Suppose that, instead of stacks, we have queues:
class Queue private
contents : array[1..n] of int front, back : int
constructor
queue() = front := back := 1 public
insert (x:int) : unit =
if back+1 mod n != front then back := back+1 mod n; contents[back] := x
else raise queue full; remove ( ) : int =
if front != back then front := front+1 mod n; return contents[front]
else raise queue empty;
end Queue
Suppose that ?ve elements have been inserted into a queue object and none of them have been removed. Do we have the same concurrency problem as we did with push and pop when one thread invokes insert and another thread simultaneously invokes remove? Assume that n is 10. Explain.
Explain the time-dependence of the ground state wavefunction
: Determine the specific solutions inside the well for the ground state and for the rst excited state by applying the boundary conditions at x = 0 and at x = L. Now consider a 50:50 superposition of the ground state and the rst excited state.
|
A stock will have quarterly dividends of $0.78
: A stock will have quarterly dividends of $0.78, $0.83, $0.76, $0.92, $0.98, $13, $36, $38 and then grow by 0.02 a year, compounded quarterly. If the required return is 0.07 per year compounded quarterly, what should the price be?
|
Determine the amount and direction of heat interactions
: The heat engine in the atachment operates reversibly and draws 1200 KJ of heat from the 200 K reservoir
|
Prepare a classified statement of financial position
: Prepare a classified statement of financial position. Assume that $15,000 of the notes payable will be paid in 2018
|
Concurrent access to objects
: This question asks about synchronizing methods for stack and queue objects. (a) Bounded stacks can be de?ned as objects, each containing an array of up to n items. Here is apseudocode for one form of stack class.
|
Compounded annually,
: A stock will have annual dividends of $0.65, $0.8, $0.78, $0.76, $0.82, and then grow by 0.02 a year. If the required return is 0.16 per year compounded annually, what should the price be?
|
Calculate the energy of the gas
: There has recently been considerable interest in one-dimensional electrical conductors. In this problem, you are asked to calculate some free-electron properties for a system of length L containing N electrons. Thus, there are n =N/L electrons per..
|
Actual overhead costs for the year
: Pinnacle Corp. budgeted $700,000 of overhead cost for the current year. Actual overhead costs for the year were $650,000. Pinnacle’s plant wide allocation base, machine hours, was budgeted at 100,000 hours
|
Write a brief report that identify surgical operations
: To analyse a set of data (in Microsoft Excel), and write a brief report (in Microsoft Word), identifying and explaining your insights into the surgical operations of BestHealth Hospital.
|