All of lore.kernel.org
 help / color / mirror / Atom feed
* a question about atomic_cmpxchg in xnsynch_acquire
@ 2021-05-24  9:20 chensong_2000
  2021-05-24  9:52 ` chensong_2000
  0 siblings, 1 reply; 2+ messages in thread
From: chensong_2000 @ 2021-05-24  9:20 UTC (permalink / raw)
  To: xenomai

hi,

i'm working on mutex_timedlock64, the call stack roughly is supposed to be:

CoBaLt_mutex_timedlock64 -- __cobalt_mutex_timedlock_break -- 
xnsynch_acquire -- xnthread_suspend

however, it doesn't go to xnthread_suspend as expected, turns out it 
returns from here:

h = atomic_cmpxchg(lockp, XN_NO_HANDLE,
			   get_owner_handle(currh, synch));

	if (likely(h == XN_NO_HANDLE)) {
		set_current_owner(synch, curr);
		xnthread_get_resource(curr);
		return 0;
	}

atomic_cmpxchg returns 0.

i printed some information by
printk("%s, 1, curr handle: 0x%x, status: 0x%x, lockp: 0x%x\n", 
__FUNCTION__, currh, synch->status, lockp);
printk("curr: 0x%x, name:%s, owner: 0x%x\n ", curr, curr->name, 
synch->owner);

got these:
xnsynch_acquire, 1, curr handle: 0x20, status: 0xb, lockp: 0xb810e40
curr: 0x6c4408, name:lt-smokey, owner: 0x0


As far as my understanding, atomic_cmpxchg is supposed to assign curr 
handle (0x20) to lockp->v, is my unserstanding correct and is there 
anything i can do to dig into atomic_cmpxchg?

Any tips would be appreciated, many thanks.

BR

Song



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: a question about atomic_cmpxchg in xnsynch_acquire
  2021-05-24  9:20 a question about atomic_cmpxchg in xnsynch_acquire chensong_2000
@ 2021-05-24  9:52 ` chensong_2000
  0 siblings, 0 replies; 2+ messages in thread
From: chensong_2000 @ 2021-05-24  9:52 UTC (permalink / raw)
  To: xenomai

i initiated mutex in the main thread and acquire at the same context, is 
it wrong?

Should i lock it in the main thread and acquire it in another thread 
with a timeout?

i will try.

/Song

在 2021/5/24 下午5:20, chensong_2000--- via Xenomai 写道:
> hi,
> 
> i'm working on mutex_timedlock64, the call stack roughly is supposed to be:
> 
> CoBaLt_mutex_timedlock64 -- __cobalt_mutex_timedlock_break -- 
> xnsynch_acquire -- xnthread_suspend
> 
> however, it doesn't go to xnthread_suspend as expected, turns out it 
> returns from here:
> 
> h = atomic_cmpxchg(lockp, XN_NO_HANDLE,
>                 get_owner_handle(currh, synch));
> 
>      if (likely(h == XN_NO_HANDLE)) {
>          set_current_owner(synch, curr);
>          xnthread_get_resource(curr);
>          return 0;
>      }
> 
> atomic_cmpxchg returns 0.
> 
> i printed some information by
> printk("%s, 1, curr handle: 0x%x, status: 0x%x, lockp: 0x%x\n", 
> __FUNCTION__, currh, synch->status, lockp);
> printk("curr: 0x%x, name:%s, owner: 0x%x\n ", curr, curr->name, 
> synch->owner);
> 
> got these:
> xnsynch_acquire, 1, curr handle: 0x20, status: 0xb, lockp: 0xb810e40
> curr: 0x6c4408, name:lt-smokey, owner: 0x0
> 
> 
> As far as my understanding, atomic_cmpxchg is supposed to assign curr 
> handle (0x20) to lockp->v, is my unserstanding correct and is there 
> anything i can do to dig into atomic_cmpxchg?
> 
> Any tips would be appreciated, many thanks.
> 
> BR
> 
> Song
> 
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-24  9:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24  9:20 a question about atomic_cmpxchg in xnsynch_acquire chensong_2000
2021-05-24  9:52 ` chensong_2000

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.