Xiang Xiao
ef65d443ad
sem: Remove PRIOINHERIT_FLAGS_ENABLE and use SEM_PRIO_INHERIT instead
...
and refine the code to prepare the support of new flags
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-11 17:35:28 +02:00
zhangyuan21
8b5078fc36
sched/semaphore: check sem flags before enable priority inheritance
...
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2022-12-20 11:50:42 +08:00
yinshengkai
552cf4b549
merge sched_note_spinxx into sched_note_spincommon
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-12-16 17:03:53 +08:00
Petro Karashchenko
5b4e12774c
sched: remove unnecessary type cast
...
fix code style issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-12-15 09:44:32 +08:00
zhangyuan21
d8051ba979
nuttx/sched: merge up_block_task and up_unblock_task
2022-11-22 22:59:08 +08:00
zhangyuan21
08f7152d9f
nuttx/sched: remove nxsched_remove_readytorun from up_block_task
...
It takes about 10 cycles to obtain the task list according to the task
status. In most cases, we know the task status, so we can directly
add the task from the specified task list to reduce time consuming.
2022-11-22 15:29:00 +09:00
zhangyuan21
e54b602208
nuttx/sched: remove nxsched_remove_blocked from up_unblock_task
...
It takes about 10 cycles to obtain the task list according to the task
status. In most cases, we know the task status, so we can directly
delete the task from the specified task list to reduce time consuming.
2022-11-22 15:29:00 +09: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
ligd
a9c647d418
semaphore: move param check to sem_xx level
...
for the speed improve
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-10 22:36:21 +08:00
ligd
d4ba93067e
sched: remove sched_continue, merge code
...
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-04 08:51:02 +01:00
zhangyuan21
18266c1012
nuttx/sched: use pid to check idle task
...
Pid is more appropriate than the flink pointer to determine idle task,
when we want to use other data structure to optimize the task list.
2022-10-31 17:53:08 +09:00
luoyong1
126ce6428e
sched/semaphore: add the wdog judge before cancel
...
N/A
to avoid entering critical again in wd_cancel when wdog not actived. But when the wdog is actived, may add more judge
2022-10-28 09:34:52 +02:00
Petro Karashchenko
e43db5fe28
sched/semaphore: fix typo in comment
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-10-24 12:59:24 +08:00
anjiahao
577e550698
libc/semaphore:sem_init change defult protocol
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
zhangyuan21
09a06e7fce
sem: don't clear waitobj when do sem recover
...
This commit is intended to solve the bug caused by #7159 .
It will fixed data abort issue when task restart in wait sem status.
If delete waitobj in the sem recover function, then we will get the wrong
task list when remove the task from task list.
2022-10-11 16:31:54 +09:00
Petro Karashchenko
d247e8d1d2
sched/semaphore: fix priority boost restoration for priority inheritance
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-10-03 15:14:24 -03:00
zhangyuan21
838309313e
sched: semaphore wait list optimize
2022-09-28 18:08:37 +08:00
Xiang Xiao
40ef5bc6db
libc: Move queue.h from include to include/nuttx
...
to avoid the conflict with libuv's queue.h
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-26 08:04:58 +02:00
zhangyuan21
40366f4153
sched: clear waitsem and msgwaitq after remove blocked
2022-09-22 16:32:44 +08:00
zhangyuan21
af72a528f1
sched: merge waitsem and msgwaitq
2022-09-22 16:32:44 +08:00
zhangyuan21
eb22ee0e21
sched/semaphore: add sem_count temporary variable to improve performance
2022-08-31 20:34:30 +08:00
Nathan Hartman
dd718e78f7
Fix typos
2022-08-07 23:33:19 +08:00
Gustavo Henrique Nihei
6f0334140f
sched: Convert DEBUGASSERT(false) into more intuitive DEBUGPANIC()
...
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-07-14 12:08:45 +08:00
Xiang Xiao
1fb8c13e5e
Replace nxsem_timedwait_uninterruptible with nxsem_tickwait_uninterruptible
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-15 13:55:58 +03:00
Xiang Xiao
22e4f1c59a
sched: Remove start from nxsem_tickwait[_uninterruptible]
...
to simplify both caller and callee
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-15 13:55:58 +03:00
ligd
61a0453e6e
os init_state: add new state OSINIT_IDLELOOP
...
This is for distinguish we are in init idle or idle loop.
Use for assertion for sem_trywait & sem_wait
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-02-23 22:05:37 +09:00
Masayuki Ishikawa
fccdcf7011
Revert "os init_state: add new state OSINIT_IDLELOOP"
...
This reverts commit 051bb32010
.
2022-02-22 10:56:14 +01:00
ligd
051bb32010
os init_state: add new state OSINIT_IDLELOOP
...
This is for distinguish we are in init idle or idle loop.
Use for assertion for sem_trywait & sem_wait
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-02-22 07:58:55 +01:00
ligd
756c9fb60d
semaphore: fix corner case sem_waitirq assert crash
...
[ 11.041077] [25] [ EMERG] [ap] up_assert: Assertion failed at file:semaphore/sem_waitirq.c line: 84 task: thermal service
[ 11.041407] [25] [ EMERG] [ap] backtrace:
[ 11.041517] [25] [ EMERG] [ap] [25] [<0x2c687c9e>] up_backtrace+0xa/0x164
[ 11.041627] [25] [ EMERG] [ap] [25] [<0x2c676e6c>] sched_dumpstack+0x1c/0x5c
[ 11.041682] [25] [ EMERG] [ap] [25] [<0x2c68763a>] up_assert+0x42/0x24c
[ 11.041792] [25] [ EMERG] [ap] [25] [<0x2c67355e>] _assert+0x2/0xc
[ 11.041847] [25] [ EMERG] [ap] [25] [<0x2c65d536>] nxsem_wait_irq+0x3e/0x134
[ 11.042288] [25] [ EMERG] [ap] [25] [<0x2c65d378>] nxsem_timeout+0x24/0x34
[ 11.043169] [25] [ EMERG] [ap] [25] [<0x2c65f74c>] wd_timer+0xc0/0x104
[ 11.043995] [25] [ EMERG] [ap] [25] [<0x2c65c930>] nxsched_alarm_expiration+0x4c/0xdc
[ 11.044986] [25] [ EMERG] [ap] [25] [<0x2c670872>] oneshot_callback+0x16/0x24
[ 11.045867] [25] [ EMERG] [ap] [25] [<0x2c6822b8>] bes_oneshot_irq_handler+0x18/0x28
[ 11.046858] [25] [ EMERG] [ap] [25] [<0x57e5c>] up_irq_handler+0x4/0xc
[ 11.047684] [25] [ EMERG] [ap] [25] [<0x2c65a20e>] irq_dispatch+0x5a/0xb8
[ 11.048510] [25] [ EMERG] [ap] [25] [<0x2c6864d8>] arm_doirq+0x28/0x3c
[ 11.049336] [25] [ EMERG] [ap] [25] [<0x2c681732>] exception_common+0x4a/0xac
[ 11.050272] [25] [ EMERG] [ap] [25] [<0x2c65a324>] leave_critical_section+0x2c/0x54
[ 11.051208] [25] [ EMERG] [ap] [25] [<0x2c65f472>] timer_settime+0x9e/0x10c
There are 2 ways can caused this:
1. sem_timedwait
HW IRQ sem_post
TIMER IRQ do wd_timer -> nxsem_timeout -> crash
Note: The 2 IRQS happens amost at same time
2. sem_timedwait
TIMER IRQ do wd_timer -> wd_func1 sem_post
-> wd_func2 nxsem_timeout -> crash
Resolve:
Stop the watchdog when sem_post
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-02-18 23:00:28 +08:00
Petro Karashchenko
7933442b98
sched/semaphore/sem_clockwait: fix typo in comment
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-02-17 12:54:49 +01:00
Petro Karashchenko
41c95da594
register_driver: fix driver modes accross the code
...
State of problem:
- Some drivers that do not support write operations (does not
have write handler or ioctl do not perform any write actions)
are registered with write permissions
- Some drivers that do not support read operation (does not
have read handler or ioctl do not perform any read actions)
are registered with read permissions
- Some drivers are registered with execute permissions
Solution:
- Iterate code where register_driver() is used and change 'mode'
parameter to reflect the actual read/write operations executed
by a driver
- Remove execute permissions from 'mode' parameter
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-02-16 16:15:29 +08:00
Zeng Zhaoxiu
fc4ab4fd94
semaphore: Improve the nxsem_release_holder function.
...
1. The task which called nxsem_release_holder may not be a holder of the semaphore,
counts of the holder would not be decreamented.
This commit try to resolve the problem if there is only one holder.
2. Avoid counts overflow.
Signed-off-by: Zeng Zhaoxiu <walker.zeng@transtekcorp.com>
2022-02-13 03:20:51 +08:00
Zeng Zhaoxiu
ea8f5f565e
semaphore: Cleanup, merge public code.
...
Signed-off-by: Zeng Zhaoxiu <walker.zeng@transtekcorp.com>
2022-02-13 03:20:51 +08:00
Zeng Zhaoxiu
5bf7c185af
semphore: release all semphores' holder that the task held when exit
...
Add a list in TCB to track all semphores the task held, so we
can release all holders when exit, so nxsched_verify_tcb
is unnecessary.
Signed-off-by: Zeng Zhaoxiu <walker.zeng@transtekcorp.com>
2022-02-13 03:20:51 +08:00
ligd
b316611ef0
Revert "sem: remove limitation of irq context when do sem_trywait"
...
This reverts commit 7c547b3ebd
.
2022-01-29 00:53:47 +08:00
ligd
dd08815991
idle: remove heap & stack check in idle thread
...
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-20 01:14:56 +08:00
Petro Karashchenko
2447b7bd9a
pthread: restore pthread mutex default protocol POSIX compatibility
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-11 01:55:12 +08:00
anjiahao
9a53601ba9
sched:add holder in sem_trywait
...
Avoid priority rollover
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2021-12-17 11:28:27 -06:00
chao.an
4703ef93cc
sched/semaphore: remove redundant goto case
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-13 14:38:44 +09:00
chao.an
102a6357ca
Revert "sched: Remove a redundant critical section"
...
There is a potential problem that can lead to deadlock at
condition wait, if the timeout of watchdog is a very small value
(1 tick ?), the timer interrupt will come before the nxsem_wait()
Revert "sched: pthread: Remove a redundant critical section in pthread_condclockwsait.c"
Revert "sched: semaphore: Remove a redundant critical section in nxsem_clockwait()"
Revert "sched: semaphore: Remove a redundant critical section in nxsem_tickwait()"
This reverts commit 7758f3dcb1
.
This reverts commit 2976bb212e
.
This reverts commit 65dec5d10a
.
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-13 14:38:44 +09:00
ligd
7c547b3ebd
sem: remove limitation of irq context when do sem_trywait
...
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-17 02:20:08 -06:00
Abdelatif Guettouche
de68507f84
sched/*/*spinlock.c: Fix some typos.
...
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-07-24 09:00:41 -07:00
Xiang Xiao
2e54df0f35
Don't include assert.h from public header file
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-03 08:36:03 -07:00
Xiang Xiao
001e7c3e76
sched: Don't include nuttx/sched.h inside sched.h
...
But let nuttx/sched.h include sched.h instead to
avoid expose nuttx kernel API to userspace.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-05-24 12:11:53 +09:00
Masayuki Ishikawa
7758f3dcb1
sched: semaphore: Remove a redundant critical section in nxsem_tickwait()
...
Summary:
- This commit removes a redundant critical section in nxsem_tickkwait()
Impact:
- None
Testing:
- Tested with ping with the following configs
- spresense:rndis, spresense:rndis_smp
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-03-16 19:50:18 -07:00
Masayuki Ishikawa
65dec5d10a
sched: semaphore: Remove a redundant critical section in nxsem_clockwait()
...
Summary:
- This commit removes a redundant critical section in nxsem_clockwait()
Impact:
- None
Testing:
- Tested with ostest with the following configurations
- maix-bit:smp (QEMU), sim:smp, esp32-devkitc:smp (QEMU)
- sabre-6quad:smp (QEMU), spresense:smp
- maix-bit:nsh (QEMU), sim:ostest, esp32-devkitc:ostest (QEMU)
- sabre-6quad:nsh (QEMU), spresense:wifi
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-03-16 19:50:18 -07:00
Alin Jerpelea
dee641828f
sched: nxstyle fixes
...
nxstyle fixes to pass CI
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Alin Jerpelea
8935ac4cc3
sched: Author Gregory Nutt: update licenses to Apache
...
Gregory Nutt has submitted the SGA and we can mograte the licenses
to Apache.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Masayuki Ishikawa
6158b6b77b
spinlock: Introduce SP_WFE() and SP_SEV()
...
Summary:
- This commit introduces SP_WFE() and SP_SEV() to be used for spinlock
- Also, use wfe/sev instructions for ARMV7-A to reduce power consumption
Impact:
- ARMV7-a SMP only
Testing:
- sabre-6quad:smp (QEMU, dev board)
- maix-bit:smp, esp32-devkitc:smp, spresense:smp sim:smp (compile only)
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-12-11 05:58:35 -06:00
YAMAMOTO Takashi
b1ecca08c1
sched/semaphore/sem_holder.c: Fix syslog formats
2020-11-22 19:01:05 -08:00