mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 04:08:32 +00:00
Write some lock contention tests
This commit is contained in:
parent
42c38bc3e3
commit
c06ffd458c
19 changed files with 205 additions and 76 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/intrin/wait0.internal.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -131,10 +132,10 @@ struct Sauce *sauces;
|
|||
struct Strings strings;
|
||||
struct Sources sources;
|
||||
const char *buildroot;
|
||||
_Alignas(64) int galock;
|
||||
_Alignas(64) int readlock;
|
||||
_Alignas(64) int writelock;
|
||||
_Alignas(64) int reportlock;
|
||||
_Alignas(64) char galock;
|
||||
_Alignas(64) char readlock;
|
||||
_Alignas(64) char writelock;
|
||||
_Alignas(64) char reportlock;
|
||||
|
||||
unsigned Hash(const void *s, size_t l) {
|
||||
return max(1, crc32c(0, s, l));
|
||||
|
@ -316,7 +317,7 @@ void LoadRelationships(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
for (i = 0; i < threads; ++i) {
|
||||
_spinlock((int *)(tls[i] + 0x38));
|
||||
_wait0((int *)(tls[i] + 0x38));
|
||||
}
|
||||
getargs_destroy(&ga);
|
||||
}
|
||||
|
@ -431,7 +432,7 @@ void Explore(void) {
|
|||
}
|
||||
}
|
||||
for (i = 0; i < threads; ++i) {
|
||||
_spinlock((int *)(tls[i] + 0x38));
|
||||
_wait0((int *)(tls[i] + 0x38));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/intrin/wait0.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/threaded.h"
|
||||
|
@ -71,7 +72,7 @@ int main(int argc, char *argv[]) {
|
|||
usleep(1000);
|
||||
}
|
||||
for (i = 0; i < n; ++i) {
|
||||
_spinlock((int *)(tls[i] + 0x38));
|
||||
_wait0((int *)(tls[i] + 0x38));
|
||||
free(tls[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/nomultics.internal.h"
|
||||
#include "libc/intrin/wait0.internal.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -6357,7 +6358,7 @@ static int ExitWorker(void) {
|
|||
}
|
||||
if (monitortty) {
|
||||
terminatemonitor = true;
|
||||
_spinlock(monitortid);
|
||||
_wait0(monitortid);
|
||||
}
|
||||
_Exit(0);
|
||||
}
|
||||
|
@ -7295,7 +7296,7 @@ void RedBean(int argc, char *argv[]) {
|
|||
if (!IsTiny()) {
|
||||
if (monitortty) {
|
||||
terminatemonitor = true;
|
||||
_spinlock(monitortid);
|
||||
_wait0(monitortid);
|
||||
munmap(monitorstack, GetStackSize());
|
||||
free(monitortls);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue