• wonderlic tests
  • EXAM REVIEW
  • NCCCO Examination
  • Summary
  • Class notes
  • QUESTIONS & ANSWERS
  • NCLEX EXAM
  • Exam (elaborations)
  • Study guide
  • Latest nclex materials
  • HESI EXAMS
  • EXAMS AND CERTIFICATIONS
  • HESI ENTRANCE EXAM
  • ATI EXAM
  • NR AND NUR Exams
  • Gizmos
  • PORTAGE LEARNING
  • Ihuman Case Study
  • LETRS
  • NURS EXAM
  • NSG Exam
  • Testbanks
  • Vsim
  • Latest WGU
  • AQA PAPERS AND MARK SCHEME
  • DMV
  • WGU EXAM
  • exam bundles
  • Study Material
  • Study Notes
  • Test Prep

have discussed the syllabus and the schedule for the courseclass.

Testbanks Dec 30, 2025 ★★★★☆ (4.0/5)
Loading...

Loading document viewer...

Page 0 of 0

Document Text

s

©2004 «GreetingLine» 1 Chapter 1 Distributed Computing, An Introduction Presentation Suggestions • I usually start presenting this chapter on the very first day of class, immediately after I have discussed the syllabus and the schedule for the course/class.• I normally spend the first week of the course covering this chapter.• To captivate the students’ interest, try to be as light-hearted as possible. Keep in mind that even though today’s students take for granted the Internet, there is a significant number of them that do not understand what happens behind the scenes when they say surf the web. A great way to start the course is to explain just that: what happens when one opens a browser and enters a URL.• In retrospect, I would have added more coverage on threading. As it stands, the book covers the bare minimum of threading. In subsequent editions of the book I will definitely expand on the coverage. For my own classes, I supplement the topic with a

handout which you can find at this URL:

http://www.csc.calpoly.edu/~mliu/csc369/websites/mutualExclusion.html

I recommend that you do likewise, as proper use of threaded programming is crucial in project assignments.• The terms introduced in the “Network Basics” section are important, as they will be used repeatedly in subsequent chapters.• A couple of the exercises require basic probability, which may be intimidating to some students. They are not typical exercises, but many of my students find them interesting.

How This Chapter Fits This is a key chapter. I have had students who told me that it should be required reading for all computer science students. I have tried to make it as interesting as possible by using graphics and excerpts of interesting articles.The chapter introduces relevant topics from three important fields in computer science that the book builds on: operating systems, networks, and software engineering. Since this book does not assume advanced knowledge in any of these fields, this orientation material is provided to ensure that all the students in a class are on the same page before the subject of distributed computing unfolds in subsequent chapters.

Solutions to Chapter Exercises (Answers are in red) 1b.In this exercise we will use a simplified mathematical model to analyze failures in a distributed system. Explain your answers.Suppose each computer in has a probability of p of failing at any time.

  • b i a
  • (Distributed Computing Principles and Applications 1e M.L. Liu) (Solution Manual all Chapters) 1 / 4

Distributed Computing, Liu Instructor’s Manual w/ Solutions Chapter 1 ©2004 «GreetingLine» 2 If n computers are interconnected and the availability of each computer is needed to maintain a service provided using distributed computing involving these computers, what is the probability that the service will not be available at any time, assuming that no other components in the distributed system will fail?

Answer:

All n computers need to be functioning in order for the service to be available. The probability that each system is functioning is 1 – p.The probability that all n systems are functioning is ( 1 – p) n , the probability that the service is available.The probability that the service is not available is the complement, or

  • – ( 1 – p)
  • n

  • b i b

Answer:

The probability when n = 1 is 1 – ( 1 – p) 1 = 1 – (1 – p) = p.

  • b i c
  • Use p=0.2 and n=3 to compute the probability. How does it compare with the failure probability if the same computing is performed using monolithic computing, that is, on one computer only?

Answer:

On a single computer, the probability of failing is p = 0.2.Using the formula developed in (i), the failure probability is (1 - .8 3)

= 0.488

on 3 computers,.Because all three computers need to be up for the service to be available, the failure probability is greater than when only one computer is needed.

  • b ii.
  • Now suppose the service provided using distributed computing requires only 1 of the 3 computers, with the other 2 computer being backups (that is, each of the three computers, on its own, is capable of providing the service). Now what is the probability that the service will not be available at any time, assuming that no other components in the distributed system will fail? How does it compare with the failure probability if the same computing is performed using monolithic computing, that is, on one computer only?

Answer:

The failure probability is p n in general, or (0.2) 3 = 0.008 in this case.Because only any one of the three computers needs to be up for the service to be available, the failure probability is now less than when exactly one single computer is needed.

  • Concurrent Programming
  • 2a i.According to the specification, which of the two, Runnable interface and Thread class, is preferred if you only intend to implement the run method? Why?

Answer: 2 / 4

Distributed Computing, Liu Instructor’s Manual w/ Solutions Chapter 1 ©2004 «GreetingLine» 3 For good programming practice, the Runnable interface should be used if only the run method needs to be defined. A subclass of the Thread class should only be used if the program requires the modification or enhancement of the base class (that is, if the program needs to add variables and/or methods that are not in the Thread class).2a ii.

Answer:

The sleep method suspends the execution of the thread that makes the method call for the specified number of milliseconds.

The simplest code for suspending the thread for 5 seconds is:

try { Thread.sleep(5000); } catch (Exception ex) { //exception handling is required }

2a iii

Answer:

activeCount( ) returns the number of active threads in the current thread’s thread group.” If 3 threads are spawned and currently activein a process, then the method should return 4 or more (1 or more thread for main( ) and 3 for the child threads.) 2a iv

Answer:

A deprecated method is one whose support is no longer guaranteed by Java, and hence its use should be avoided.2a v

Answer:

There is only one method, run( )

2a vi

Answer:

You define a class that implements the Runnable interface, then create an instance of the Thread class, passing as an argument to the constructor a reference to an

instance of the class you defined. Like this:

Thread p1 = new Thread(new SomeThread2(1)); p1.start(); 2b.Compile and run the Java class file provided in section 1 in the Appendix. What is the outcome? Capture the output of the run and write a paragraph to explain the output, paying special attention to the order of the lines.

Answer:

Thread1: 1

Thread1: 2

Thread1: 3

Thread1: 4

Thread1: 5

Thread1: 6

Thread1: 7

Thread2: 1

Thread3: 1

Thread2: 2

Thread3: 2

Thread2: 3

Thread3: 3

Thread2: 4

Thread3: 4 3 / 4

Distributed Computing, Liu Instructor’s Manual w/ Solutions Chapter 1 ©2004 «GreetingLine» 4

Thread2: 5

Thread3: 5

Thread2: 6

Thread3: 6

Thread2: 7

Thread2: 8

Thread2: 9

Thread2: 10

Thread3: 7

Thread3: 8

Thread3: 9

Thread3: 10

Thread1: 8

Thread1: 9

Thread1: 10

Since the threads share the system’s resources, including a single CPU, they are dispatched by the operating system in turns, and are therefore executed in an interleaved manner; the order of the interleaving is unpredictable.

2c.Compile and run the Java class file provided in section 2 in the Appendix. What is the outcome? Capture the output of the run and write a paragraph to explain the output, paying special attention to the order of the lines. Also, how does it compare with the output from (a)?

Answer:

Thread1: 1

Thread1: 2

Thread1: 3

Thread1: 4

Thread1: 5

Thread1: 6

Thread1: 7

Thread2: 1

Thread3: 1

Thread2: 2

Thread3: 2

Thread2: 3

Thread3: 3

Thread2: 4

Thread3: 4

Thread2: 5

Thread3: 5

Thread2: 6

Thread3: 6

Thread3: 7

Thread3: 8

Thread3: 9

Thread3: 10

Thread2: 7

Thread2: 8

Thread2: 9

Thread2: 10

Thread1: 8

Thread1: 9

Thread1: 10

The threads are still executed in an interleaved manner, in an unpredictable order.

2d.

Consider the following Java classes:

import SomeThread3; public class RunThreads3 { public static void main (String[] args) { int originalThreadCount = Thread.activeCount( ); for (int i=0; i<10; i++) { Thread p = new Thread(new SomeThread3()); p.start(); System.out.println("thread count=" +Thread.activeCount( )); }

while (Thread.activeCount() > originalThreadCount ){ // loop until all child threads have exited.} System.out.println("finally, Count = " + SomeThread3.count); } }//end class RunThreads3

class SomeThread3 implements Runnable { static int count=0;

SomeThread3() { super(); }

  • / 4

User Reviews

★★★★☆ (4.0/5 based on 1 reviews)
Login to Review
S
Student
May 21, 2025
★★★★☆

This document provided detailed explanations, which was incredibly useful for my research. Absolutely outstanding!

Download Document

Buy This Document

$1.00 One-time purchase
Buy Now
  • Full access to this document
  • Download anytime
  • No expiration

Document Information

Category: Testbanks
Added: Dec 30, 2025
Description:

s ©2004 «GreetingLine» Chapter 1 Distributed Computing, An Introduction Presentation Suggestions • I usually start presenting this chapter on the very first day of class, immediately after I h...

Unlock Now
$ 1.00