#3621 closed enhancement (fixed)

Statically initialize object information structures

Reported by: Sebastian Huber Owned by: Sebastian Huber
Priority: normal Milestone: 5.1
Component: score Version: 5
Severity: normal Keywords: qualification
Cc: Blocked By:
Blocking:

Description

Statically initialize the object information structures to make the configuration easier to review and simplify the debugging.

The workspace size estimate generated by <rtems/confdefs.h> looks currently like this:

  const rtems_configuration_table Configuration = { ( ( ( (ssize_t) ((((((1 +
0) != 0 ? 1 : 0) * ((Objects_Maximum) ((1 + 0) & ~0x80000000U))) *
(sizeof(Configuration_Thread_control))) != 0 ? 1 : 0) * ((((((1 + 0) != 0 ? 1 :
0) * ((Objects_Maximum) ((1 + 0) & ~0x80000000U))) *
(sizeof(Configuration_Thread_control)) + (2 * sizeof(uintptr_t) +
(sizeof(Heap_Protection_block_begin) + sizeof(Heap_Protection_block_end)))) +
((((sizeof(Heap_Block)) + (8) - 1) - ((sizeof(Heap_Block)) + (8) - 1) % (8))) -
1) - (((((1 + 0) != 0 ? 1 : 0) * ((Objects_Maximum) ((1 + 0) & ~0x80000000U)))
* (sizeof(Configuration_Thread_control)) + (2 * sizeof(uintptr_t) +
(sizeof(Heap_Protection_block_begin) + sizeof(Heap_Protection_block_end)))) +
((((sizeof(Heap_Block)) + (8) - 1) - ((sizeof(Heap_Block)) + (8) - 1) % (8)))

[more than 500 similar lines]

1) - (((sizeof(Configuration_Initial_Extensions) /
sizeof((Configuration_Initial_Extensions)[0])) *
sizeof(User_extensions_Switch_control) + (2 * sizeof(uintptr_t) +
(sizeof(Heap_Protection_block_begin) + sizeof(Heap_Protection_block_end)))) +
((((sizeof(Heap_Block)) + (8) - 1) - ((sizeof(Heap_Block)) + (8) - 1) % (8))) -
1) % ((((sizeof(Heap_Block)) + (8) - 1) - ((sizeof(Heap_Block)) + (8) - 1) %
(8)))))) + 0 + 0 + (0 * 1024) + ((((2 * sizeof(uintptr_t) +
(sizeof(Heap_Protection_block_begin) + sizeof(Heap_Protection_block_end)))) +
(8) - 1) - (((2 * sizeof(uintptr_t) + (sizeof(Heap_Protection_block_begin) +
sizeof(Heap_Protection_block_end)))) + (8) - 1) % (8)) ),

The object controls reside on the heap even for fixed object count configuration. Using a statically allocated array makes it easier to find the objects during debugging.

Change History (15)

comment:1 in reply to:  description Changed on 11/27/18 at 00:53:30 by Chris Johns

Replying to Sebastian Huber:

The object controls reside on the heap even for fixed object count configuration. Using a statically allocated array makes it easier to find the objects during debugging.

It is not clear me to what the requirements are these change are being based on? Is there some overriding push for everything to be static tables every where.

Static tables for initialisation do solve some issues such as audit-able configuration control but are there other use cases where this may not be a good fit. I cannot tell. For example statically inflexible kernel initialisation and libdl do not sit well together. The demands on the kernel configuration from the loadable code can vary and does and if you consider libdl as a means to produce "golden images" having the ability to vary the configuration is important. I have built systems where the bootloader loads the kernel configuration data and then loads the application. Can this still be done?

comment:2 Changed on 11/27/18 at 06:00:08 by Sebastian Huber

You can still do whatever you want after the system is initialized. I just want to get rid of the workspace allocations used during the system startup and instead use storage allocated by the linker.

comment:3 Changed on 11/27/18 at 06:05:25 by Chris Johns

Great and thank you.

comment:4 Changed on 12/07/18 at 13:33:28 by Sebastian Huber <sebastian.huber@…>

In f70079c/rtems:

score: Remove Objects_Information::the_api

Remove Objects_Information::the_class. This information is already
contained in Objects_Information::maximum_id.

Update #3621.

comment:5 Changed on 12/07/18 at 13:33:31 by Sebastian Huber <sebastian.huber@…>

In 1c2d178/rtems:

score: Remove Objects_Information::maximum

This information is already present in Objects_Information::maximum_id.
Add and use _Objects_Get_maximum_index().

Update #3621.

comment:6 Changed on 12/07/18 at 13:33:35 by Sebastian Huber <sebastian.huber@…>

In 3899bc1a/rtems:

score: Optimize object lookup

Use the maximum ID for the ID to object translation. Using the maximum
ID gets rid of an additional load from the object information in
_Objects_Get(). In addition, object lookups fail for every ID in case
the object information is cleared to zero. This makes it a bit more
robust during system startup (see new tests in spconfig02).

The local table no longer needs a NULL pointer entry at array index
zero. Adjust all the object iteration loops accordingly.

Remove Objects_Information::minimum_id since it contains only redundant
information. Add _Objects_Get_minimum_id() to get the minimum ID.

Update #3621.

comment:7 Changed on 12/07/18 at 13:33:38 by Sebastian Huber <sebastian.huber@…>

In 359a3a3/rtems:

score: Rename Objects_Information::allocation_size

Rename Objects_Information::allocation_size in
Objects_Information::objects_per_block. Adjust integer types in
_Objects_Shrink_information() and _Objects_Free().

Update #3621.

comment:8 Changed on 12/07/18 at 13:33:41 by Sebastian Huber <sebastian.huber@…>

In 0da9d80/rtems:

score: Rename Objects_Information::size

Rename Objects_Information::size to Objects_Information::object_size.
Change its type from size_t to uint16_t and move it to reduce the size
of Objects_Information.

Update #3621.

comment:9 Changed on 12/07/18 at 13:33:44 by Sebastian Huber <sebastian.huber@…>

In 9c9c6a9/rtems:

score: Remove Objects_Information::is_string

Use Objects_Information::name_length to store this information.

Update #3621.

comment:10 Changed on 12/07/18 at 13:33:48 by Sebastian Huber <sebastian.huber@…>

In d6e3473/rtems:

score: Remove dead code

Update #3621.

comment:11 Changed on 12/14/18 at 06:04:01 by Sebastian Huber <sebastian.huber@…>

In 8b0e752/rtems:

score: Remove Objects_Information::auto_extend

Use Objects_Information::objects_per_block to provide this information.
Add and use _Objects_Is_auto_extend().

Update #3621.

comment:12 Changed on 12/14/18 at 06:04:05 by Sebastian Huber <sebastian.huber@…>

In 0f5b2c09/rtems:

rtems: Use object information to get config max

Use functions instead of macros. Add missing
rtems_configuration_get_maximum_*() functions.

Update #3621.

comment:13 Changed on 12/14/18 at 06:04:08 by Sebastian Huber <sebastian.huber@…>

Resolution: fixed
Status: assignedclosed

In 21275b58/rtems:

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

comment:14 Changed on 01/02/20 at 08:49:12 by Sebastian Huber <sebastian.huber@…>

In a320aedd/rtems:

score: Fix objects node initialization

The objects node is statically initialized to one. Clear the node field
before it is set.

Update #3621.

comment:15 Changed on 06/23/21 at 07:16:03 by Sebastian Huber

Keywords: qualification added
Note: See TracTickets for help on using tickets.