+ int j;
+
+ /* Check the target bo's contents. */
+ data = gem_mmap(fd, handle, LINEAR_DWORDS, PROT_READ | PROT_WRITE);
+ for (j = 0; j < WIDTH*HEIGHT; j++)
+ igt_assert_f(data[j] == j,
+ "mismatch at %i: %i\n",
+ j, data[j]);
+ munmap(data, LINEAR_DWORDS);
+}
+
+static void *thread_run(void *data)
+{
+ struct thread *t = data;
+ int i;
+
+ for (i = 0; i < t->count; i++)
+ check_bo(t->fd, bo_handles[t->idx_arr[i]]);
+
+ return NULL;
+}
+
+static void thread_init(struct thread *t, int fd, int count)
+{
+ int i;
+
+ t->fd = fd;
+ t->count = count;
+ t->idx_arr = calloc(count, sizeof(int));
+ igt_assert(t->idx_arr);
+
+ for (i = 0; i < count; i++)
+ t->idx_arr[i] = i;
+
+ igt_permute_array(t->idx_arr, count, igt_exchange_int);
+}
+
+static void thread_fini(struct thread *t)
+{
+ free(t->idx_arr);
+}
+
+igt_simple_main
+{
+ struct thread *threads;
+ int fd, n, count, num_threads;
+