A potential Xenomai Mutex issue

Jan Kiszka jan.kiszka at siemens.com
Fri Aug 23 17:23:20 CEST 2019


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



More information about the Xenomai mailing list