mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-31 17:52:27 +00:00
Improve multithreading
This commit is contained in:
parent
d3167126aa
commit
30afd6ddbb
38 changed files with 752 additions and 174 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue