Make some more fixes

This change deletes mkfifo() so that GNU Make on Windows will work in
parallel mode using its pipe-based implementation. There's an example
called greenbean2 now, which shows how to build a scalable web server
for Windows with 10k+ threads. The accuracy of clock_nanosleep is now
significantly improved on Linux.
This commit is contained in:
Justine Tunney 2023-10-09 11:56:21 -07:00
parent 820c3599ed
commit 3b4dbc9fdd
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
22 changed files with 870 additions and 330 deletions

View file

@ -23,7 +23,7 @@
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/clock.h"
#define MAXIMUM 1e8
#define MAXIMUM 1e9
#define ITERATIONS 10
void WarmUp(void) {
@ -33,34 +33,36 @@ void WarmUp(void) {
void TestSleepRealRelative(void) {
printf("\n");
printf("testing: clock_nanosleep(CLOCK_REALTIME) with relative timeout\n");
printf("testing: clock_nanosleep(CLOCK_REALTIME) with relative "
"timeout\n");
for (long nanos = 1; nanos < (long)MAXIMUM; nanos *= 2) {
struct timespec t1, t2, wf;
wf = timespec_fromnanos(nanos);
clock_gettime(CLOCK_REALTIME_PRECISE, &t1);
clock_gettime(CLOCK_REALTIME, &t1);
for (int i = 0; i < ITERATIONS; ++i) {
npassert(!clock_nanosleep(CLOCK_REALTIME, 0, &wf, 0));
}
clock_gettime(CLOCK_REALTIME_PRECISE, &t2);
clock_gettime(CLOCK_REALTIME, &t2);
long took = timespec_tonanos(timespec_sub(t2, t1)) / ITERATIONS;
printf("%,11ld ns sleep took %,11ld ns delta %,11ld ns\n", nanos, took,
printf("%,12ld ns sleep took %,12ld ns delta %,12ld ns\n", nanos, took,
took - nanos);
}
}
void TestSleepMonoRelative(void) {
printf("\n");
printf("testing: clock_nanosleep(CLOCK_MONOTONIC) with relative timeout\n");
printf("testing: clock_nanosleep(CLOCK_MONOTONIC) with relative "
"timeout\n");
for (long nanos = 1; nanos < (long)MAXIMUM; nanos *= 2) {
struct timespec t1, t2, wf;
wf = timespec_fromnanos(nanos);
clock_gettime(CLOCK_REALTIME_PRECISE, &t1);
clock_gettime(CLOCK_REALTIME, &t1);
for (int i = 0; i < ITERATIONS; ++i) {
npassert(!clock_nanosleep(CLOCK_MONOTONIC, 0, &wf, 0));
}
clock_gettime(CLOCK_REALTIME_PRECISE, &t2);
clock_gettime(CLOCK_REALTIME, &t2);
long took = timespec_tonanos(timespec_sub(t2, t1)) / ITERATIONS;
printf("%,11ld ns sleep took %,11ld ns delta %,11ld ns\n", nanos, took,
printf("%,12ld ns sleep took %,12ld ns delta %,12ld ns\n", nanos, took,
took - nanos);
}
}