a question about atomic_cmpxchg in xnsynch_acquire

chensong_2000 at 189.cn chensong_2000 at 189.cn
Mon May 24 11:20:43 CEST 2021


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




More information about the Xenomai mailing list