Fix many thread and file descriptor issues on Windows

The greenbean web server now works nearly perfectly on Windows with over
1000 threads. But some synchronization issues still remain which prevent
us from going over nine thousand.
This commit is contained in:
Justine Tunney 2022-05-20 18:51:41 -07:00
parent 96781d0679
commit 7838edae88
32 changed files with 363 additions and 192 deletions

View file

@ -16,24 +16,30 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/bits/weaken.h"
#include "libc/calls/calls.h"
#include "libc/intrin/kprintf.h"
#include "libc/intrin/lockcmpxchgp.h"
#include "libc/intrin/spinlock.h"
#include "libc/log/log.h"
#include "libc/nexgen32e/rdtsc.h"
#include "libc/runtime/internal.h"
#include "libc/time/clockstonanos.internal.h"
void _spinlock_debug_4(void *lockptr, const char *lockname, const char *file,
int line, const char *func) {
privileged void _spinlock_debug_4(int *lock, const char *lockname,
const char *file, int line,
const char *func) {
unsigned i;
int me, owner;
uint64_t ts1, ts2;
int me, owner, *lock = lockptr;
me = gettid();
owner = 0;
if (!_lockcmpxchgp(lock, &owner, me)) {
if (owner == me) {
kprintf("%s:%d: warning: lock re-entry on %s in %s()\n", file, line,
kprintf("%s:%d: error: lock re-entry on %s in %s()\n", file, line,
lockname, func);
if (weaken(__die)) weaken(__die)();
__restorewintty();
_Exit(1);
}
i = 0;