PatchworkOS
Loading...
Searching...
No Matches
main.c File Reference
#include <stdatomic.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/proc.h>
#include <threads.h>

Go to the source code of this file.

Macros

#define PRIME_MAX   (10000000)
 

Functions

bool is_prime (uint64_t n)
 
static void count_primes (uint64_t start, uint64_t end)
 
static int thread_entry (void *arg)
 
static void benchmark (uint64_t threadAmount)
 
int main (void)
 

Variables

static atomic_long count
 
static atomic_long next
 

Macro Definition Documentation

◆ PRIME_MAX

#define PRIME_MAX   (10000000)

Definition at line 7 of file main.c.

Function Documentation

◆ benchmark()

static void benchmark ( uint64_t  threadAmount)
static

◆ count_primes()

static void count_primes ( uint64_t  start,
uint64_t  end 
)
static

Definition at line 38 of file main.c.

References atomic_fetch_add, count, is_prime(), and start().

Referenced by thread_entry().

◆ is_prime()

bool is_prime ( uint64_t  n)

Definition at line 12 of file main.c.

Referenced by count_primes().

◆ main()

int main ( void  )

Definition at line 99 of file main.c.

References benchmark(), printf(), and threads.

◆ thread_entry()

static int thread_entry ( void *  arg)
static

Definition at line 49 of file main.c.

References atomic_fetch_add, count_primes(), next, PRIME_MAX, start(), and thrd_success.

Referenced by benchmark().

Variable Documentation

◆ count

◆ next