Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

31
Review Questions Review Questions on on Chapter IV—IPC Chapter IV—IPC COSC 4330/6310 COSC 4330/6310 Summer 2013 Summer 2013

Transcript of Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Page 1: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Review Questions onReview Questions onChapter IV—IPC Chapter IV—IPC

COSC 4330/6310COSC 4330/6310

Summer 2013Summer 2013

Page 2: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

How can you implement the How can you implement the at most at most onceonce semantics in a remote procedure semantics in a remote procedure call package?call package?

Page 3: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

How can you implement the How can you implement the at most at most onceonce semantics in a remote procedure semantics in a remote procedure call package?call package?

By adding sequence numbers to all By adding sequence numbers to all client requests and instructing the client requests and instructing the server to ignore requests with server to ignore requests with duplicate serial numbersduplicate serial numbers

Page 4: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

What is the major advantage of What is the major advantage of atomic atomic transactionstransactions? ?

Page 5: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

What is the major advantage of What is the major advantage of atomic atomic transactionstransactions??

They either execute correctly orThey either execute correctly ornot at allnot at all

• We do not have to worry about We do not have to worry about partial executions or duplicate partial executions or duplicate executions executions

Page 6: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

How can you simulate a How can you simulate a blocking receiveblocking receive primitive using a primitive using a non-blocking receivenon-blocking receive ? ?

Page 7: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

How can you simulate a How can you simulate a blocking receiveblocking receive primitive using a primitive using a non-blocking receivenon-blocking receive ? ?

By doing a By doing a busy waitbusy wait

while (receive(…) == NO_MSG);while (receive(…) == NO_MSG);

Page 8: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

What is the major advantage of streams What is the major advantage of streams over datagrams? over datagrams?

Page 9: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

What is the major advantage of streams What is the major advantage of streams over datagrams?over datagrams?

All data are transmitted in sequence All data are transmitted in sequence and no data are damaged, lost or and no data are damaged, lost or duplicatedduplicated

Page 10: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

How do you pass a linked list to a remote How do you pass a linked list to a remote procedure?procedure?

Page 11: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

How do you pass a linked list to a remote How do you pass a linked list to a remote procedure?procedure?

You send it as an array along with You send it as an array along with instructions how to rebuild itinstructions how to rebuild it

Page 12: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

When should we worry about When should we worry about big-big-endiansendians and and little-endianslittle-endians??

Page 13: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

First QuestionFirst Question

When should we worry about When should we worry about big-big-endiansendians and and little-endianslittle-endians??

Each time we exchange numerical Each time we exchange numerical data between two different machinesdata between two different machines

• Strings are never a problemStrings are never a problem

Page 14: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

All UNIX message passing primitives use All UNIX message passing primitives use direct naming.direct naming.

Page 15: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

All UNIX message passing primitives use All UNIX message passing primitives use direct naming.direct naming.

FALSE, FALSE, they use sockets and sockets are private mailboxes

Page 16: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

Most servers use Most servers use non-blockingnon-blocking receives.receives.

Page 17: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

Most servers use Most servers use non-blockingnon-blocking receives.receives.

FALSEFALSE, they use blocking receives, they use blocking receives

Page 18: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

Reliable datagramsReliable datagrams guarantee that no guarantee that no message will be lost or duplicated.message will be lost or duplicated.

Page 19: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

Reliable datagramsReliable datagrams guarantee that no guarantee that no message will be lost or duplicated.message will be lost or duplicated.

FALSE, FALSE, they only guarantee that no they only guarantee that no message will be lost or damagedmessage will be lost or damaged

• Messages can still be duplicatedMessages can still be duplicated

Page 20: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

Making all remote procedures Making all remote procedures idempotentidempotent greatly simplifies the task of greatly simplifies the task of the RPC server.the RPC server.

Page 21: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

Making all remote procedures Making all remote procedures idempotentidempotent greatly simplifies the task of greatly simplifies the task of the RPC server.the RPC server.

TRUE, TRUE, we do not have to worry about we do not have to worry about multiple executionsmultiple executions

Page 22: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

In a RPC, one of the tasks of the user In a RPC, one of the tasks of the user stub is to exchange messages with the stub is to exchange messages with the user program.user program.

Page 23: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Second Question: True or FalseSecond Question: True or False

In a RPC, one of the tasks of the user stub In a RPC, one of the tasks of the user stub is to exchange messages with the user is to exchange messages with the user program.program.

FALSE, the user stub is in the same FALSE, the user stub is in the same address space as the user programaddress space as the user program

• It exchanges messages with the It exchanges messages with the server stubserver stub

Page 24: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Third QuestionThird Question

What would you need to do to simulate What would you need to do to simulate streams using datagrams? (10 points) streams using datagrams? (10 points)

Page 25: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Third QuestionThird Question

What would you need to do to simulate What would you need to do to simulate streams using datagrams? (10 points)streams using datagrams? (10 points)

Use positive acknowledgments to ensure Use positive acknowledgments to ensure that all messages will be delivered intact.that all messages will be delivered intact.

Attach a serial number to each message Attach a serial number to each message to detect duplicate messages and reorder to detect duplicate messages and reorder messages that arrive out-of-order.messages that arrive out-of-order.

Remove message boundariesRemove message boundaries..

Page 26: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Fourth QuestionFourth Question

Consider the functionConsider the function

void doubletrouble(int *one, int *two) {void doubletrouble(int *one, int *two) {*one += *one; *one += *one; *two += *two;*two += *two;

} // doubletrouble`} // doubletrouble`

and assume the calling sequence:and assume the calling sequence:

alpha = 10;alpha = 10;doubletrouble (&alpha, &alpha);doubletrouble (&alpha, &alpha);

Page 27: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Fourth QuestionFourth Question

What will be the value of alpha What will be the value of alpha after the after the callcall assuming thatassuming that

The call was a The call was a conventional conventional procedure callprocedure call??Answer:Answer: alpha = ____________ alpha = ____________

The call was aThe call was a remote procedure remote procedure callcall??Answer:Answer: alpha = ____________ alpha = ____________

Page 28: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Fourth QuestionFourth Question

What will be the value of alpha What will be the value of alpha after the after the callcall assuming thatassuming that

The call was a The call was a conventional conventional procedure callprocedure call??Answer:Answer: alpha = alpha = 4040

The call was aThe call was a remote procedure remote procedure callcall??Answer:Answer: alpha = ____________ alpha = ____________

Page 29: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Fourth QuestionFourth Question

What will be the value of alpha What will be the value of alpha after the after the callcall assuming thatassuming that

The call was a The call was a conventional conventional procedure callprocedure call??Answer:Answer: alpha = alpha = 4040

The call was aThe call was a remote procedure remote procedure callcall??Answer:Answer: alpha = alpha = 2020

Page 30: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Passing by reference

Caller: … int alpha; alpha = 10; doubletrouble(&alpha, &alpha); …

alphaPass TWICE theADDRESS of variable alpha

Alpha getsincrementedTWICE

Page 31: Review Questions on Chapter IV—IPC COSC 4330/6310 Summer 2013.

Passing by value and result

Pass twice theVALUE of alpha:10 and 10

ReturnNEW VALUES:20 and 20

Caller: … int alpha; alpha = 10; doubletrouble(&alpha, &alpha); …

alpha