COSC 4319 Distributed Object
Computing
Fall 2000 Midterm 2 November
20, 2000
Name Student
Number:
1. A COM class (call it
parent) supports the following interfaces: I1, I2. It also aggregates two
objects. First it has a selective aggregation, for I3, to the object (call it
A) that supports I3, I4 and I5. It has a blind aggregation to an object (call
it B) that supports I2, I4, I6 and I7. Assume, ATL is used for this. Answer the
following with respect to this scenario (Simply check one blank (only one) for
each question (a) – (f)) [6 pts]:
(a) What will be returned when request for IUnknown comes in during CoCreateInstance?
Parent’s __ I1
__ I2; A’s __ I3 __ I4 __I5; B’s
__ I2 __ I4 __ I6
__ I7 __None of above
(b) If QI request is made using the above IUnknown, which I2 will be returned?
Parent’s __ I1
__ I2; A’s __ I3 __ I4 __I5; B’s
__ I2 __ I4 __ I6
__ I7 __None of above
(c) If QI request is made using the above IUnknown,
which I3 will be returned?
Parent’s __ I1
__ I2; A’s __ I3 __ I4 __I5; B’s
__ I2 __ I4 __ I6
__ I7 __None of above
(d) If QI request is made using the above IUnknown,
which I4 will be returned?
Parent’s __ I1
__ I2; A’s __ I3 __ I4 __I5; B’s
__ I2 __ I4 __ I6
__ I7 __None of above
(e) If QI request is made using the above IUnknown,
which I5 will be returned?
Parent’s __ I1
__ I2; A’s __ I3 __ I4 __I5; B’s
__ I2 __ I4 __ I6
__ I7 __None of above
(f) If QI request is made using the above IUnknown,
which I6 will be returned?
Parent’s __ I1
__ I2; A’s __ I3 __ I4 __I5; B’s
__ I2 __ I4 __ I6
__ I7 __None of above
2. In the scenario from
question 1, if QI request for I2 comes through interface I6, explain the
sequence of function calls that take place (and where it occurs), before the
appropriate interface is returned [4 pts].
3.What should be the threading
model of the proxy COM class? Explain why? [5 pts]
4. What is the purpose of the
IDispatch interface? Explain the mechanism involved[3 pts]
5. There are two threads in a
program, T1 is in the Primary STA and T2 is in the MTA. A COM object CLSID_C1
has no threading model specification. Its constructor creates and holds a
pointer to another COM object CLSID_C2 whose threading model is Free. T2 issues
a CoCreateInstance to create CLSID_C1, and gets a pointer P2. Then, it passes
the pointer to T1 (appropriately). T1 then requests for the connected object
from the first object and gets a pointer P1. Show where the objects are created
and how the threads would communicate with them [10 pts].
6. interface ICompare :
IUnknown {
HRESULT compare([in] long* ptr1, [in] long* ptr2);
}
Assume a COM class, with threading model Free,
implements this interface as follows:
HRESULT compare(long* p1,
long* p2) {
if (p1 == p2) return S_OK;
return S_FALSE; }
(a) If a thread accessing it is in MTA, what will be
the result of the following call [2pts]:
long
a = 4;
pICompare->compare(&a,
&a); Result: ___________________________
(b) If a thread accessing it is in STA, then what will be
the result of the above call[2 pts]? Result:
___________________________
7. Explain the answer to the above two questions (6
a and b). Fix the interface to work correctly for both cases (rewrite the
interface below) [8 pts].