Improve multithreading

This commit is contained in:
Justine Tunney 2024-07-21 06:41:30 -07:00
parent d3167126aa
commit 30afd6ddbb
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
38 changed files with 752 additions and 174 deletions

View file

@ -19,18 +19,16 @@
#include "libc/thread/thread.h"
/**
* Sets size of unmapped pages at bottom of stack.
* Sets size of protected region at bottom of thread stack.
*
* This value will be rounded up to the host microprocessor page size,
* which is usually 4096 or 16384. It's important to write code in such
* a way that that code can't skip over the guard area. GCC has warnings
* like `-Wframe-larger-than=4096 -Walloca-larger-than=4096` which help
* guarantee your code is safe in this regard. It should be assumed the
* guard pages exist beneath the stack pointer, rather than the bottom
* of the stack, since guard pages are also used to grow down commit,
* which can be poked using CheckLargeStackAllocation().
* Cosmopolitan sets this value to `sysconf(_SC_PAGESIZE)` by default.
*
* @param guardsize contains guard size in bytes
* You may set `guardsize` to disable the stack guard feature and gain a
* slight performance advantage by avoiding mprotect() calls. Note that
* it could make your code more prone to silent unreported corruption.
*
* @param guardsize contains guard size in bytes, which is implicitly
* rounded up to `sysconf(_SC_PAGESIZE)`, or zero to disable
* @return 0 on success, or errno on error
*/
errno_t pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize) {