posix: epicsMutexShowAll() print if PI mutex are used

Confirms that pthread_mutex_t are actually being created
with PTHREAD_PRIO_INHERIT, ie. if both libc and kernel
support is present.
This commit is contained in:
Michael Davidsaver
2021-02-21 10:36:21 -08:00
parent 5a8b6e4111
commit 5593103c11
7 changed files with 33 additions and 0 deletions

View File

@@ -26,6 +26,9 @@ The IOC needs to run with SCHED_FIFO engaged.
Support for Posix implementations before POSIX.1-2001 (_XOPEN_SOURCE < 500,
glibc version < 2.3.3) has been dropped.
The epicsMutexShowAll() function (available through IOC shell)
will print "PI is enabled" if both libc and kernel support is present.
### Add epicsStrSimilarity()
Add epicsStrSimilarity() to epicsString.h which uses edit distance as an approximate comparison.

View File

@@ -17,6 +17,7 @@
* currently safe to convert a thread id to a thread name because
* the thread may have exited making the thread id invalid.
*/
#define EPICS_PRIVATE_API
#include <new>
@@ -223,6 +224,7 @@ void epicsStdCall epicsMutexShowAll(int onlyLocked,unsigned int level)
printf("ellCount(&mutexList) %d ellCount(&freeList) %d\n",
ellCount(&mutexList),ellCount(&freeList));
epicsMutexOsdShowAll();
epicsMutexLockStatus lockStat =
epicsMutexOsdLock(epicsMutexGlobalLock);
assert ( lockStat == epicsMutexLockOK );

View File

@@ -258,6 +258,9 @@ void epicsMutexOsdUnlock(struct epicsMutexOSD *);
epicsMutexLockStatus epicsMutexOsdLock(struct epicsMutexOSD *);
epicsMutexLockStatus epicsMutexOsdTryLock(struct epicsMutexOSD *);
void epicsMutexOsdShow(struct epicsMutexOSD *,unsigned int level);
#ifdef EPICS_PRIVATE_API
void epicsMutexOsdShowAll(void);
#endif
#ifdef __cplusplus
}

View File

@@ -22,6 +22,8 @@
#include <rtems.h>
#include <rtems/error.h>
#define EPICS_PRIVATE_API
#include "epicsStdio.h"
#include "epicsMutex.h"
#include "epicsEvent.h"
@@ -193,3 +195,5 @@ LIBCOM_API void epicsMutexOsdShow(struct epicsMutexOSD * id,unsigned int level)
#endif
epicsEventShow ((epicsEventId)id,level);
}
void epicsMutexOsdShowAll(void) {}

View File

@@ -42,6 +42,8 @@
#endif
#include <windows.h>
#define EPICS_PRIVATE_API
#include "libComAPI.h"
#include "epicsMutex.h"
#include "epicsAssert.h"
@@ -176,3 +178,5 @@ void epicsMutexOsdShow ( epicsMutexOSD * pSem, unsigned level )
}
}
void epicsMutexOsdShowAll(void) {}

View File

@@ -24,11 +24,14 @@
#include <unistd.h>
#include <pthread.h>
#define EPICS_PRIVATE_API
#include "epicsMutex.h"
#include "osdPosixMutexPriv.h"
#include "cantProceed.h"
#include "epicsTime.h"
#include "errlog.h"
#include "epicsStdio.h"
#include "epicsAssert.h"
#define checkStatus(status,message) \
@@ -188,3 +191,14 @@ void epicsMutexOsdShow(struct epicsMutexOSD * pmutex, unsigned int level)
*/
printf(" pthread_mutex_t* uaddr=%p\n", &pmutex->lock);
}
void epicsMutexOsdShowAll(void)
{
int proto = -1;
int ret = pthread_mutexattr_getprotocol(&globalAttrRecursive, &proto);
if(ret) {
printf("PI maybe not enabled: %d\n", ret);
} else {
printf("PI is%s enabled\n", proto==PTHREAD_PRIO_INHERIT ? "" : " not");
}
}

View File

@@ -20,6 +20,7 @@
/* The following not defined in an vxWorks header */
int sysClkRateGet(void);
#define EPICS_PRIVATE_API
#include "epicsMutex.h"
@@ -47,3 +48,5 @@ void epicsMutexOsdShow(struct epicsMutexOSD * id,unsigned int level)
{
semShow((SEM_ID)id,level);
}
void epicsMutexOsdShowAll(void) {}