diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-05-29 18:02:52 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-05-31 11:05:48 +0200 |
commit | b6911069d42381b89505803e2c699b4271c25e96 (patch) | |
tree | c38a59068cfd7f62f03b3eee7dea6d39e77b8f0e /cpukit/libblock | |
parent | pc386: Added sections for rtems-libbsd support. (diff) | |
download | rtems-b6911069d42381b89505803e2c699b4271c25e96.tar.bz2 |
libblock: Add task stack size bdbuf configuration
The task stack size for the swap-out and worker tasks is now
configurable. The bdbuf task resources are now included in the work
space size estimate.
Diffstat (limited to 'cpukit/libblock')
-rw-r--r-- | cpukit/libblock/include/rtems/bdbuf.h | 13 | ||||
-rw-r--r-- | cpukit/libblock/src/bdbuf.c | 76 |
2 files changed, 51 insertions, 38 deletions
diff --git a/cpukit/libblock/include/rtems/bdbuf.h b/cpukit/libblock/include/rtems/bdbuf.h index 134a0ceff5..ead40206d1 100644 --- a/cpukit/libblock/include/rtems/bdbuf.h +++ b/cpukit/libblock/include/rtems/bdbuf.h @@ -363,14 +363,16 @@ typedef struct rtems_bdbuf_config { * at once. */ rtems_task_priority swapout_priority; /**< Priority of the swap out * task. */ - uint32_t swapout_period; /**< Period swapout checks buf + uint32_t swapout_period; /**< Period swap-out checks buf * timers. */ uint32_t swap_block_hold; /**< Period a buffer is held. */ size_t swapout_workers; /**< The number of worker - * threads for the swapout + * threads for the swap-out * task. */ rtems_task_priority swapout_worker_priority; /**< Priority of the swap out * task. */ + size_t task_stack_size; /**< Task stack size for swap-out + * task and worker threads. */ size_t size; /**< Size of memory in the * cache */ uint32_t buffer_min; /**< Minimum buffer size. */ @@ -418,12 +420,17 @@ extern const rtems_bdbuf_config rtems_bdbuf_configuration; #define RTEMS_BDBUF_SWAPOUT_WORKER_TASKS_DEFAULT 0 /** - * Default swap-out worker task priority. The same as the swapout task. + * Default swap-out worker task priority. The same as the swap-out task. */ #define RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT \ RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT /** + * Default task stack size for swap-out and worker tasks. + */ +#define RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT RTEMS_MINIMUM_STACK_SIZE + +/** * Default size of memory allocated to the cache. */ #define RTEMS_BDBUF_CACHE_MEMORY_SIZE_DEFAULT (64 * 512) diff --git a/cpukit/libblock/src/bdbuf.c b/cpukit/libblock/src/bdbuf.c index 593f19beaf..439da9883d 100644 --- a/cpukit/libblock/src/bdbuf.c +++ b/cpukit/libblock/src/bdbuf.c @@ -173,7 +173,6 @@ typedef struct rtems_bdbuf_cache #define RTEMS_BLKDEV_FATAL_BDBUF_SO_WAKE RTEMS_BLKDEV_FATAL_ERROR(20) #define RTEMS_BLKDEV_FATAL_BDBUF_SO_NOMEM RTEMS_BLKDEV_FATAL_ERROR(21) #define RTEMS_BLKDEV_FATAL_BDBUF_SO_WK_CREATE RTEMS_BLKDEV_FATAL_ERROR(22) -#define RTEMS_BLKDEV_FATAL_BDBUF_SO_WK_START RTEMS_BLKDEV_FATAL_ERROR(23) #define BLKDEV_FATAL_BDBUF_SWAPOUT_RE RTEMS_BLKDEV_FATAL_ERROR(24) #define BLKDEV_FATAL_BDBUF_SWAPOUT_TS RTEMS_BLKDEV_FATAL_ERROR(25) #define RTEMS_BLKDEV_FATAL_BDBUF_WAIT_EVNT RTEMS_BLKDEV_FATAL_ERROR(26) @@ -190,12 +189,6 @@ typedef struct rtems_bdbuf_cache #define RTEMS_BDBUF_SWAPOUT_SYNC RTEMS_EVENT_2 /** - * The swap out task size. Should be more than enough for most drivers with - * tracing turned on. - */ -#define SWAPOUT_TASK_STACK_SIZE (8 * 1024) - -/** * Lock semaphore attributes. This is used for locking type mutexes. * * @warning Priority inheritance is on. @@ -1287,6 +1280,35 @@ rtems_bdbuf_get_buffer_from_lru_list (const rtems_disk_device *dd, return NULL; } +static rtems_status_code +rtems_bdbuf_create_task( + rtems_name name, + rtems_task_priority priority, + rtems_task_priority default_priority, + rtems_task_entry entry, + rtems_task_argument arg, + rtems_id *id +) +{ + rtems_status_code sc; + size_t stack_size = bdbuf_config.task_stack_size ? + bdbuf_config.task_stack_size : RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT; + + priority = priority != 0 ? priority : default_priority; + + sc = rtems_task_create (name, + priority, + stack_size, + RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR, + RTEMS_LOCAL | RTEMS_NO_FLOATING_POINT, + id); + + if (sc == RTEMS_SUCCESSFUL) + sc = rtems_task_start (*id, entry, arg); + + return sc; +} + /** * Initialise the cache. * @@ -1456,20 +1478,12 @@ rtems_bdbuf_init (void) */ bdbuf_cache.swapout_enabled = true; - sc = rtems_task_create (rtems_build_name('B', 'S', 'W', 'P'), - bdbuf_config.swapout_priority ? - bdbuf_config.swapout_priority : - RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT, - SWAPOUT_TASK_STACK_SIZE, - RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR, - RTEMS_LOCAL | RTEMS_NO_FLOATING_POINT, - &bdbuf_cache.swapout); - if (sc != RTEMS_SUCCESSFUL) - goto error; - - sc = rtems_task_start (bdbuf_cache.swapout, - rtems_bdbuf_swapout_task, - (rtems_task_argument) &bdbuf_cache); + sc = rtems_bdbuf_create_task (rtems_build_name('B', 'S', 'W', 'P'), + bdbuf_config.swapout_priority, + RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT, + rtems_bdbuf_swapout_task, + 0, + &bdbuf_cache.swapout); if (sc != RTEMS_SUCCESSFUL) goto error; @@ -2639,22 +2653,14 @@ rtems_bdbuf_swapout_workers_open (void) rtems_chain_initialize_empty (&worker->transfer.bds); worker->transfer.dd = BDBUF_INVALID_DEV; - sc = rtems_task_create (rtems_build_name('B', 'D', 'o', 'a' + w), - (bdbuf_config.swapout_priority ? - bdbuf_config.swapout_priority : - RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT), - SWAPOUT_TASK_STACK_SIZE, - RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR, - RTEMS_LOCAL | RTEMS_NO_FLOATING_POINT, - &worker->id); + sc = rtems_bdbuf_create_task (rtems_build_name('B', 'D', 'o', 'a' + w), + bdbuf_config.swapout_worker_priority, + RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT, + rtems_bdbuf_swapout_worker_task, + (rtems_task_argument) worker, + &worker->id); if (sc != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_SO_WK_CREATE); - - sc = rtems_task_start (worker->id, - rtems_bdbuf_swapout_worker_task, - (rtems_task_argument) worker); - if (sc != RTEMS_SUCCESSFUL) - rtems_fatal_error_occurred (RTEMS_BLKDEV_FATAL_BDBUF_SO_WK_START); } rtems_bdbuf_unlock_cache (); |