From 3c2fe264cd7ef9f73ba0dd5ba10a9b2c9cc54c83 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 8 Dec 2017 12:47:45 -0500 Subject: [PATCH] epicsThreadRealtimeLock: clarify errors give some more descriptive, linux specific, error messages --- modules/libcom/src/osi/os/posix/osdThread.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/libcom/src/osi/os/posix/osdThread.c b/modules/libcom/src/osi/os/posix/osdThread.c index 755390eed..c08dea40e 100644 --- a/modules/libcom/src/osi/os/posix/osdThread.c +++ b/modules/libcom/src/osi/os/posix/osdThread.c @@ -422,9 +422,24 @@ void epicsThreadRealtimeLock(void) int status = mlockall(MCL_CURRENT | MCL_FUTURE); if (status) { - fprintf(stderr, "epicsThreadRealtimeLock " - "Warning: Unable to lock the virtual address space.\n" - "VM page faults may harm real-time performance.\n"); + const int err = errno; + switch(err) { +#ifdef __linux__ + case ENOMEM: + fprintf(stderr, "epicsThreadRealtimeLock " + "Warning: unable to lock memory. RLIMIT_MEMLOCK is too small or missing CAP_IPC_LOCK\n"); + break; + case EPERM: + fprintf(stderr, "epicsThreadRealtimeLock " + "Warning: unable to lock memory. missing CAP_IPC_LOCK\n"); + break; +#endif + default: + fprintf(stderr, "epicsThreadRealtimeLock " + "Warning: Unable to lock the virtual address space.\n" + "VM page faults may harm real-time performance. errno=%d\n", + err); + } } } #endif