Hi Jan,
Thank you for your reply. Please see my following comments. Thank you so much.
For the issue 2 the test case is very simple. The lock sequence is as below.
After ReadReg function I checked the lockcnt. The lockcnt is 1.
Int writeReg()
{
SMILock();
ReadReg();
......
SMIUnlock();
}
Int ReadReg()
{
SMILock();
/* Check the lockcnt here. It is still 1, should be 2 */
........
......
SMIUnlock();
}
-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Friday, August 23, 2019 11:23 AM
To: DIAO, Hanson (DI PA CI RC R&D SW2) <[email protected]>
Cc: [email protected]
Subject: Re: A potential Xenomai Mutex issue
On 23.08.19 16:29, DIAO, Hanson (DI PA CI RC R&D SW2) wrote:
> Hi Jan,
>
> I attached my code here. This is only Lock function. Unlock function is
> similar.
>
>
> printf("Before Mutex Lock Mutext addr = %p,count = %d, owner = %x\n",
> mpMutex,
> mpMutex->lockcnt,
> xnarch_atomic_get(mpMutex->fastlock));
> int err = rt_mutex_acquire( mpMutex, (RTIME)TM_INFINITE );
> if ( err &&
> // During boot-up and shutdown we run single-threaded
> // so there is no need to lock an semaphore.
> !(rc_system_state() != SYSTEM_RUNNING && err == -EPERM) )
> {
> rc_xeno_log( LOG_ERROR , "rt_mutex_acquire" , err);
> }
> printf("After Mutex Lock Mutext addr = %p,count = %d, owner = %x\n",
> mpMutex,
> mpMutex->lockcnt,
> xnarch_atomic_get(mpMutex->fastlock));
OK, now I understand the relation between "count" and "lockcnt". Thanks.
Again, for the deadlock case, can you reproduce it with synthetic patterns and
share them?
>
>
> For the issue 2 the test case is very simple. The lock sequence is as below.
> After ReadReg function I checked the lockcnt. The lockcnt is 1.
> Int writeReg()
> {
> SMILock();
> ReadReg();
So you are reading lockcnt here? Then 1 is obviously the expected value. Is
owner (fastlock) 0 here?
> ......
> SMIUnlock();
> }
>
> Int ReadReg()
> {
> SMILock();
If you read it here, it should be 2 in a recursive case.
Jan
> ........
> ......
> SMIUnlock();
> }
>
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center
Embedded Linux