Browse Source

Plan 9 from Bell Labs 2009-12-01

David du Colombier 14 years ago
parent
commit
18f03b979d

+ 1 - 0
sys/games/lib/fortunes

@@ -4263,3 +4263,4 @@ size: q.out not an a.out
 Sharing your DNA hasn't been this exciting since the good old days. - Genealogy.com
 *WASH_Eyes_outWith_soap*
 -rwxr-xr-x  1 rae rae 141307906 Nov 10 16:55 arm-2009q3-67-arm-none-linux-gnueabi.bin  # shell script
+Beam to 1.04TeV... Lost due to tune drifting [sh*t!]... Tunes for beam 1 were different when we returned to injection energy (no precycle)... Trimmed and incorporated... Ramped 2 beams, all the way to 1.18TeV !!

+ 6 - 5
sys/src/9/pc/etherm10g.c

@@ -861,16 +861,17 @@ whichrx(Ctlr *c, int sz)
 static Block*
 balloc(Rx* rx)
 {
-	Block *b;
+	Block *bp;
 
 	ilock(rx->pool);
-	if((b = rx->pool->head) != nil){
-		rx->pool->head = b->next;
-		b->next = nil;
+	if((bp = rx->pool->head) != nil){
+		rx->pool->head = bp->next;
+		bp->next = nil;
+		_xinc(&bp->ref);	/* prevent bp from being freed */
 		rx->pool->n--;
 	}
 	iunlock(rx->pool);
-	return b;
+	return bp;
 }
 
 static void

+ 2 - 2
sys/src/cmd/cc/dcl.c

@@ -540,8 +540,8 @@ suallign(Type *t)
 				}
 				l->offset = o;
 			} else {
-				if(l->width <= 0)
-				if(l->down != T)
+				if(l->width < 0 ||
+				   l->width == 0 && l->down != T)
 					if(l->sym)
 						diag(Z, "incomplete structure element: %s",
 							l->sym->name);

+ 7 - 1
sys/src/cmd/cc/pswt.c

@@ -18,6 +18,7 @@ doswit(Node *n)
 	Case *c;
 	C1 *q, *iq;
 	long def, nc, i, isv;
+	int dup;
 
 	def = 0;
 	nc = 0;
@@ -51,9 +52,14 @@ doswit(Node *n)
 	if(debug['W'])
 	for(i=0; i<nc; i++)
 		print("case %2ld: = %.8llux\n", i, (vlong)iq[i].val);
+	dup = 0;
 	for(i=0; i<nc-1; i++)
-		if(iq[i].val == iq[i+1].val)
+		if(iq[i].val == iq[i+1].val) {
 			diag(n, "duplicate cases in switch %lld", (vlong)iq[i].val);
+			dup = 1;
+		}
+	if(dup)
+		return;
 	if(def == 0) {
 		def = breakpc;
 		nbreak++;

+ 17 - 17
sys/src/cmd/fossil/periodic.c

@@ -5,10 +5,10 @@
 
 struct Periodic {
 	VtLock *lk;
-	int die;
-	void (*f)(void*);
-	void *a;
-	int msec;
+	int die;		/* flag: quit if set */
+	void (*f)(void*);	/* call this each period */
+	void *a;		/* argument to f */
+	int msec;		/* period */
 };
 
 static void periodicThread(void *a);
@@ -51,31 +51,31 @@ static void
 periodicThread(void *a)
 {
 	Periodic *p = a;
-	double t, ct, ts;
+	vlong t, ct, ts;		/* times in ms. */
 
 	vtThreadSetName("periodic");
 
-	ct = nsec()*1e-6;
-	t = ct + p->msec;
+	ct = nsec() / 1000000;
+	t = ct + p->msec;		/* call p->f at or after this time */
 
 	for(;;){
-		/* skip missed */
-		while(t <= ct)
-			t += p->msec;
-
-		ts = t - ct;
+		ts = t - ct;		/* ms. to next cycle's start */
 		if(ts > 1000)
-			ts = 1000;
-		sleep(ts);
-		ct = nsec()*1e-6;
+			ts = 1000;	/* bound sleep duration */
+		if(ts > 0)
+			sleep(ts);	/* wait for cycle's start */
+
 		vtLock(p->lk);
 		if(p->die){
 			vtUnlock(p->lk);
 			break;
 		}
-		if(t <= ct){
+		ct = nsec() / 1000000;
+		if(t <= ct){		/* due to call p->f? */
 			p->f(p->a);
-			t += p->msec;
+			ct = nsec() / 1000000;
+			while(t <= ct)	/* advance t to future cycle start */
+				t += p->msec;
 		}
 		vtUnlock(p->lk);
 	}

+ 11 - 5
sys/src/cmd/look.c

@@ -66,6 +66,13 @@ void	torune(char*, Rune*);
 void	rcanon(Rune*, Rune*);
 int	ncomp(Rune*, Rune*);
 
+void
+usage(void)
+{
+	fprint(2, "usage: %s [-dfinx] [-t c] [string] [file]\n", argv0);
+	exits("usage");
+}
+
 void
 main(int argc, char *argv[])
 {
@@ -88,15 +95,14 @@ main(int argc, char *argv[])
 		compare = ncomp;
 		break;
 	case 't':
-		chartorune(&tab,ARGF());
+		chartorune(&tab, EARGF(usage()));
 		break;
 	case 'x':
 		exact++;
 		break;
 	default:
 		fprint(2, "%s: bad option %c\n", argv0, ARGC());
-		fprint(2, "usage: %s -[dfinx] [-t c] [string] [file]\n", argv0);
-		exits("usage");
+		usage();
 	} ARGEND
 	if(!iflag){
 		if(argc >= 1) {
@@ -153,12 +159,12 @@ main(int argc, char *argv[])
 int
 locate(void)
 {
-	long top, bot, mid;
+	vlong top, bot, mid;
 	long c;
 	int n;
 
 	bot = 0;
-	top = Bseek(dfile, 0L, 2);
+	top = Bseek(dfile, 0, 2);
 	for(;;) {
 		mid = (top+bot) / 2;
 		Bseek(dfile, mid, 0);

+ 120 - 49
sys/src/cmd/venti/srv/venti.c

@@ -9,6 +9,15 @@
 
 #include "whack.h"
 
+typedef struct Allocs Allocs;
+struct Allocs {
+	u32int	mem;
+	u32int	bcmem;
+	u32int	icmem;
+	u32int	stfree;				/* free memory at start */
+	uint	mempcnt;
+};
+
 int debug;
 int nofork;
 int mainstacksize = 256*1024;
@@ -53,11 +62,94 @@ freemem(void)
 	return size;
 }
 
+static void
+allocminima(Allocs *all)			/* enforce minima for sanity */
+{
+	if (all->icmem < 6 * 1024 * 1024)
+		all->icmem = 6 * 1024 * 1024;
+	if (all->mem < 1024 * 1024 || all->mem == 0xffffffffUL)  /* lumps */
+		all->mem = 1024 * 1024;
+	if (all->bcmem < 2 * 1024 * 1024)
+		all->bcmem = 2 * 1024 * 1024;
+}
+
+/* automatic memory allocations sizing per venti(8) guidelines */
+static Allocs
+allocbypcnt(u32int mempcnt, u32int stfree)
+{
+	u32int avail;
+	vlong blmsize;
+	Allocs all;
+	static u32int free;
+
+	all.mem = all.bcmem = all.icmem = 0;
+	all.mempcnt = mempcnt;
+	all.stfree = stfree;
+
+	if (free == 0)
+		free = freemem();
+	blmsize = stfree - free;
+	if (blmsize <= 0)
+		blmsize = 0;
+	avail = ((vlong)stfree * mempcnt) / 100 - blmsize;
+	if (avail <= (1 + 2 + 6) * 1024 * 1024)
+		fprint(2, "%s: bloom filter bigger than mem pcnt; "
+			"resorting to minimum values (9MB total)\n", argv0);
+	else {
+		if (avail >= 3840UL * 1024 * 1024)
+			avail = 3840UL * 1024 * 1024;	/* sanity */
+		avail /= 2;
+		all.icmem = avail;
+		avail /= 3;
+		all.mem = avail;
+		all.bcmem = 2 * avail;
+	}
+	return all;
+}
+
+/*
+ * we compute default values for allocations,
+ * which can be overridden by (in order):
+ *	configuration file parameters,
+ *	command-line options other than -m, and -m.
+ */
+static Allocs
+sizeallocs(Allocs opt, Config *cfg)
+{
+	Allocs all;
+
+	/* work out sane defaults */
+	all = allocbypcnt(20, opt.stfree);
+
+	/* config file parameters override */
+	if (cfg->mem)
+		all.mem = cfg->mem;
+	if (cfg->bcmem)
+		all.bcmem = cfg->bcmem;
+	if (cfg->icmem)
+		all.icmem = cfg->icmem;
+
+	/* command-line options override */
+	if (opt.mem)
+		all.mem = opt.mem;
+	if (opt.bcmem)
+		all.bcmem = opt.bcmem;
+	if (opt.icmem)
+		all.icmem = opt.icmem;
+
+	/* automatic memory sizing? */
+	if(opt.mempcnt > 0)
+		all = allocbypcnt(opt.mempcnt, opt.stfree);
+
+	allocminima(&all);
+	return all;
+}
+
 void
 usage(void)
 {
 	fprint(2, "usage: venti [-Ldrsw] [-a ventiaddr] [-c config] "
-"[-h httpaddr] [-m %%] [-B blockcachesize] [-C cachesize] [-I icachesize] "
+"[-h httpaddr] [-m %%mem] [-B blockcachesize] [-C cachesize] [-I icachesize] "
 "[-W webroot]\n");
 	threadexitsall("usage");
 }
@@ -66,8 +158,8 @@ void
 threadmain(int argc, char *argv[])
 {
 	char *configfile, *haddr, *vaddr, *webroot;
-	u32int mem, icmem, bcmem, minbcmem, mempcnt, stfree, aftblmfree, avail;
-	vlong blmsize;
+	u32int mem, icmem, bcmem, minbcmem, mempcnt, stfree;
+	Allocs allocs;
 	Config config;
 
 	traceinit();
@@ -154,55 +246,31 @@ threadmain(int argc, char *argv[])
 	if(configfile == nil)
 		configfile = "venti.conf";
 
-	/* automatic memory sizing? */
 	if(mempcnt > 0)
-		stfree = freemem();
+		stfree = freemem();   /* remember free memory for auto-sizing */
 	fprint(2, "conf...");
 	if(initventi(configfile, &config) < 0)
 		sysfatal("can't init server: %r");
+	/*
+	 * load bloom filter
+	 */
 	if(mainindex->bloom && loadbloom(mainindex->bloom) < 0)
 		sysfatal("can't load bloom filter: %r");
 
-	/* automatic memory sizing per venti(8) guidelines? */
-	if(mempcnt > 0) {
-		mem = bcmem = icmem = 0;
-		aftblmfree = freemem();
-		blmsize = stfree - aftblmfree;
-		if (blmsize <= 0)
-			blmsize = 0;
-		avail = ((vlong)stfree * mempcnt) / 100 - blmsize;
-		if (avail <= (1 + 2 + 6) * 1024 * 1024)
-			fprint(2, "%s: bloom filter bigger than mem pcnt; "
-				"resorting to minimum values (9MB total)\n",
-				argv0);
-		else {
-			if (avail >= 3840UL * 1024 * 1024)
-				avail = 3840UL * 1024 * 1024;	/* sanity */
-			avail /= 2;
-			icmem = avail;
-			avail /= 3;
-			mem = avail;
-			bcmem = 2 * avail;
-		}
-		if (icmem < 6 * 1024 * 1024)
-			icmem = 6 * 1024 * 1024;
-		if (mem < 1 * 1024 * 1024)		/* lumps */
-			mem = 1 * 1024 * 1024;
-		if (bcmem < 2 * 1024 * 1024)
-			bcmem = 2 * 1024 * 1024;
-		config.mem = mem;
-		config.bcmem = bcmem;
-		config.icmem = icmem;
-	}
-
-	if(mem == 0)
-		mem = config.mem;
-	if(bcmem == 0)
-		bcmem = config.bcmem;
-	if(icmem == 0)
-		icmem = config.icmem;
-	fprint(2, "%s: mem %d bcmem %d icmem %d...", argv0, mem, bcmem, icmem);
+	/*
+	 * size memory allocations; assumes bloom filter is loaded
+	 */
+	allocs = sizeallocs((Allocs){mem, bcmem, icmem, stfree, mempcnt},
+		&config);
+	mem = allocs.mem;
+	bcmem = allocs.bcmem;
+	icmem = allocs.icmem;
+	fprint(2, "%s: mem %,ud bcmem %,ud icmem %,ud...",
+		argv0, mem, bcmem, icmem);
 
+	/*
+	 * default other configuration-file parameters
+	 */
 	if(haddr == nil)
 		haddr = config.haddr;
 	if(vaddr == nil)
@@ -213,31 +281,34 @@ threadmain(int argc, char *argv[])
 		webroot = config.webroot;
 	if(queuewrites == 0)
 		queuewrites = config.queuewrites;
+
 	if(haddr){
 		fprint(2, "httpd %s...", haddr);
 		if(httpdinit(haddr, webroot) < 0)
 			fprint(2, "warning: can't start http server: %r");
 	}
-
 	fprint(2, "init...");
 
-	if(mem == 0xffffffffUL)
-		mem = 1 * 1024 * 1024;
+	/*
+	 * lump cache
+	 */
 	if(0) fprint(2, "initialize %d bytes of lump cache for %d lumps\n",
 		mem, mem / (8 * 1024));
 	initlumpcache(mem, mem / (8 * 1024));
 
+	/*
+	 * index cache
+	 */
 	initicache(icmem);
 	initicachewrite();
 
 	/*
-	 * need a block for every arena and every process
+	 * block cache: need a block for every arena and every process
 	 */
 	minbcmem = maxblocksize * 
 		(mainindex->narenas + mainindex->nsects*4 + 16);
 	if(bcmem < minbcmem)
 		bcmem = minbcmem;
-
 	if(0) fprint(2, "initialize %d bytes of disk block cache\n", bcmem);
 	initdcache(bcmem);
 

+ 0 - 1
sys/src/libc/arm/mkfile

@@ -5,7 +5,6 @@ LIB=/$objtype/lib/libc.a
 SFILES=\
 	argv0.s\
 	atom.s\
-	cas.s\
 	div.s\
 	getcallerpc.s\
 	getfcr.s\