On 04.01.2024 19:55, Kinsey Moore wrote:
On Thu, Jan 4, 2024 at 12:35 PM <berndmoessne...@gmail.com> wrote:
From: Bernd Moessner <berndmoessne...@gmail.com>
---
cpukit/dev/flash/flashdev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 8bd3d11246..0020e8d2c1 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -34,6 +34,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -490,7 +491,9 @@ static int rtems_flashdev_do_init(
void ( *destroy )( rtems_flashdev *flash )
)
{
- rtems_recursive_mutex_init( &flash->mutex, "RTEMS_FLASHDEV
Flash" );
+ char mtx_name[19];
+ sprintf(mtx_name, "FDEV_MTX_%08x", (unsigned int) flash);
+ rtems_recursive_mutex_init( &flash->mutex, (const char*)
&mtx_name );
None of the other uses of mutexes in cpukit differentiate between
various instantiations and the information you've added here is
already available if you know the mutex address and know that it's a
flash mutex.
Is there a reason this needs to differentiate between the various
instances where others don't?
Kinsey
I already know that i will require two instances of flashedev.
I had two thoughts on my mind:
a) I was worried that creating two mutex with the same name could cause
problems
b) Not sure if that already exists for RTEMS but I had those debug views
in mind where you can immediately see all kernel objects (tasks, mutex,
etc.).
Therefore, I thought about a way to make the mutex name unique.
Note: You've hit the weak spot and I've changed the implementation in a
later patch. Perhaps, I have completely misunderstood the docs:
https://docs.rtems.org/branches/master/c-user/self_contained_objects.html
The|name|must be persistent throughout the life-time of the mutex.
A|name|of|NULL|is valid. The mutex is unlocked after initialization.
Things worked out on my side, but I the "persistent" made me a worry
about the fact that mtx_name goes out scope. Therefore, I've added the
required buffer to the flashdev struct to store the name there.
I am open for all solutions: keeping Aarons implementation, passing NULL
as name, better ideas to create unique names.
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel