Nov 13, 5pm.
NTP and Cristian’s algorithm
At 9:23:223 (hr:min:msec) local time, server C requests the time from server N. At 9:23:726 local time, server C receives a reply from N with a timestamp of 9:23:102.
What is the skew of C’s clock with respect to N, assuming there is no processing time at N to reply to the message?
Assuming that C and N’s clocks were equal at some point in the past, is C’s clock going too fast, or too slow, with respect to N?
Types of clocks
On the ieng6 servers (e.g., ieng6-201.ucsd.edu), read the man page for the
clock_gettime() system call. This system call allows you to get the time
relative to one of several clocks in the system. The
is the “wall clock” time representing the real time (kept in sync with a
protocol like NTP),
CLOCK_REALTIME_COARSE also represents real-time,
however at a coarser granularity.
CLOCK_MONOTONIC clock is guaranteed to never
decrease, however its absolute value is meaningless, and the
CLOCK_THREAD_CPUTIME_ID clock is very precise, however its absolute value is
meaningless and is not necessarily even the same as the per-thread clock on
other CPU cores.
Describe an example of a real-world application that could best make use of each type of clock.
clock_getres() system call, indicate how precise each of the above
clocks are, in terms of nanoseconds.
Lamport and vector clocks
Imagine that three processes,
Client 2, and
exchanging messages and initiating local events. The following events
occur in this system:
- Event 1: Client 1 modifies Resume.doc
- Event 2: Client 1 modifies Resume.doc again
- Event 3: Client 1 sends a copy of Resume.doc to the Server
- Event 4: The server receives Resume.doc
- Event 5: Client 2 sends a copy of Schedule.xls to the server
- Event 6: The server receives Schedule.xls
- Event 7: The server sends a copy of Schedule.xls to Client 1
- Event 8: The server sends a copy of Resume.doc to Client 2
- Event 9: Client 2 receives Resume.doc
- Event 10: Client 2 modifies Resume.doc
- Event 11: Clent 2 sends a copy of Resume.doc to the Server
- Event 12: Client 1 receives Schedule.xls
- Event 13: The server receives Resume.doc
- Event 14: The server sends a copy of Resume.doc to Client 1
- Event 15: Client 1 receives Resume.doc
- Event 16: Client 1 modifies Resume.doc
- Event 17: Client 1 sends Resume.doc to the server
- Event 18: The Server receives Resume.doc
- Event 19: The Server updates Resume.doc
Using this sequence of events, write out the Lamport Clock representation of each timestamp, using the notation L([event]) = [Lamport timestep]. For example, L(e1) = 1
Next, write out the vector time representation of each timestep.
Submit a PDF of your solution to: http://www.gradescope.com using entry code MP5RJ6