💾 Archived View for thrig.me › blog › 2023 › 09 › 28 › stuckverybusy.c captured on 2024-07-09 at 01:42:09.

View Raw

More Information

⬅️ Previous capture (2023-09-28)

-=-=-=-=-=-=-

#include <err.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>

volatile int foo;

void *
busybee(void *unused)
{
	while (1) foo++;
}

int
main(void)
{
#define THC 32
	pthread_t th[THC];
	for (int i = 0; i < THC; i++)
		if (pthread_create(&th[i], NULL, busybee, NULL) != 0)
			err(1, "pthread_create");
	while (1) sleep(99999);
}