Previous Contents Next

5.8   Module ns: global name server

The name server provides a basic mechanism to initiate distributed computation. Due to lexical scoping, programs running on different machines cannot refer to names that are remotely defined, unless these names were sent to them. To bootstrap the process, a global table of publicly-available names is maintained by one runtime running in server-mode.

According to their distributed protocols, programs will usually first register and/or lookup a few values from this table before the actual computation begins. Once this is done, the name server does not need to be used anymore.

The global ordering of register/lookup calls may depend on the way the different runtimes are started. Accordingly, a lookup to a name that is not defined yet in the nameserver blocks until this name gets registered. Assuming that every name is registered at most once, this guarantees that the values obtained from the name-server, if any, are always the same.

Except for the command-line options (cf. 10) and the availability of the nameserver in case of partial failure, there is no visible difference between server- and client- runtimes.

Beware! In this release no typechecking is performed on the values stored in the table; if a value of some type is registered, then read in a context that expects another incompatible type, anything may happen.
val register : <string * 'a> -> <>
ns.register(s,v) registers some arbitrary value v under a given name s. The key s is a string that must not have been previously registered.
val lookup : <string> -> <'b>
ns.lookup(s) returns the value registered under the name s, if any. The key s is a string that must have been registered by another process; the function blocks if this is not the case. WARNING: no typechecking on the incoming value.
val server : bool
true if the nameserver is running locally, false otherwise.
val address : string
The host name used by the name server
val port : int
The port number used by the name server
val fork_client : < string > 
ns.fork_client(cmd) starts a new runtime by calling sh on the command cmd with additional options that specify client mode using the IP address and port number of the current name server. This does not affects the current runtime.

Typical examples of cmds are ``mycode.out'' and ``rsh ~/program/mine.out''

Previous Contents Next