From de8951771162c140e4be81b129dc05ca6e220d77 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Thu, 9 Feb 2012 22:28:18 +0100 Subject: [PATCH] libblockdriver: increase stack size to 8KB per thread --- lib/libblockdriver/const.h | 3 +++ lib/libblockdriver/driver_mt.c | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/libblockdriver/const.h b/lib/libblockdriver/const.h index 941c4391c..5f475e3e9 100644 --- a/lib/libblockdriver/const.h +++ b/lib/libblockdriver/const.h @@ -1,6 +1,9 @@ #ifndef _BLOCKDRIVER_CONST_H #define _BLOCKDRIVER_CONST_H +/* Thread stack size. */ +#define STACK_SIZE 8192 + /* Maximum number of devices supported. */ #define MAX_DEVICES 32 diff --git a/lib/libblockdriver/driver_mt.c b/lib/libblockdriver/driver_mt.c index 0ec53e31e..b3c686c14 100644 --- a/lib/libblockdriver/driver_mt.c +++ b/lib/libblockdriver/driver_mt.c @@ -212,6 +212,7 @@ PRIVATE void master_create_worker(worker_t *wp, worker_id_t worker_id, { /* Start a new worker thread. */ + mthread_attr_t attr; int r; wp->device_id = device_id; @@ -221,8 +222,15 @@ PRIVATE void master_create_worker(worker_t *wp, worker_id_t worker_id, /* Initialize synchronization primitives. */ mthread_event_init(&wp->sleep_event); - r = mthread_create(&wp->mthread, NULL /*attr*/, worker_thread, (void *) wp); + r = mthread_attr_init(&attr); + if (r != 0) + panic("blockdriver_mt: could not initialize attributes (%d)", r); + + r = mthread_attr_setstacksize(&attr, STACK_SIZE); + if (r != 0) + panic("blockdriver_mt: could not set stack size (%d)", r); + r = mthread_create(&wp->mthread, &attr, worker_thread, (void *) wp); if (r != 0) panic("blockdriver_mt: could not start thread %d (%d)", worker_id, r); } -- 2.44.0