Browse Source

posix: improve error out for mlockall() and pthread_create

- add strerror
 - mlockall skipped in lockstep builds (ENABLE_LOCKSTEP_SCHEDULER)
release/1.12
Daniel Agar 4 years ago committed by GitHub
parent
commit
092060cde2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      platforms/posix/src/px4/common/main.cpp
  2. 2
      platforms/posix/src/px4/common/tasks.cpp

8
platforms/posix/src/px4/common/main.cpp

@ -178,13 +178,13 @@ int main(int argc, char **argv) @@ -178,13 +178,13 @@ int main(int argc, char **argv)
return client.process_args(argc, (const char **)argv);
} else {
#if (_POSIX_MEMLOCK > 0)
#if (_POSIX_MEMLOCK > 0) && !defined(ENABLE_LOCKSTEP_SCHEDULER)
// try to lock address space into RAM, to avoid page swap delay
// TODO: Check CAP_IPC_LOCK instead of euid
if (geteuid() == 0) { // root user
if (mlockall(MCL_CURRENT) + mlockall(MCL_FUTURE)) { // check if both works
PX4_ERR("mlockall() failed! errno: %d", errno);
if (mlockall(MCL_CURRENT | MCL_FUTURE)) { // check if both works
PX4_ERR("mlockall() failed! errno: %d (%s)", errno, strerror(errno));
munlockall(); // avoid mlock limitation caused alloc failure in future
} else {
@ -192,7 +192,7 @@ int main(int argc, char **argv) @@ -192,7 +192,7 @@ int main(int argc, char **argv)
}
}
#endif
#endif // (_POSIX_MEMLOCK > 0) && !ENABLE_LOCKSTEP_SCHEDULER
/* Server/daemon apps need to parse the command line arguments. */

2
platforms/posix/src/px4/common/tasks.cpp

@ -252,7 +252,7 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int @@ -252,7 +252,7 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
rv = pthread_create(&taskmap[taskid].pid, nullptr, &entry_adapter, (void *) taskdata);
if (rv != 0) {
PX4_ERR("px4_task_spawn_cmd: failed to create thread %d %d\n", rv, errno);
PX4_ERR("px4_task_spawn_cmd: failed to create thread for %s (%i): %s", name, rv, strerror(rv));
taskmap[taskid].isused = false;
pthread_attr_destroy(&attr);
pthread_mutex_unlock(&task_mutex);

Loading…
Cancel
Save