[PATCH] libblock: Do resource allocation in one place

Chris Johns chrisj at rtems.org
Thu Feb 21 09:09:19 UTC 2013


Sebastian Huber wrote:
> On 02/21/2013 03:56 AM, Chris Johns wrote:
>> Sebastian Huber wrote:
>>>
>>> - /*
>>> - * Create the worker threads.
>>> - */
>>> - rtems_bdbuf_swapout_workers_open ();
>>> -
>>
>> Why the need to move this to the bdbuf init ? The worker threads are
>> part of
>> the implementation of the swapout task. This abstraction is being
>> removed.
>
> The usage of worker threads is part of the configuration.

Hmmm interesting point of view. Not one I see as a strong argument.

> If we allocate
> all resources in rtems_bdbuf_init() we have consistent behaviour.

What determines "consistent behavior" ? Creating the tasks or letting 
them run to a blocking point ? This adds an interesting constraint to 
using the cache.

> The
> initialization may be either successful or a failure and nothing else.
> If we postpone the swapout and worker thread initialization the success
> is unpredictable and may lead to fatal system errors depending on the
> state of the overall application.

The swapout task is deterministic as it happens in the init. The worker 
threads, yes they could fail once the scheduler lets swap out run, but I 
fail to see the state argument. Either you have the resources to build a 
working system or you do not. The sequence not should not effect this. 
If the worker threads fail to start later and did before, whatever used 
the worker thread resources should fail later or you have another type 
of design issue.

>
>>>
>>> dev_t dev = 0;
>>>
>>> -static void initialize_swapout_task(void)
>>> -{
>>> - int fd = open(RAMDISK_PATH, O_RDONLY);
>>> - int rv = 0;
>>> -
>>> - rtems_test_assert(fd>= 0);
>>> -
>>> - rv = rtems_disk_fd_sync(fd);
>>> - rtems_test_assert(rv == 0);
>>> -
>>> - rv = close(fd);
>>> - rtems_test_assert(rv == 0);
>>> -}
>>
>> I do not understand why this call is needed. What is it working around ?
>
> This was necessary to force the swapout task initialization. Without
> this you cannot check the resource usage with
> rtems_resource_snapshot_take() etc.
>

Ah so the above is about making the snapshot work. Maybe there are other 
things such as changing the init priority or sleeping a little. There is 
always a level of fragility in a test like this unless you specifically 
adjust all parts of the system. That is something I am not entirely for.

Chris



More information about the devel mailing list