I realize there's a lot of people who can't "see it", so I've isolated
an example program that demonstrates the problem.

The attached (short) C program attempts to run a counter. You can modify
two portions: the first is where you set an initial counter, and the
second is how the counter is transformed.

Run your program on two machines or two TTY sessions (even different
programs/versions if you think it will help) for a while. At each
"step" (output line), note that "n" must never be "below" the other
process.

Note you cannot change the "sleep" statement- this simulates delays or
UID number usage.

Example run from attached version:
$ cc -o problem problem.c
$ ./problem & ./problem
(21219) n = 0
(21220) n = 0
(21220) n = 1
(21220) n = 2
(21219) n = 4
(21219) n = 8
(21219) n = 12
(21220) n = 3
(21219) n = 16

When n=3, the UID constraint set by RFC2060 has failed.

Your programs should run equally well over a network, thusly I should be
able to do:

$ ssh host1 ./problem & ssh host2 ./problem

If they use NFS, they I should be able to yank the network cables.

The programs may _stop_ outputting (while network is done), but they
must NEVER violate the UID constraint and emit a lower value.

My token passing algorithm requires that both nodes "be live" in order
to generate a new UID. I know there's a lot of people interested in a
"high availability UID generation scheme" and I hope this example
problem will prove valuable to anyone who wants to explore it.

I still think XIDs are easier though :)


-- 
Internet Connection High Quality Web Hosting
http://www.internetconnection.net/
/*
 * This file is released into the public domain. Do what you want.
 *
 * Simplified version of distributed sequence generation problem.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>

int main(int argc, char *argv[])
{
	int n;

	/*
	 * set N to some initial value (if you like)
	 */
	srand(time(0) ^ getpid());
	n = 0;

	for (;;) {
		/* simulate uid usage */
		printf("(%d) n = %d\n", getpid(), n);
		fflush(stdout);
		sleep(rand() % 10);

		/*
		 * modify N somehow
		 *
		 */
		n += (getpid() & 3)+1;
	}
}

Reply via email to