From: Florin Postolache Date: Thu, 11 May 2023 10:07:48 +0000 (+0300) Subject: lib/posix-process: Reserve PID/TID 0 for kernel X-Git-Tag: RELEASE-0.13.0~19 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d4100c9dc4dfffdebd48ce8788d04ca3fa75d066;p=unikraft%2Funikraft.git lib/posix-process: Reserve PID/TID 0 for kernel 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 Reviewed-by: Simon Kuenzer Reviewed-by: Andra Paraschiv Approved-by: Simon Kuenzer Tested-by: Unikraft CI GitHub-Closes: #885 --- diff --git a/lib/posix-process/process.c b/lib/posix-process/process.c index ddea9631e..02ad05fbb 100644 --- a/lib/posix-process/process.c +++ b/lib/posix-process/process.c @@ -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