[Glibc-bsd-commits] r4601 - trunk/glibc-ports/fbtl-misc
Petr Salinger
ps-guest at alioth.debian.org
Mon Jul 8 12:47:12 UTC 2013
Author: ps-guest
Date: 2013-06-24 08:17:22 +0000 (Mon, 24 Jun 2013)
New Revision: 4601
Added:
trunk/glibc-ports/fbtl-misc/pid-tid.txt
Log:
pid tid notes
Added: trunk/glibc-ports/fbtl-misc/pid-tid.txt
===================================================================
--- trunk/glibc-ports/fbtl-misc/pid-tid.txt (rev 0)
+++ trunk/glibc-ports/fbtl-misc/pid-tid.txt 2013-06-24 08:17:22 UTC (rev 4601)
@@ -0,0 +1,91 @@
+Under Linux:
+
+man set_tid_address
+man clone
+
+Similar interface exists in FreeBSD, but:
+
+the "wake point" is long (Linux: int).
+The "wake point" address is passed as an argument to thr_exit()
+(Linux: set via set_tid_address() earlier).
+
+thr_exit() for all but last thread
+will store "1" into "wake point" (linux stores "0").
+Both do wake "wake point" address.
+
+thr_exit() does not return for all but last thread,
+for last thread it returns. Usually standard exit(),
+with exit_code passed as an argument is called immediately after that.
+
+thr_new() stores the ktid/tid into two places - usually one for child
+and one for parent. It can write into both places even iff creating of
+thread fails in kernel later - parent have to clean it up in case of a failure.
+
+Under linux, the new process have the same pid and tid.
+It does not hold on FreeBSD.
+
+The value of ktit fits into positive int range.
+Currently:
+
+pid: 1 .. 99999
+ktid: 100001 .. INT_MAX
+
+
+****************************************************************************
+
+some hackery to align both long and int at the same place based
+on wordsize and endianness will be needed
+
+struct pthread
+{
+int a;
+ union {
+ struct {
+ int tid;
+ int pad;
+ };
+ long ktid;
+};
+};
+
+
+
+****************************************************************************
+sys/proc.h:
+
+/*
+ * We use process IDs <= pid_max <= PID_MAX; PID_MAX + 1 must also fit
+ * in a pid_t, as it is used to represent "no process group".
+ */
+#define PID_MAX 99999
+#define NO_PID 100000
+extern pid_t pid_max;
+
+
+****************************************************************************
+kern/ksubr_unit.c:
+ * These functions implement a mixed run-length/bitmap management of unit
+ * number spaces in a very memory efficient manner.
+ * Allocation policy is always lowest free number first.
+
+kern/kern_thread.c:
+
+ tid_unrhdr = new_unrhdr(PID_MAX + 2, INT_MAX, &tid_lock);
+
+****************************************************************************
+sys/thr.h:
+
+struct thr_param {
+ void (*start_func)(void *); /* thread entry function. */
+ void *arg; /* argument for entry function. */
+ char *stack_base; /* stack base address. */
+ size_t stack_size; /* stack size. */
+ char *tls_base; /* tls base address. */
+ size_t tls_size; /* tls size. */
+ long *child_tid; /* address to store new TID. */
+ long *parent_tid; /* parent accesses the new TID here. */
+ int flags; /* thread flags. */
+ struct rtprio *rtp; /* Real-time scheduling priority */
+ void *spare[3]; /* TODO: cpu affinity mask etc. */
+};
+
More information about the Glibc-bsd-commits
mailing list