mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-02 07:50:31 +00:00
Make fork() go 30% faster
This change makes fork() go nearly as fast as sys_fork() on UNIX. As for Windows this change shaves about 4-5ms off fork() + wait() latency. This is accomplished by using WriteProcessMemory() from the parent process to setup the address space of a suspended process; it is better than a pipe
This commit is contained in:
parent
98c5847727
commit
0b3c81dd4e
44 changed files with 769 additions and 649 deletions
16
third_party/gdtoa/lock.c
vendored
16
third_party/gdtoa/lock.c
vendored
|
@ -32,8 +32,8 @@
|
|||
#include "libc/thread/posixthread.internal.h"
|
||||
#include "third_party/gdtoa/lock.h"
|
||||
|
||||
pthread_mutex_t __gdtoa_lock_obj = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_t __gdtoa_lock1_obj = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t __gdtoa_lock_obj = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t __gdtoa_lock1_obj = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
void
|
||||
__gdtoa_lock(void)
|
||||
|
@ -47,6 +47,12 @@ __gdtoa_unlock(void)
|
|||
_pthread_mutex_unlock(&__gdtoa_lock_obj);
|
||||
}
|
||||
|
||||
void
|
||||
__gdtoa_wipe(void)
|
||||
{
|
||||
_pthread_mutex_wipe_np(&__gdtoa_lock_obj);
|
||||
}
|
||||
|
||||
void
|
||||
__gdtoa_lock1(void)
|
||||
{
|
||||
|
@ -58,3 +64,9 @@ __gdtoa_unlock1(void)
|
|||
{
|
||||
_pthread_mutex_unlock(&__gdtoa_lock1_obj);
|
||||
}
|
||||
|
||||
void
|
||||
__gdtoa_wipe1(void)
|
||||
{
|
||||
_pthread_mutex_wipe_np(&__gdtoa_lock1_obj);
|
||||
}
|
||||
|
|
6
third_party/gdtoa/lock.h
vendored
6
third_party/gdtoa/lock.h
vendored
|
@ -3,13 +3,13 @@
|
|||
#include "libc/thread/thread.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern pthread_mutex_t __gdtoa_lock_obj;
|
||||
extern pthread_mutex_t __gdtoa_lock1_obj;
|
||||
|
||||
void __gdtoa_lock(void);
|
||||
void __gdtoa_unlock(void);
|
||||
void __gdtoa_wipe(void);
|
||||
|
||||
void __gdtoa_lock1(void);
|
||||
void __gdtoa_unlock1(void);
|
||||
void __gdtoa_wipe1(void);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_THIRD_PARTY_GDTOA_LOCK_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue