Systems Programming/NT

Final Exam

 

SSN: __________________________________________ (put on all submitted work)

I have neither given nor received unauthorized help in taking this exam (HONOR PLEDGE) _________________________________ (sign here)

1) What would be the effect on the Paint4 program of changing the implementation of CFrameWnd::OnCmdMsg shown on page 564 to

Only  Command Messages are subject to routing. Standard window messages are NOT.


    a) eliminate the call to pView->OnCmdMsg (but keep the other two calls to OnCmdMsg)


All of the following functions would no longer work: (4 points total as shown below))
Command messages for the View: None for paint4 (print is NOT prewired)
Command messages for the Document:
    OnWidth: changes current width (1)
    OnColor: changes current color (1)
    OnUpdateWidthUI: sets check in Width menu
    OnUpdateColorUI: sets check in Color Menu
Command messges for Document Template:
    OnFileSendMail: Sends document in e-mail (1)
    OnUpdateFileSendMail: enables/disables sned menu item in file menu
    OnFileSave: saves file (1)
    OnFileSaveAs: saves file different name


    b) eliminate the call to CWnd::OnCmdMsg (but keep the other two calls to OnCmdMsg)


I will accept either a) no change or b) (2 points total)

The following functions would no longer work:
Command messages for the FrameWindow:
    OnCreate: creates FrameWindow, sets for user drawn menu (1)
    OnMeasureItem: sets dimensions for user draw menu (1)
    OnDrawItem: draws color menu items


    c) eliminate the call to pApp->OnCmdMsg (but keep the other two calls to OnCmdMsg)


The following functions would no longer work: (4 points total)
Command messages for the Application:
    OnFileNew: sets up an empty document (1)
    OnFileOpen: opens and serializes in an existing document after saving previous (1)
    OnAppAbout: Displays about dialog 91)
    OnOpenRecentFile: opens file in MRU part of File menu
    OnAppExit: checks unsaved documents, exits (1)



Answer by giving the specific effect (if any) on the running of Paint4 given in this chapter (e.g. what would be affected and how).

2) On page 570, describe the message routing sequence for the MENUITEM for ID_APP_EXIT. Give every object which is involved in routing this message from the object which receives the initial mouse button up event to the object which finally handles this message. (1 point for each of the following 8 objects)


  1. It is the window displaying the File PopUp menu that receives the initial WM_LBUTTONUP event (this is a "windows object" but is attached to a CMenu object which is a child of the the CMainFrame object).
  2. The CMenu object sends a Command message to its parent the CMainFrame object.
  3. CMainFrame sends this message to the active view  CPaintView
  4. CPaintView passes the message to CPaintDoc
  5. CPaintDoc passes to CDocument
  6. Since CDocument declines to handle, the message is next sent to CWnd parent of CMainFrame which declines
  7. Then it is passed to CPaintApp
  8. By inheritance, it is passed to CWinApp, which finally handles it

3) What would be the effect of rearranging the POPUP menu items on page 570 so they looked like this?

    POPUP "&Width" {
        MENUITEM "Very &Thick\tF9",         ID_WIDTH_VTHICK
        MENUITEM "Thic&k\tF8",              ID_WIDTH_THICK
        MENUITEM "&Medium\tF7",             ID_WIDTH_MEDIUM
        MENUITEM "Thi&n\tF6",               ID_WIDTH_THIN
        MENUITEM "&Very Thin\tF5",          ID_WIDTH_VTHIN
    }

Appearance of Menu is changed (4 points), but functionality is the same(4).


4) Trace the Message for ID_FILE_NEW in Paint4.
    a) Describe all users actions which will result in the message handler of ID_FILE_NEW message being called. (4 points as shown below)


  1. Select File Menu with mouse, select New with mouse (1)
  2. Select File Menu with mouse, type N
  3. Open file menu with ATL+F, select New with mouse
  4. Open file menu with ATL+F, type N (1)
  5. type CTL+N (1)
  6. Open Paint4 (this opens a new document) (1)

    b) For each method of invoking this handler, describe the path taken (all objects touched).


  1. CMenu Object(1) -> CMainFrame(1)-> [CPaintView->CPaintDoc->CDocument->CFrameWnd(parent)](1 point)
    ->CPaintApp->CWinApp(1)
  2. Same as 1
  3. Same as 1
  4. Same as 1
  5. This requires some deduction on your part on how keyboard accelerators might work - I am looking to see if you can devise a plausible scenario - here's mine:
    Raw Keyboard messages is handled in PreTranslateMessage and routed to CMainFrame: Same as 1
  6. Again some deduction is in order. - same as 1 - or directly to CPaintApp part of 1

    c) describe which, if any, code listed on pages 569-586 is called after the message handler is called.


THe message handler we are talking about is OnFileNew in CWinApp
In CPaintDOc, DeleteContents (1) then OnNewDocument(1)
I assume that saving previous document is necessary because of modified flag preceeds the call to the OnFileNew Handler

Serialize (1), initialize view(I don't have book in front of me on this one) (1 point)

Although 4 points coudl be gotten - I expected only 2.


5) Consider the RPC Audio Message Server developed in the notes:
a) could this server support a client simultaneously recording and playback messages? Explain


Yes - RpcServerListen specifies 5 concurrent calls - It does not matter if these are from the same client or not. (4)

The only restriction is that imposed by CreateFile which will prevent the same file from being opened simulataneously by two clients (1)


b) could this server handle multiple clients simultaneously? Explain


See a) above (4)


6) Consider the Mandelbrot Set program listing on page 426. What is the advantage of creating a thread for the MandelThread function?


TO keep main thread available for user interface events. Since the RPC calcuation will take a long time, want ot be able to stop, resize, exit in the middle of computing the set. (6)


7) Consider the Client program "labdriv.cpp"  given in the notes on Distributed Objects.
    a) What would be the effect of removing the three calls to "Release"?


The object would live forever. (hypothethically)



    b) Suggest ways to handle the premature termination of a client which is accessing distributed objects (not specific to COM, CORBA).

 


Here are several (4 points for any one)

  1. Time out (somwhat dangerous unless a really long time out) - how do you know how long an application will want an object?
  2. Keep alive messages (pinging) to the client (actually to the client process). - But of course the client could go into an infinite loop in a thread using the object)
  3. Let underlying network protocol detect lost network connection (good for TCP/IP but not UDP)

8) Consider the DLL implementation of the stack on pages 763-766. Would it be possible to eliminate the calls to "init" and/or "destroy"? Explain. (8 points)


Yes. The application would have to initialize the "top" pointer to NULL before using the stack and it would have to POP all elements off the stack to destroy it.


9) Consider the role that the CLine class plays in the Document/View architecture with respect to the provided "Serialize" function. (4 points each part)
    a) What user actions ultimately trigger a call to CLine's Serialize?


Open/Save file (either by mouse or accelerator)



    b) Trace the relationship between CPaintDoc's Serialize and CLine's Serialize. That is, how does CLine's Serialize get called?

 


CPaintDoc calls CObjArray's serialize - which is an array of pointers to objects- which uses the virtual overloaded serialze on the object being pointed at - thus calling CLine's serialize.


10) Consider the statements from the IDL file listed on page 438 shown below.
    a) Describe what information should be present in the packet being sent from the client to the server (3 points)


All the [in] parameters (left, right, y, width)



    b) Describe what information should be present in the packet being sent from the server to the client.


All the [out] parameters (short line array)
NOTE: width need not be sent - since the client knows it and sends to server above)



    c) Describe the role of the MIDL compiler in making the RPC mechanism work for this function call.

 


  1. Creates Stubs for client to call
  2. Creates Stubs for server which will make actual procedure call
  3. Stubs marshall parameters, allocate space, build packets and call network transport functions in the DLLs
  4. Creates header file to access stub functions. on both sides

  void CalcLine([in] double left, 
	[in] double right,
	[in] double y, [in] long width,
	[out, size_is(width)] short line[]);