source: rtems/testsuites/libtests/block04/init.c @ b6911069

4.115
Last change on this file since b6911069 was b6911069, checked in by Sebastian Huber <sebastian.huber@…>, on 05/29/12 at 16:02:52

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.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup test_bdbuf
5 *
6 * @brief Bdbuf test.
7 */
8
9/*
10 * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include "tmacros.h"
28
29#include <rtems.h>
30#include <rtems/ramdisk.h>
31#include <rtems/bdbuf.h>
32#include <rtems/diskdevs.h>
33
34/* forward declarations to avoid warnings */
35static rtems_task Init(rtems_task_argument argument);
36
37#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
38
39#define PRIORITY_INIT 10
40
41#define PRIORITY_SWAPOUT 50
42
43#define PRIORITY_HIGH 30
44
45#define PRIORITY_LOW 40
46
47#define BLOCK_SIZE 512
48
49#define BLOCK_COUNT 1
50
51static const rtems_disk_device *dd;
52
53static rtems_id task_id_low;
54
55static rtems_id task_id_high;
56
57static void task_low(rtems_task_argument arg)
58{
59  rtems_status_code sc = RTEMS_SUCCESSFUL;
60  rtems_bdbuf_buffer *bd = NULL;
61
62  printk("L: try access: 0\n");
63
64  sc = rtems_bdbuf_get(dd, 0, &bd);
65  ASSERT_SC(sc);
66
67  printk("L: access: 0\n");
68
69  sc = rtems_task_resume(task_id_high);
70  ASSERT_SC(sc);
71
72  sc = rtems_bdbuf_sync(bd);
73  ASSERT_SC(sc);
74
75  printk("L: sync done: 0\n");
76
77  rtems_test_assert(false);
78}
79
80static void task_high(rtems_task_argument arg)
81{
82  rtems_status_code sc = RTEMS_SUCCESSFUL;
83  rtems_bdbuf_buffer *bd = NULL;
84
85  sc = rtems_task_suspend(RTEMS_SELF);
86  ASSERT_SC(sc);
87
88  printk("H: try access: 0\n");
89
90  sc = rtems_bdbuf_get(dd, 0, &bd);
91  ASSERT_SC(sc);
92
93  printk("H: access: 0\n");
94
95  printk("H: release: 0\n");
96
97  sc = rtems_bdbuf_release(bd);
98  ASSERT_SC(sc);
99
100  printk("H: release done: 0\n");
101
102  printk("*** END OF TEST BLOCK 4 ***\n");
103
104  exit(0);
105}
106
107static rtems_task Init(rtems_task_argument argument)
108{
109  rtems_status_code sc = RTEMS_SUCCESSFUL;
110  dev_t dev = 0;
111
112  printk("\n\n*** TEST BLOCK 4 ***\n");
113
114  sc = rtems_disk_io_initialize();
115  ASSERT_SC(sc);
116
117  sc = ramdisk_register(BLOCK_SIZE, BLOCK_COUNT, false, "/dev/rda", &dev);
118  ASSERT_SC(sc);
119
120  dd = rtems_disk_obtain(dev);
121  rtems_test_assert(dd != NULL);
122
123  sc = rtems_task_create(
124    rtems_build_name(' ', 'L', 'O', 'W'),
125    PRIORITY_LOW,
126    0,
127    RTEMS_DEFAULT_MODES,
128    RTEMS_DEFAULT_ATTRIBUTES,
129    &task_id_low
130  );
131  ASSERT_SC(sc);
132
133  sc = rtems_task_start(task_id_low, task_low, 0);
134  ASSERT_SC(sc);
135
136  sc = rtems_task_create(
137    rtems_build_name('H', 'I', 'G', 'H'),
138    PRIORITY_HIGH,
139    0,
140    RTEMS_DEFAULT_MODES,
141    RTEMS_DEFAULT_ATTRIBUTES,
142    &task_id_high
143  );
144  ASSERT_SC(sc);
145
146  sc = rtems_task_start(task_id_high, task_high, 0);
147  ASSERT_SC(sc);
148
149  sc = rtems_task_suspend(RTEMS_SELF);
150  ASSERT_SC(sc);
151}
152
153#define CONFIGURE_INIT
154
155#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
156#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
157#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
158
159#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
160
161#define CONFIGURE_MAXIMUM_TASKS 3
162#define CONFIGURE_MAXIMUM_DRIVERS 2
163
164#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
165
166#define CONFIGURE_INIT_TASK_PRIORITY PRIORITY_INIT
167#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
168#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
169
170#define CONFIGURE_SWAPOUT_TASK_PRIORITY PRIORITY_SWAPOUT
171
172#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE BLOCK_SIZE
173#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE BLOCK_SIZE
174#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE BLOCK_SIZE
175
176#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.