【发布时间】:2019-02-24 10:38:19
【问题描述】:
查看 glibc 代码时,观察到一行描述“请注意,我们不会重置 'tid' 字段中的 'used' 标志。这是由内核完成的”在 glibc_source(版本 2.21)中(@987654321 @) 在第 760 行。
据我了解,glibc 重用了缓存堆栈列表中维护的 T2 线程堆栈。但在重用该堆栈之前,它会检查 T1 的线程描述符中的 tid 字段(在 T1 的 pthread_join 之后已重置为 -1)。
T1 - First thread.
T2 - Second thread created after T1 exited.
根据文件 (allocatestack.c:760) 中的注释, struct pthread 的 'tid' 字段由 linux 内核重置。但是,据我了解,tid 字段由 pthread_join 重置。
内核如何重置'tid'字段?如果我的理解有误,请指正。
【问题讨论】:
标签: linux linux-kernel glibc