mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +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
|
@ -18,6 +18,7 @@
|
|||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/wait0.internal.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
|
@ -333,11 +334,17 @@ int main(int argc, char *argv[]) {
|
|||
// clean up terminal line
|
||||
kprintf("\r\e[K");
|
||||
|
||||
// clean up memory
|
||||
for (i = 0; i < threads; ++i) {
|
||||
if (stack) munmap(stack[i], GetStackSize());
|
||||
if (tls) free(tls[i]);
|
||||
// join the workers
|
||||
// this is how we guarantee stacks are safe to free
|
||||
if (tls && stack) {
|
||||
for (i = 0; i < threads; ++i) {
|
||||
_wait0((int *)(tls[i] + 0x38));
|
||||
munmap(stack[i], GetStackSize());
|
||||
free(tls[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// clean up memory
|
||||
free(hostips);
|
||||
free(stack);
|
||||
free(tls);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue