Skip to content

Commit

Permalink
Replace BigInt.shift_right with Z.shift_right
Browse files Browse the repository at this point in the history
  • Loading branch information
karoliineh committed Jan 15, 2024
1 parent 1b13207 commit b5e883b
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/regression/40-threadid/12-threads.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

#include <goblint.h>
#include <pthread.h>

/* Slab sizing definitions. */
#define POWER_SMALLEST 1
#define POWER_LARGEST 16 /* actual cap is 255 */
#define LARGEST_ID POWER_LARGEST
/* Locks for cache LRU operations */
pthread_mutex_t lru_locks[POWER_LARGEST];
static pthread_t item_crawler_tid;

int myglobal;

void memcached_thread_init(int nthreads, void *arg) {
int i;
for (i = 0; i < POWER_LARGEST; i++) {
pthread_mutex_init(&lru_locks[i], NULL);
}
}

void *item_crawler_thread(void *arg) {
int i, r1, r2;
for (i = POWER_SMALLEST; i < LARGEST_ID; i++) {
pthread_mutex_lock(&lru_locks[i]);
myglobal = myglobal + 1; // RACE!
if (r1) {
pthread_mutex_unlock(&lru_locks[i]);
continue;
}
// if (r2) {
// int x = 0;
// }
}
return NULL;
}

int main(void) {
int i;
int num_threads = rand();
memcached_thread_init(num_threads, NULL);
pthread_create(&item_crawler_tid, NULL, item_crawler_thread, NULL);
for (i = POWER_SMALLEST; i < LARGEST_ID; i++) {
pthread_mutex_lock(&lru_locks[i]);
myglobal = myglobal + 1; // RACE!
pthread_mutex_unlock(&lru_locks[i]);
}
pthread_join(&item_crawler_tid, NULL);
return 0;
}

0 comments on commit b5e883b

Please sign in to comment.