Commit Graph

32 Commits

Author SHA1 Message Date
chao an 4c8d244fae sched/getpid: replace syscall getpid/tid/ppid() to kernel version
NuttX kernel should not use the syscall functions, especially after
enabling CONFIG_SCHED_INSTRUMENTATION_SYSCALL, all system functions
will be traced to backend, which will impact system performance.

Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-02 10:33:01 +08:00
qinwei1 8021dfece6 sched/task/task_getpid: getpid should return process id not thread id
Summary:
   implement the right semantics:
1. getpid should return the main thread id
2. gettid should return the current thread id

Refer to:
 https://github.com/apache/incubator-nuttx/issues/2499
 https://github.com/apache/incubator-nuttx/pull/2518

Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2022-11-17 17:58:08 +08:00
Gustavo Henrique Nihei 1416afc6b6 sched: Remove "0x" prefix preceding "%p" specifier on format string
The "p" format specifier already prepends the pointer address with
"0x" when printing.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-06-30 22:08:58 +03:00
Petro Karashchenko 68902d8732 pid_t: unify usage of special task IDs
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-22 21:22:32 +08:00
Nathan Hartman 878c347bb6 sched: Fix typos in comments
sched/pthread/pthread_mutextimedlock.c:
sched/pthread/pthread_mutextrylock.c:

    * Fix typos in comments. No functional change.
2021-12-21 11:07:23 -06:00
Gregory Nutt 4b44b628ea Run nxstyle against all .c and .h files modified by this PR.
All complaints fixed except for those that were not possible to fix:

- Used of Mixed case identifier in ESP32 files.  These are references to Expressif ROM functions which are outside of the scope of NuttX.
2020-05-09 14:19:08 -03:00
Gregory Nutt a4218e2144 include/nuttx/sched.h: Make naming of all internal names consistent:
1. Add internal scheduler functions should begin with nxsched_, not sched_
2. Follow the consistent naming patter of https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+OS+Internal+Functions
2020-05-09 14:19:08 -03:00
Xiang Xiao cde88cabcc Run codespell -w with the latest dictonary again
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-02-23 22:27:46 +01:00
Xiang Xiao 5c80b94820 Replace #include <semaphore.h> to #include <nuttx/semaphore.h>
Since the kernel side should call nxsem_xxx instead and remove the unused inclusion
2020-02-01 08:27:30 -06:00
Gregory Nutt b5111d2c38 tools/nxstyle.c: Add logic to detect if there is a blank line following the final right brace. sched/: Applied the modified nxstyle to all C file as a test. 2019-10-24 11:02:42 -06:00
Gregory Nutt bde0509cae tools/nxstyle.c: Fix error in conditional logic that was preventing detection bad brace alignment. Add logic to handle alignment of braces in data initializators which following slightly different indentation rules. 2019-06-30 10:35:10 -06:00
Gregory Nutt f914ec6e2b tools/nxstyle.c: Fix logic that detects if an operator is correctly delimited with spaces. sched/: Various changes because sched/ C files were used as Guinea Pigs to test nstyle.c. 2019-03-01 10:50:02 -06:00
Gregory Nutt b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Gregory Nutt 7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Arjun Hary b274a97840 Miscellaneous fixes from astyle tool. 2017-08-14 17:19:27 -06:00
Gregory Nutt 031fbfc6bc sched/: Remove dangling space at the end of lines. 2017-06-28 13:33:04 -06:00
Gregory Nutt eb344d7260 Fix an assertion noted by Jussi Kivilinna.
This was a consequence of the recent robust mutex changes.  If robust mutexes are selected, then each mutex that a thread takes is retained in a list in threads TCB.  If the thread exits and that list is not empty, then we know that the thread exitted while holding mutexes.  And, in that case, each will be marked as inconsistent and the any waiter for the thread is awakened.

For the case of pthread_mutex_trywait(), the mutex was not being added to the list!  while not usually a fatal error, this was caught by an assertion when pthread_mutex_unlock() was called:  It tried to remove the mutex from the TCB list and it was not there when, of course, it shoule be.

The fix was to add pthread_mutex_trytake() which does sem_trywait() and if successful, does correctly add the mutext to the TCB list.  This should eliminated the assertion.
2017-03-29 07:50:40 -06:00
Gregory Nutt b07d3fc305 Rename CONFIG_MUTEX_TYPES to CONFIG_PTHREAD_MUTEX_TYPES 2017-03-27 09:08:14 -06:00
Gregory Nutt f2f798cb29 pthread mutexes: Finish logic to support configuration mutex robustness. 2017-03-27 08:50:45 -06:00
Gregory Nutt 8b3c554e45 pthreads: Add a configuration option to disable robust mutexes and revert to the traditional unsafe mutexes. 2017-03-26 17:37:28 -06:00
Gregory Nutt 5a69453e16 pthreads: Add some assertions. 2017-03-26 13:54:43 -06:00
Gregory Nutt 6e623ce06f pthreads: Partial implementation of final part of robust mutexes: Keep list of all mutexes held by a thread in a list in the TCB. 2017-03-26 12:46:57 -06:00
Gregory Nutt 363403fb1f pthreads: Add more robustness characteristics: pthread_mutex_lock() and trylock() will now return EOWNERDEAD if the mutex is locked by a thread that no longer exists. Add pthread_mutex_consistent() to recover from this situation. 2017-03-26 10:35:23 -06:00
Gregory Nutt 13cac3b592 sched/: Change some *err() message to *info() messages if what was a *dbg() message does not indicate and error condition. 2016-06-11 16:42:42 -06:00
Gregory Nutt a1469a3e95 Add CONFIG_DEBUG_ERROR. Change names of *dbg() * *err() 2016-06-11 15:50:49 -06:00
Gregory Nutt 3994b094c5 Remove some empty C file section comments; Update some text in TODO file 2016-02-19 10:01:15 -06:00
Gregory Nutt 79d554939e sched/: Fix some spacing issues 2015-10-07 19:59:14 -06:00
Gregory Nutt cb9e27c3b0 Standardize naming used for public data and function groupings 2015-10-02 16:30:35 -06:00
Juha Niskanen e1846dff82 sched/pthread: Implement pthread_mutex_trylock() for recursive mutexes 2015-06-16 08:32:20 -06:00
Gregory Nutt b4423c1eed Make some file section headers more consistent with standard 2015-04-08 06:47:36 -06:00
Gregory Nutt 0f318e9249 Move watchdog functions from sched/ to sched/wdog 2014-08-08 14:21:48 -06:00
Gregory Nutt cb79407ced Move all pthread files from sched/ to sched/pthread 2014-08-08 12:55:02 -06:00