IN5710v19 Exercise Set 3
v19.2 (2019-02-11)
Oleks Shturmov
Sølve Johnsen

1. Getting Started with PlanetLab

PlanetLab is a world-wide network of computers intended as a testbed for distributed systems research. In this course, you too get to run your programs on PlanetLab. Here we get started with using PlanetLab.

Follow the in-depth guide here to complete the following tasks:

  1. Create a PlanetLab account, under the “University of Copenhagen, DIKU” site.
  2. Wait for your user to be approved by Eric Jul. (You don't need the guide for this.)
  3. Create a 4096-bit, password-protected, RSA SSH key (unless you already have one).
  4. Upload your (new) SSH key under your user on PlanetLab.
  5. Wait. (You don't need the guide for this.)
  6. Try and login to some PlanetLab machines once your key has been propagated.

If time allows (i.e., your user is approved, and your SSH key is pushed to sufficiently many machines), try and run your solutions to the below exercises on PlanetLab.

2. Name Round

Create a program that prints out the names of all currently active nodes, with one node name per line (i.e., all Node objects have a getName function).

Let the Emerald-file be called nameround.m, and compile it as nameround.x.

NB! For each element returned by getActiveNodes, you must ask for getTheNode, to get an actual node object, rather than a node list element object.

3. Echo All

Write an Emerald program that echo's whatever it receives on the standard input stream, on the standard output stream of every active node (including self), line-by-line. Let the program end, if it receives the line “exit”.

Let the Emerald-file be called echoall.m, and compile it as echoall.x.

Clarification: You can read a string from the standard input stream using stdin.getstring. However, that might come with a trailing line break due to the user pressing Enter. For the purposes of this exercise, you may assume that the user always does so. Hence, you might appreciate the following auxiliary functions:

function trunclast [ i : String ] -> [ o : String ]
  o <- i.getSlice[ 0, i.length - 1 ]
end striplast
function readline -> [ o : String ]
  o <- self.trunclast [ stdin.getstring ]
end readline

Hint: See the helloall-program in the slides from the first exercise session for a reminder on how to write something on the standard output stream of every active node.

What happens if some of the nodes become unreachable? Would your program crash? Test this. Try and mitigate for this using the unavailable construction.

4. HiHo

Run the hiho.m program from lecture 3.

Explain the program in your own words.

5. Counting Semaphore

Implement a counting semaphore object in Emerald, conforming to the following type:

typeobject NSem
  operation p [ n : Integer ]
  operation v [ n : Integer ]
end NSem

The semantics must be such that the operation p procures n instances of the resource governed by NSem, and v vacates n instances of that resource.

6. Keywords

After completing these exercises, you should be familiar with the following keywords. If not, read up on them in the language report.

  • Node
  • NodeList
  • fix
  • unfix
  • refix
  • unavailable
  • delay
  • Time

7. Tips

You can use the $ as syntactic sugar for .get.

For instance, you can write self$stdout in place of self.getstdout above.