Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _GNU_SOURCE
- #include <unistd.h>
- #include <pthread.h>
- #include <stdlib.h>
- #include <sys/sysinfo.h>
- #include <stdio.h>
- char *x;
- unsigned long long arena_size = 1L * 1024 * 1024 * 1024;
- unsigned long long start;
- void * worker(void *p) {
- int n;
- while (n<arena_size) {
- x[n]++;
- n += 4095;
- }
- }
- int main( int ac, char ** av ) {
- int n, nthr = get_nprocs();
- pthread_t *threads = malloc(sizeof(pthread_t) * nthr);
- x = malloc(arena_size);
- if (x==(caddr_t)-1) {
- exit(1);
- }
- for (n=0; n<nthr; n++)
- pthread_create(&threads[n], NULL, worker, NULL);
- while (n--)
- pthread_join(threads[n], NULL);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement