* [Xenomai] [PATCH] Xenomai-forge: psos: extended object names
@ 2013-10-22 13:05 Kim De Mey
2013-10-22 14:03 ` Philippe Gerum
0 siblings, 1 reply; 3+ messages in thread
From: Kim De Mey @ 2013-10-22 13:05 UTC (permalink / raw)
To: xenomai
Extend object names with number to make them unique
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Ronny Meeus <ronny.meeus@gmail.com>
Signed-off-by: Kim De Mey <kim.demey@gmail.com>
---
Although this is not a requirement for pSOS, it would be nice to have
unique names for debugging purposes. This comes especially in the picture
with the implementation of registry for pSOS. Without unique names no
object with duplicate name will be added to registry. Unless changes
are made to the creation of the files.
lib/psos/queue.c | 5 ++++-
lib/psos/rn.c | 5 ++++-
lib/psos/sem.c | 5 ++++-
lib/psos/task.c | 5 ++++-
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/lib/psos/queue.c b/lib/psos/queue.c
--- a/lib/psos/queue.c
+++ b/lib/psos/queue.c
@@ -99,7 +99,10 @@ static u_long __q_create(const char *nam
sprintf(q->name, "q%lu", ++anon_qids);
else {
name = __psos_maybe_short_name(short_name, name);
- strncpy(q->name, name, sizeof(q->name));
+ if (cluster_findobj(&psos_queue_table, name) != NULL)
+ snprintf(q->name,sizeof(q->name), "%s_%lu", name, ++anon_qids);
+ else
+ strncpy(q->name, name, sizeof(q->name));
q->name[sizeof(q->name) - 1] = '\0';
}
diff --git a/lib/psos/rn.c b/lib/psos/rn.c
--- a/lib/psos/rn.c
+++ b/lib/psos/rn.c
@@ -115,7 +115,10 @@ u_long rn_create(const char *name, void
sprintf(rn->name, "rn%lu", ++anon_rnids);
else {
name = __psos_maybe_short_name(short_name, name);
- strncpy(rn->name, name, sizeof(rn->name));
+ if (cluster_findobj(&psos_rn_table, name) != NULL)
+ snprintf(rn->name,sizeof(rn->name), "%s_%lu", name, ++anon_rnids);
+ else
+ strncpy(rn->name, name, sizeof(rn->name));
rn->name[sizeof(rn->name) - 1] = '\0';
}
diff --git a/lib/psos/sem.c b/lib/psos/sem.c
--- a/lib/psos/sem.c
+++ b/lib/psos/sem.c
@@ -93,7 +93,10 @@ u_long sm_create(const char *name,
sprintf(sem->name, "sm%lu", ++anon_smids);
else {
name = __psos_maybe_short_name(short_name, name);
- strncpy(sem->name, name, sizeof(sem->name));
+ if (cluster_findobj(&psos_sem_table, name) != NULL)
+ snprintf(sem->name,sizeof(sem->name), "%s_%lu", name, ++anon_smids);
+ else
+ strncpy(sem->name, name, sizeof(sem->name));
sem->name[sizeof(sem->name) - 1] = '\0';
}
diff --git a/lib/psos/task.c b/lib/psos/task.c
--- a/lib/psos/task.c
+++ b/lib/psos/task.c
@@ -285,7 +285,10 @@ u_long t_create(const char *name, u_long
sprintf(task->name, "t%lu", ++anon_tids);
else {
name = __psos_maybe_short_name(short_name, name);
- strncpy(task->name, name, sizeof(task->name));
+ if (cluster_findobj(&psos_task_table, name) != NULL)
+ snprintf(task->name,sizeof(task->name), "%s_%lu", name, ++anon_tids);
+ else
+ strncpy(task->name, name, sizeof(task->name));
task->name[sizeof(task->name) - 1] = '\0';
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai] [PATCH] Xenomai-forge: psos: extended object names
2013-10-22 13:05 [Xenomai] [PATCH] Xenomai-forge: psos: extended object names Kim De Mey
@ 2013-10-22 14:03 ` Philippe Gerum
2013-10-22 14:45 ` Kim De Mey
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Gerum @ 2013-10-22 14:03 UTC (permalink / raw)
To: Kim De Mey, xenomai
On 10/22/2013 03:05 PM, Kim De Mey wrote:
> Extend object names with number to make them unique
>
> Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
> Signed-off-by: Ronny Meeus <ronny.meeus@gmail.com>
> Signed-off-by: Kim De Mey <kim.demey@gmail.com>
>
> ---
>
> Although this is not a requirement for pSOS, it would be nice to have
> unique names for debugging purposes. This comes especially in the picture
> with the implementation of registry for pSOS. Without unique names no
> object with duplicate name will be added to registry. Unless changes
> are made to the creation of the files.
>
I'm ok with the intent, not with the implementation. Please check how
the alchemy API does this via alchemy_build_name().
This will keep the name generation in a single place, and also fix a
race in the current pSOS emulator code, which post-increments anon_*ids
in a sloppy non-atomic way.
--
Philippe.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai] [PATCH] Xenomai-forge: psos: extended object names
2013-10-22 14:03 ` Philippe Gerum
@ 2013-10-22 14:45 ` Kim De Mey
0 siblings, 0 replies; 3+ messages in thread
From: Kim De Mey @ 2013-10-22 14:45 UTC (permalink / raw)
To: Philippe Gerum; +Cc: xenomai
2013/10/22 Philippe Gerum <rpm@xenomai.org>
> On 10/22/2013 03:05 PM, Kim De Mey wrote:
>
>> Extend object names with number to make them unique
>>
>> Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@**
>> gmail.com <thomas.de.schampheleire@gmail.com>>
>> Signed-off-by: Ronny Meeus <ronny.meeus@gmail.com>
>> Signed-off-by: Kim De Mey <kim.demey@gmail.com>
>>
>> ---
>>
>> Although this is not a requirement for pSOS, it would be nice to have
>> unique names for debugging purposes. This comes especially in the picture
>> with the implementation of registry for pSOS. Without unique names no
>> object with duplicate name will be added to registry. Unless changes
>> are made to the creation of the files.
>>
>>
> I'm ok with the intent, not with the implementation. Please check how the
> alchemy API does this via alchemy_build_name().
>
> This will keep the name generation in a single place, and also fix a race
> in the current pSOS emulator code, which post-increments anon_*ids in a
> sloppy non-atomic way.
>
>
Okay, I will adjust the patch to have a similar implementation as the one
of alchemy.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-22 14:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-22 13:05 [Xenomai] [PATCH] Xenomai-forge: psos: extended object names Kim De Mey
2013-10-22 14:03 ` Philippe Gerum
2013-10-22 14:45 ` Kim De Mey
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.