]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-process: Reserve PID/TID 0 for kernel
authorFlorin Postolache <florin.postolache.of@gmail.com>
Thu, 11 May 2023 10:07:48 +0000 (13:07 +0300)
committerUnikraft <monkey@unikraft.io>
Fri, 12 May 2023 08:19:04 +0000 (08:19 +0000)
This commit marks the TID/PID as unavailable to mimic the behaviour of
other kernels. This change also make pthread_rwlocks from glibc work in
binary compatibility mode.

Signed-off-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Andra Paraschiv <andra@unikraft.org>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #885

lib/posix-process/process.c

index ddea9631ebbe8e59d4ba2243df79c570685e6e48..02ad05fbb39bdcff0bfcf0e04e5b16b46812c96b 100644 (file)
@@ -83,9 +83,11 @@ struct posix_thread {
 
 /**
  * System global lists
+ * NOTE: We pre-allocate PID/TID 0 which is reserved by the kernel.
+ *       An application should never get PID/TID 0 assigned.
  */
 static struct posix_thread *tid_thread[TIDMAP_SIZE];
-static unsigned long tid_map[UK_BITS_TO_LONGS(TIDMAP_SIZE)];
+static unsigned long tid_map[UK_BITS_TO_LONGS(TIDMAP_SIZE)] = { [0] = 0x01UL };
 
 /**
  * Thread-local posix_thread reference