From d60f201dc86668ba4eb485f732487bac7a295da1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 19 Oct 2015 13:35:46 +0200 Subject: [PATCH] POSIX: Fix formatting --- src/platforms/posix/include/crc32.h | 2 +- src/platforms/posix/include/queue.h | 32 ++--- src/platforms/posix/main.cpp | 2 + src/platforms/posix/px4_layer/drv_hrt.c | 1 + src/platforms/posix/px4_layer/lib_crc32.c | 85 ++++++------ .../posix/px4_layer/px4_posix_tasks.cpp | 121 +++++++++++------- src/platforms/posix/px4_layer/px4_sem.cpp | 10 +- src/platforms/posix/work_queue/hrt_thread.c | 2 +- 8 files changed, 140 insertions(+), 115 deletions(-) diff --git a/src/platforms/posix/include/crc32.h b/src/platforms/posix/include/crc32.h index bf828e3e0e..34e080b1c2 100644 --- a/src/platforms/posix/include/crc32.h +++ b/src/platforms/posix/include/crc32.h @@ -63,7 +63,7 @@ extern "C" { ****************************************************************************/ EXTERN uint32_t crc32part(const uint8_t *src, size_t len, - uint32_t crc32val); + uint32_t crc32val); /**************************************************************************** * Name: crc32 diff --git a/src/platforms/posix/include/queue.h b/src/platforms/posix/include/queue.h index 4d95541e02..30dc264f3f 100644 --- a/src/platforms/posix/include/queue.h +++ b/src/platforms/posix/include/queue.h @@ -69,30 +69,26 @@ * Global Type Declarations ************************************************************************/ -struct sq_entry_s -{ - FAR struct sq_entry_s *flink; +struct sq_entry_s { + FAR struct sq_entry_s *flink; }; typedef struct sq_entry_s sq_entry_t; -struct dq_entry_s -{ - FAR struct dq_entry_s *flink; - FAR struct dq_entry_s *blink; +struct dq_entry_s { + FAR struct dq_entry_s *flink; + FAR struct dq_entry_s *blink; }; typedef struct dq_entry_s dq_entry_t; -struct sq_queue_s -{ - FAR sq_entry_t *head; - FAR sq_entry_t *tail; +struct sq_queue_s { + FAR sq_entry_t *head; + FAR sq_entry_t *tail; }; typedef struct sq_queue_s sq_queue_t; -struct dq_queue_s -{ - FAR dq_entry_t *head; - FAR dq_entry_t *tail; +struct dq_queue_s { + FAR dq_entry_t *head; + FAR dq_entry_t *tail; }; typedef struct dq_queue_s dq_queue_t; @@ -112,11 +108,11 @@ EXTERN void dq_addfirst(FAR dq_entry_t *node, dq_queue_t *queue); EXTERN void sq_addlast(FAR sq_entry_t *node, sq_queue_t *queue); EXTERN void dq_addlast(FAR dq_entry_t *node, dq_queue_t *queue); EXTERN void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node, - sq_queue_t *queue); + sq_queue_t *queue); EXTERN void dq_addafter(FAR dq_entry_t *prev, FAR dq_entry_t *node, - dq_queue_t *queue); + dq_queue_t *queue); EXTERN void dq_addbefore(FAR dq_entry_t *next, FAR dq_entry_t *node, - dq_queue_t *queue); + dq_queue_t *queue); EXTERN FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue); EXTERN void sq_rem(FAR sq_entry_t *node, sq_queue_t *queue); diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index fd9fdef5c6..26465c266e 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -96,6 +96,7 @@ static void run_cmd(const vector &appargs, bool exit_on_fail) if (exit_on_fail && retval) { exit(retval); } + usleep(65000); } else if (command.compare("help") == 0) { @@ -108,6 +109,7 @@ static void run_cmd(const vector &appargs, bool exit_on_fail) cout << "Invalid command: " << command << "\ntype 'help' for a list of commands" << endl; } + print_prompt(); } diff --git a/src/platforms/posix/px4_layer/drv_hrt.c b/src/platforms/posix/px4_layer/drv_hrt.c index cae3c379da..c925574b42 100644 --- a/src/platforms/posix/px4_layer/drv_hrt.c +++ b/src/platforms/posix/px4_layer/drv_hrt.c @@ -237,6 +237,7 @@ void hrt_init(void) sq_init(&callout_queue); int sem_ret = px4_sem_init(&_hrt_lock, 0, 1); + if (sem_ret) { PX4_ERR("SEM INIT FAIL: %s", strerror(errno)); } diff --git a/src/platforms/posix/px4_layer/lib_crc32.c b/src/platforms/posix/px4_layer/lib_crc32.c index 4ba6fbf6df..c14ebfceeb 100644 --- a/src/platforms/posix/px4_layer/lib_crc32.c +++ b/src/platforms/posix/px4_layer/lib_crc32.c @@ -48,46 +48,45 @@ #include // Needed for Linux -#define FAR +#define FAR /************************************************************************************************ * Private Data ************************************************************************************************/ - -static const uint32_t crc32_tab[] = -{ - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, - 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, - 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, - 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, - 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, - 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, - 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, - 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, - 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, - 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, - 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, - 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, - 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, - 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, - 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, - 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, - 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, - 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d + +static const uint32_t crc32_tab[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; /************************************************************************************************ @@ -103,13 +102,13 @@ static const uint32_t crc32_tab[] = uint32_t crc32part(FAR const uint8_t *src, size_t len, uint32_t crc32val) { - size_t i; + size_t i; + + for (i = 0; i < len; i++) { + crc32val = crc32_tab[(crc32val ^ src[i]) & 0xff] ^ (crc32val >> 8); + } - for (i = 0; i < len; i++) - { - crc32val = crc32_tab[(crc32val ^ src[i]) & 0xff] ^ (crc32val >> 8); - } - return crc32val; + return crc32val; } /************************************************************************************************ @@ -122,5 +121,5 @@ uint32_t crc32part(FAR const uint8_t *src, size_t len, uint32_t crc32val) uint32_t crc32(FAR const uint8_t *src, size_t len) { - return crc32part(src, len, 0); + return crc32part(src, len, 0); } diff --git a/src/platforms/posix/px4_layer/px4_posix_tasks.cpp b/src/platforms/posix/px4_layer/px4_posix_tasks.cpp index f112290cb3..ba476b5070 100644 --- a/src/platforms/posix/px4_layer/px4_posix_tasks.cpp +++ b/src/platforms/posix/px4_layer/px4_posix_tasks.cpp @@ -63,8 +63,7 @@ pthread_t _shell_task_id = 0; -struct task_entry -{ +struct task_entry { pthread_t pid; std::string name; bool isused; @@ -73,27 +72,26 @@ struct task_entry static task_entry taskmap[PX4_MAX_TASKS]; -typedef struct -{ +typedef struct { px4_main_t entry; int argc; char *argv[]; - // strings are allocated after the + // strings are allocated after the } pthdata_t; -static void *entry_adapter ( void *ptr ) +static void *entry_adapter(void *ptr) { - pthdata_t *data; - data = (pthdata_t *) ptr; + pthdata_t *data; + data = (pthdata_t *) ptr; data->entry(data->argc, data->argv); free(ptr); PX4_DEBUG("Before px4_task_exit"); - px4_task_exit(0); + px4_task_exit(0); PX4_DEBUG("After px4_task_exit"); return NULL; -} +} void px4_systemreset(bool to_bootloader) @@ -102,7 +100,8 @@ px4_systemreset(bool to_bootloader) exit(0); } -px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_size, px4_main_t entry, char * const argv[]) +px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_size, px4_main_t entry, + char *const argv[]) { int rv; int argc = 0; @@ -110,52 +109,62 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int unsigned int len = 0; unsigned long offset; unsigned long structsize; - char * p = (char *)argv; + char *p = (char *)argv; - pthread_t task; + pthread_t task; pthread_attr_t attr; struct sched_param param; // Calculate argc while (p != (char *)0) { p = argv[argc]; - if (p == (char *)0) + + if (p == (char *)0) { break; + } + ++argc; - len += strlen(p)+1; + len += strlen(p) + 1; } - structsize = sizeof(pthdata_t)+(argc+1)*sizeof(char *); + + structsize = sizeof(pthdata_t) + (argc + 1) * sizeof(char *); pthdata_t *taskdata; - + // not safe to pass stack data to the thread creation - taskdata = (pthdata_t *)malloc(structsize+len); - offset = ((unsigned long)taskdata)+structsize; + taskdata = (pthdata_t *)malloc(structsize + len); + offset = ((unsigned long)taskdata) + structsize; - taskdata->entry = entry; + taskdata->entry = entry; taskdata->argc = argc; - for (i=0; iargv[i] = (char *)offset; strcpy((char *)offset, argv[i]); - offset+=strlen(argv[i])+1; + offset += strlen(argv[i]) + 1; } + // Must add NULL at end of argv taskdata->argv[argc] = (char *)0; PX4_DEBUG("starting task %s", name); rv = pthread_attr_init(&attr); + if (rv != 0) { PX4_WARN("px4_task_spawn_cmd: failed to init thread attrs"); return (rv < 0) ? rv : -rv; } + rv = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + if (rv != 0) { PX4_WARN("px4_task_spawn_cmd: failed to set inherit sched"); return (rv < 0) ? rv : -rv; } + rv = pthread_attr_setschedpolicy(&attr, scheduler); + if (rv != 0) { PX4_WARN("px4_task_spawn_cmd: failed to set sched policy"); return (rv < 0) ? rv : -rv; @@ -164,28 +173,31 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int param.sched_priority = priority; rv = pthread_attr_setschedparam(&attr, ¶m); + if (rv != 0) { PX4_WARN("px4_task_spawn_cmd: failed to set sched param"); return (rv < 0) ? rv : -rv; } - rv = pthread_create (&task, &attr, &entry_adapter, (void *) taskdata); + rv = pthread_create(&task, &attr, &entry_adapter, (void *) taskdata); + if (rv != 0) { if (rv == EPERM) { //printf("WARNING: NOT RUNING AS ROOT, UNABLE TO RUN REALTIME THREADS\n"); - rv = pthread_create (&task, NULL, &entry_adapter, (void *) taskdata); + rv = pthread_create(&task, NULL, &entry_adapter, (void *) taskdata); + if (rv != 0) { PX4_ERR("px4_task_spawn_cmd: failed to create thread %d %d\n", rv, errno); return (rv < 0) ? rv : -rv; } - } - else { + + } else { return (rv < 0) ? rv : -rv; } } - for (i=0; i=PX4_MAX_TASKS) { + + if (i >= PX4_MAX_TASKS) { return -ENOSPC; } - return i; + + return i; } int px4_task_delete(px4_task_t id) @@ -205,15 +219,18 @@ int px4_task_delete(px4_task_t id) pthread_t pid; PX4_DEBUG("Called px4_task_delete"); - if (id < PX4_MAX_TASKS && taskmap[id].isused) + if (id < PX4_MAX_TASKS && taskmap[id].isused) { pid = taskmap[id].pid; - else + + } else { return -EINVAL; + } // If current thread then exit, otherwise cancel - if (pthread_self() == pid) { + if (pthread_self() == pid) { taskmap[id].isused = false; pthread_exit(0); + } else { rv = pthread_cancel(pid); } @@ -225,20 +242,21 @@ int px4_task_delete(px4_task_t id) void px4_task_exit(int ret) { - int i; + int i; pthread_t pid = pthread_self(); // Get pthread ID from the opaque ID - for (i=0; i=PX4_MAX_TASKS) { + + if (i >= PX4_MAX_TASKS) { PX4_ERR("px4_task_exit: self task not found!"); - } - else { + + } else { PX4_DEBUG("px4_task_exit: %s", taskmap[i].name.c_str()); } @@ -251,10 +269,12 @@ int px4_task_kill(px4_task_t id, int sig) pthread_t pid; PX4_DEBUG("Called px4_task_kill %d", sig); - if (id < PX4_MAX_TASKS && taskmap[id].isused && taskmap[id].pid != 0) + if (id < PX4_MAX_TASKS && taskmap[id].isused && taskmap[id].pid != 0) { pid = taskmap[id].pid; - else + + } else { return -EINVAL; + } // If current thread then exit, otherwise cancel rv = pthread_kill(pid, sig); @@ -268,27 +288,30 @@ void px4_show_tasks() int count = 0; PX4_INFO("Active Tasks:"); - for (idx=0; idx < PX4_MAX_TASKS; idx++) - { + + for (idx = 0; idx < PX4_MAX_TASKS; idx++) { if (taskmap[idx].isused) { PX4_INFO(" %-10s %lu", taskmap[idx].name.c_str(), (unsigned long)taskmap[idx].pid); count++; } } - if (count == 0) + + if (count == 0) { PX4_INFO(" No running tasks"); + } } bool px4_task_is_running(const char *taskname) { int idx; - for (idx=0; idx < PX4_MAX_TASKS; idx++) - { + + for (idx = 0; idx < PX4_MAX_TASKS; idx++) { if (taskmap[idx].isused && (strcmp(taskmap[idx].name.c_str(), taskname) == 0)) { return true; } } + return false; } __BEGIN_DECLS @@ -301,14 +324,14 @@ unsigned long px4_getpid() const char *getprogname(); const char *getprogname() { - pthread_t pid = pthread_self(); - for (int i=0; ilock)); s->value--; - if(s->value < 0) { - pthread_cond_wait(&(s->wait), &(s->lock)); + + if (s->value < 0) { + pthread_cond_wait(&(s->wait), &(s->lock)); } + pthread_mutex_unlock(&(s->lock)); return 0; @@ -77,9 +79,11 @@ int px4_sem_post(px4_sem_t *s) { pthread_mutex_lock(&(s->lock)); s->value++; - if(s->value <= 0) { + + if (s->value <= 0) { pthread_cond_signal(&(s->wait)); } + pthread_mutex_unlock(&(s->lock)); return 0; diff --git a/src/platforms/posix/work_queue/hrt_thread.c b/src/platforms/posix/work_queue/hrt_thread.c index 46ca7538c1..98331ca798 100644 --- a/src/platforms/posix/work_queue/hrt_thread.c +++ b/src/platforms/posix/work_queue/hrt_thread.c @@ -274,7 +274,7 @@ void hrt_work_queue_init(void) work_hrtthread, (char *const *)NULL); - + #ifdef __PX4_QURT signal(SIGALRM, _sighandler); #else