* [Xenomai-help] rt_mutex_acquire returns -3
@ 2009-08-14 7:31 Hans Søndergaard (HSO)
2009-08-14 8:26 ` Gilles Chanteperdrix
2009-08-14 9:41 ` Philippe Gerum
0 siblings, 2 replies; 7+ messages in thread
From: Hans Søndergaard (HSO) @ 2009-08-14 7:31 UTC (permalink / raw)
To: xenomai@xenomai.org
[-- Attachment #1: Type: text/plain, Size: 640 bytes --]
I use objects of type:
typedef struct object {
RT_MUTEX *rt_lock;
..
} Object;
int err = rt_mutex_create (ob->rt_lock, NULL);
printf ("[alloc.c]: rt_mutex_create err: %d; #%d \n", err, __LINE__);
err = rt_mutex_acquire (ob->rt_lock, TM_INFINITE);
printf ("[lock.c]: rt_mutex_acquire, err: %d; #%d \n", err, __LINE__);
On creation, rt_mutex_create returns 0 (as expected).
On acquiring, rt_mutex_acquire returns -3,
but this return value is not included among the possible return values in the documentation of Mutex services.
Could you please explain what this return value -3 means?
Best regards
Hans So
[-- Attachment #2: Type: text/html, Size: 4959 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [Xenomai-help] rt_mutex_acquire returns -3
2009-08-14 7:31 [Xenomai-help] rt_mutex_acquire returns -3 Hans Søndergaard (HSO)
@ 2009-08-14 8:26 ` Gilles Chanteperdrix
[not found] ` <0AB95BFCF14F984980DE7149C21D6B90065D58B5EA@FND-MAILB03.VIA.DK>
2009-08-14 9:41 ` Philippe Gerum
1 sibling, 1 reply; 7+ messages in thread
From: Gilles Chanteperdrix @ 2009-08-14 8:26 UTC (permalink / raw)
To: "Hans Søndergaard (HSO)"; +Cc: xenomai@xenomai.org
Hans Søndergaard (HSO) wrote:
> I use objects of type:
>
>
>
> typedef struct object {
>
> RT_MUTEX *rt_lock;
>
> ..
>
> } Object;
>
>
>
> int err = rt_mutex_create (ob->rt_lock, NULL);
>
> printf ("[alloc.c]: rt_mutex_create err: %d; #%d \n", err, __LINE__);
>
>
>
> err = rt_mutex_acquire (ob->rt_lock, TM_INFINITE);
>
> printf ("[lock.c]: rt_mutex_acquire, err: %d; #%d \n", err, __LINE__);
>
A question that may look stupid, is ob->rt_lock correctly initialised?
Also, why using a malloc for this, why not doing:
typedef struct object {
RT_MUTEX rt_lock;
/* ... */
} Object;
int err = rt_mutex_create (&ob->rt_lock, NULL);
err = rt_mutex_acquire (&ob->rt_lock, TM_INFINITE);
> On creation, rt_mutex_create returns 0 (as expected).
>
> On acquiring, rt_mutex_acquire returns -3,
>
> but this return value is not included among the possible return values
> in the documentation of Mutex services.
>
>
> Could you please explain what this return value -3 means?
3 is ESRCH, what version of Xenomai are you using?
--
Gilles
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [Xenomai-help] rt_mutex_acquire returns -3
2009-08-14 7:31 [Xenomai-help] rt_mutex_acquire returns -3 Hans Søndergaard (HSO)
2009-08-14 8:26 ` Gilles Chanteperdrix
@ 2009-08-14 9:41 ` Philippe Gerum
2009-08-22 7:49 ` Hans Søndergaard (HSO)
1 sibling, 1 reply; 7+ messages in thread
From: Philippe Gerum @ 2009-08-14 9:41 UTC (permalink / raw)
To: Hans Søndergaard (HSO); +Cc: xenomai@xenomai.org
On Fri, 2009-08-14 at 09:31 +0200, Hans Søndergaard (HSO) wrote:
> I use objects of type:
>
>
>
> typedef struct object {
>
> RT_MUTEX *rt_lock;
>
> ..
>
> } Object;
>
>
>
> int err = rt_mutex_create (ob->rt_lock, NULL);
>
> printf ("[alloc.c]: rt_mutex_create err: %d; #%d \n", err, __LINE__);
>
>
>
> err = rt_mutex_acquire (ob->rt_lock, TM_INFINITE);
>
> printf ("[lock.c]: rt_mutex_acquire, err: %d; #%d \n", err, __LINE__);
>
>
>
> On creation, rt_mutex_create returns 0 (as expected).
>
> On acquiring, rt_mutex_acquire returns -3,
>
-ESRCH. This means that for some reason, the internal handle copied by
rt_mutex_create() to ob->rt_lock could not be found back in the system
registry when calling rt_mutex_acquire().
Any chance ob->rt_lock may have been overwritten, or this mutex deleted
by another thread in the meantime?
In userland, RT_MUTEX is a structure containing an opaque long integer
value. Maybe you could check that value (printf("%ld",
ob->rt_lock.opaque)) right after rt_mutex_create() returns, and just
before rt_mutex_acquire() is invoked.
> but this return value is not included among the possible return values
> in the documentation of Mutex services.
>
>
>
> Could you please explain what this return value -3 means?
>
>
>
> Best regards
>
> Hans So
>
>
>
>
>
>
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
--
Philippe.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [Xenomai-help] rt_mutex_acquire returns -3
2009-08-14 9:41 ` Philippe Gerum
@ 2009-08-22 7:49 ` Hans Søndergaard (HSO)
2009-08-22 10:01 ` Gilles Chanteperdrix
0 siblings, 1 reply; 7+ messages in thread
From: Hans Søndergaard (HSO) @ 2009-08-22 7:49 UTC (permalink / raw)
To: Philippe Gerum; +Cc: xenomai@xenomai.org
Thank you to both Gilles and Philippe.
I followed the advises from you both:
typedef struct object {
RT_MUTEX rt_lock;
..
} Object;
and used:
printf("%ld", ob->rt_lock.opaque);
to see output.
For a general orientation: I am rewriting a Java VM: JamVM, for a Predictable Java profile (nearly the same as the Safety Critical Java proposal from SUN). The profile will be presented at JTRES 2009.
I use Xenomai as real-time OS.
Vh/Regards
Hans Sø
-----Original Message-----
From: Philippe Gerum [mailto:rpm@xenomai.org]
Sent: 14. august 2009 11:42
To: Hans Søndergaard (HSO)
Cc: xenomai-help@gna.org
Subject: Re: [Xenomai-help] rt_mutex_acquire returns -3
On Fri, 2009-08-14 at 09:31 +0200, Hans Søndergaard (HSO) wrote:
> I use objects of type:
>
>
>
> typedef struct object {
>
> RT_MUTEX *rt_lock;
>
> ..
>
> } Object;
>
>
>
> int err = rt_mutex_create (ob->rt_lock, NULL);
>
> printf ("[alloc.c]: rt_mutex_create err: %d; #%d \n", err, __LINE__);
>
>
>
> err = rt_mutex_acquire (ob->rt_lock, TM_INFINITE);
>
> printf ("[lock.c]: rt_mutex_acquire, err: %d; #%d \n", err, __LINE__);
>
>
>
> On creation, rt_mutex_create returns 0 (as expected).
>
> On acquiring, rt_mutex_acquire returns -3,
>
-ESRCH. This means that for some reason, the internal handle copied by
rt_mutex_create() to ob->rt_lock could not be found back in the system
registry when calling rt_mutex_acquire().
Any chance ob->rt_lock may have been overwritten, or this mutex deleted
by another thread in the meantime?
In userland, RT_MUTEX is a structure containing an opaque long integer
value. Maybe you could check that value (printf("%ld",
ob->rt_lock.opaque)) right after rt_mutex_create() returns, and just
before rt_mutex_acquire() is invoked.
> but this return value is not included among the possible return values
> in the documentation of Mutex services.
>
>
>
> Could you please explain what this return value -3 means?
>
>
>
> Best regards
>
> Hans So
>
>
>
>
>
>
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@gna.org
> https://mail.gna.org/listinfo/xenomai-help
--
Philippe.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [Xenomai-help] rt_mutex_acquire returns -3
2009-08-22 7:49 ` Hans Søndergaard (HSO)
@ 2009-08-22 10:01 ` Gilles Chanteperdrix
2009-08-22 18:44 ` Hans Søndergaard (HSO)
0 siblings, 1 reply; 7+ messages in thread
From: Gilles Chanteperdrix @ 2009-08-22 10:01 UTC (permalink / raw)
To: "Hans Søndergaard (HSO)"; +Cc: xenomai@xenomai.org
Hans Søndergaard (HSO) wrote:
> Thank you to both Gilles and Philippe.
> I followed the advises from you both:
> typedef struct object {
> RT_MUTEX rt_lock;
> ..
> } Object;
>
> and used:
> printf("%ld", ob->rt_lock.opaque);
> to see output.
So, what is the result? Did you find the bug?
--
Gilles.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [Xenomai-help] rt_mutex_acquire returns -3
2009-08-22 10:01 ` Gilles Chanteperdrix
@ 2009-08-22 18:44 ` Hans Søndergaard (HSO)
0 siblings, 0 replies; 7+ messages in thread
From: Hans Søndergaard (HSO) @ 2009-08-22 18:44 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai@xenomai.org
> So, what is the result? Did you find the bug?
Yes, I think so.
The problem was in my rewriting of JamVM. I have implemented Java PeriodicEventHandlers using periodic RT_TASKs, and re-implemented Java object allocation with synchronized methods, using RT_MUTEX to utilize the priority inheritance included in Xenomai. Each handler has a private native memoryArea (no Garbage Collector because of real-time constraints).
The allocation of a new object and calling its synchronized method now gives the output:
=> Native: enterNativeMemArea
[alloc.c]: rt_mutex_create err: 0;
[alloc.c]: ob->rt_lock.opaque: 75;
[lock.c]: ob->rt_lock.opaque: 75;
[lock.c]: rt_mutex_acquire, result 0;
[lock.c]: ob->rt_lock.opaque: 75;
[lock.c]: rt_mutex_release, result 0;
[alloc.c]: rt_mutex_delete, err: 0;
[alloc.c]: ob->rt_lock.opaque: 75;
=> Native: resetMemArea: after-before=used: 10232 - 10208 = 24 Bytes;
This should be OK.
I have (still) problems, if I use System.out.println in the synchronized method, but now I know it is because of my insufficient re-implementation of JamVM.
Vh/Regards
Hans Sø
-----Original Message-----
From: Gilles Chanteperdrix [mailto:gilles.chanteperdrix@xenomai.org]
Sent: 22. august 2009 12:02
To: Hans Søndergaard (HSO)
Cc: xenomai-help@gna.org
Subject: Re: [Xenomai-help] rt_mutex_acquire returns -3
Hans Søndergaard (HSO) wrote:
> Thank you to both Gilles and Philippe.
> I followed the advises from you both:
> typedef struct object {
> RT_MUTEX rt_lock;
> ..
> } Object;
>
> and used:
> printf("%ld", ob->rt_lock.opaque);
> to see output.
So, what is the result? Did you find the bug?
--
Gilles.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-08-22 18:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-14 7:31 [Xenomai-help] rt_mutex_acquire returns -3 Hans Søndergaard (HSO)
2009-08-14 8:26 ` Gilles Chanteperdrix
[not found] ` <0AB95BFCF14F984980DE7149C21D6B90065D58B5EA@FND-MAILB03.VIA.DK>
2009-08-14 9:20 ` Gilles Chanteperdrix
2009-08-14 9:41 ` Philippe Gerum
2009-08-22 7:49 ` Hans Søndergaard (HSO)
2009-08-22 10:01 ` Gilles Chanteperdrix
2009-08-22 18:44 ` Hans Søndergaard (HSO)
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.