int memorytest_alloc_thread(void* _arg) { struct memorytest_alloc_thread_arg* arg = _arg; void** ptrs; int i; int ret;
ptrs = calloc(arg->count, sizeof(*ptrs)); if (!ptrs) { return ERR_NO_MEMORY;
}
/* Busy-wait until control thread says go. */ while (!atomic_load(&arg->go)) {
}
for (i = 0; i < arg->count; i++) {
ptrs[i] = malloc(arg->alloc_size); if (!ptrs[i]) {
ret = ERR_NO_MEMORY; goto err_malloc;
}
atomic_fetch_add(&arg->chunks_allocated, 1);
}
ret = 0;
err_malloc:
atomic_fetch_add(&arg->threads_done, 1); while (atomic_load(&arg->threads_done) !=
MEMORYTEST_CONCURRENT_ALLOCATION_THREADS) {
thread_sleep(10);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.