shithub: gefs

Download patch

ref: 5943b07c27555189a92fbed56893483190f79601
parent: fa36d7f22f788a5c4aac2c41d31a689ce1ee702f
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Nov 12 17:24:17 EST 2023

main: show worker id in proc name

--- a/main.c
+++ b/main.c
@@ -5,6 +5,7 @@
 
 #include "dat.h"
 #include "fns.h"
+#include "atomic.h"
 
 Gefs *fs;
 
@@ -59,7 +60,7 @@
 static void
 launch(void (*f)(int, void *), void *arg, char *text)
 {
-	int pid;
+	long pid, id;
 
 	assert(fs->nworker < nelem(fs->lepoch));
 	pid = rfork(RFPROC|RFMEM|RFNOWAIT);
@@ -66,8 +67,9 @@
 	if (pid < 0)
 		sysfatal("can't fork: %r");
 	if (pid == 0) {
-		procsetname("%s", text);
-		(*f)(fs->nworker++, arg);
+		id = aincl(&fs->nworker, 1);
+		procsetname("%s.%ld", text, id);
+		(*f)(id, arg);
 		exits("child returned");
 	}
 }