Opened on 12/16/16 at 16:25:04
Closed on 02/08/18 at 08:59:06
#2843 closed enhancement (fixed)
Use self-contained objects instead of Classic API for drivers and support libraries
Reported by: | Sebastian Huber | Owned by: | Sebastian Huber |
---|---|---|---|
Priority: | normal | Milestone: | 5.1 |
Component: | unspecified | Version: | 5 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: |
Description (last modified by Sebastian Huber)
The Classic API has some weaknesses:
- Dynamic memory (the workspace) is used to allocate object pools. This requires a complex configuration with heavy use of the C pre-processor.
- Objects are created via function calls which return an object identifier. The object operations use this identifier and map it internally to an object representation.
- The objects reside in a table, e.g. they are suspect to false sharing of cache lines.
- The object operations use a rich set of options and attributes. For each object operation these parameters must be evaluated and validated at run-time to figure out what to do exactly for this operation.
The overhead for Classic API mutexes used for example in Termios and the SPI framework is significant, see discussion:
https://lists.rtems.org/pipermail/devel/2016-December/016543.html
There are some API options available:
- Use C11 mutexes and condition variables.
- Turn the POSIX synchronization objects into self-contained objects and use them.
- Use FreeBSD synchronization objects like MUTEX(9) or CONDVAR(9).
- Add RTEMS-specific self-contained synchronization objects and use them.
Option 1. and 2. lack support for binary semaphores which are used for task/interrupt synchronization, e.g. Termios.
Option 2. needs run-time evaluation to figure out the actual object variant, e.g. non-recursive, recursive, ceiling, error-checking, robust POSIX mutex.
Option 3. uses hash tables, thus it is not suitable for real-time systems.
Option 1. and 2. lack support for user-defined object names that may help for system diagnostic, tracing and debugging.
Option 4. could be used to avoid all shortcomings of options 1-3. It would be trivial to implement, test and document.
In order to enable user-defined object names one option is to add a const char *name member to Thread_queue_Queue.
Change History (43)
comment:1 Changed on 12/20/16 at 08:15:06 by Sebastian Huber
Description: | modified (diff) |
---|---|
Summary: | Use C11 mutexes instead of Classic API priority inheritance semaphores → Use self-contained objects instead of Classic API for drivers and support libraries |
comment:2 follow-up: 3 Changed on 12/20/16 at 10:23:41 by Chris Johns
comment:3 Changed on 12/20/16 at 10:28:54 by Sebastian Huber
Replying to chrisj:
Can Option 4 be NP extensions to POSIX after Option 2 is done?
Binary semaphores are not available out of the box with POSIX. You need a mutex and a condition variable for this, e.g. http://stackoverflow.com/questions/7478684/how-to-initialise-a-binary-semaphore-in-c.
Option 4. should be implementable via POSIX to allow to run the software without RTEMS, however, it should use a specialized implementation on RTEMS to minimize run-time and space overheads.
comment:4 Changed on 12/20/16 at 19:34:28 by Gedare Bloom
What are the downsides for self-contained objects? (Is there a clear definition of what self-contained objects are?)
comment:5 Changed on 12/21/16 at 06:43:21 by Sebastian Huber
Self-contained means the user must provide the storage for the object.
What you cannot do with self-contained objects is using them in a distributed system with distinct address spaces, e.g. a usage case RTEMS was initially designed for. Here you need one level of indirection to identify objects globally.
With object identifiers you can detect a use of deleted objects under certain conditions. You cannot detect use of a deleted and re-used object. To detect/prevent the use of deleted objects in SMP configurations is quite difficult (e.g. hazard pointers) and not implemented in RTEMS.
From my point of view the advantages of self-contained objects are apparent.
comment:6 Changed on 05/11/17 at 07:31:02 by Sebastian Huber
Milestone: | 4.12 → 4.12.0 |
---|
comment:7 Changed on 05/11/17 at 07:42:40 by Sebastian Huber
Milestone: | 4.12.0 → 5.0 |
---|
comment:8 Changed on 08/14/17 at 00:55:55 by Chris Johns
Milestone: | 5.0 → 4.12.0 |
---|
Please review and update the milestone. Thanks.
comment:9 Changed on 10/12/17 at 02:23:15 by Joel Sherrill
Component: | score → bsps |
---|---|
Milestone: | 4.12.0 → 4.13.0 |
comment:10 Changed on 11/09/17 at 06:26:20 by Sebastian Huber
Milestone: | 4.13.0 → 5.0 |
---|
comment:11 Changed on 11/09/17 at 06:26:42 by Sebastian Huber
Milestone: | 5.0 → 6.1 |
---|
Milestone renamed
comment:13 Changed on 02/02/18 at 14:21:23 by Sebastian Huber <sebastian.huber@…>
In f14a04c6/rtems:
comment:14 Changed on 02/02/18 at 14:21:36 by Sebastian Huber <sebastian.huber@…>
In 1b2da177/rtems:
comment:15 Changed on 02/02/18 at 14:21:48 by Sebastian Huber <sebastian.huber@…>
In 8d7f3680/rtems:
comment:18 Changed on 02/02/18 at 14:22:35 by Sebastian Huber <sebastian.huber@…>
In 16fc3f9a/rtems:
comment:21 Changed on 02/02/18 at 14:23:11 by Sebastian Huber <sebastian.huber@…>
In 0940648f/rtems:
comment:23 Changed on 02/02/18 at 14:23:34 by Sebastian Huber <sebastian.huber@…>
In 03e5a780/rtems:
comment:24 Changed on 02/04/18 at 22:31:46 by Chris Johns
These changes are fantastic. It is so nice after all this time to see the internal allocation issue being solved in this way. Thank you.
comment:25 Changed on 02/05/18 at 08:47:18 by Sebastian Huber <sebastian.huber@…>
comment:27 Changed on 02/05/18 at 09:01:16 by Sebastian Huber <sebastian.huber@…>
comment:28 Changed on 02/05/18 at 10:39:43 by Sebastian Huber <sebastian.huber@…>
comment:29 Changed on 02/05/18 at 11:14:17 by Sebastian Huber
Component: | bsps → unspecified |
---|---|
Milestone: | 6.1 → 5.1 |
comment:32 Changed on 02/08/18 at 08:16:50 by Sebastian Huber <sebastian.huber@…>
In f9027ccf/rtems:
comment:33 Changed on 02/08/18 at 08:17:02 by Sebastian Huber <sebastian.huber@…>
In 868ca746/rtems:
comment:34 Changed on 02/08/18 at 08:17:17 by Sebastian Huber <sebastian.huber@…>
In a59a6182/rtems:
comment:35 Changed on 02/08/18 at 08:17:32 by Sebastian Huber <sebastian.huber@…>
In 0a593c2d/rtems:
comment:37 Changed on 02/08/18 at 08:17:59 by Sebastian Huber <sebastian.huber@…>
In 87b7117f/rtems:
comment:39 Changed on 02/08/18 at 08:18:26 by Sebastian Huber <sebastian.huber@…>
In 3535439f/rtems:
comment:41 Changed on 02/08/18 at 08:18:51 by Sebastian Huber <sebastian.huber@…>
In 2fd31117/rtems:
comment:42 Changed on 02/08/18 at 08:38:11 by Sebastian Huber <sebastian.huber@…>
In 9ace2648/rtems:
comment:43 Changed on 02/08/18 at 08:59:06 by Sebastian Huber
Resolution: | → fixed |
---|---|
Status: | new → closed |
All cpukit services use now self-contained objects, except:
- gxx_wrappers.c (legacy, would need GCC patch)
- ada_intrsupp.c (would need GCC patch)
- libi2c.c (legacy, I2C drivers should use new framework)
- sse_test.c (seems to be dead code)
Can Option 4 be NP extensions to POSIX after Option 2 is done?