Commit Graph

1947 Commits

Author SHA1 Message Date
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
Petro Karashchenko
9b02a91c72 libc/sched/task_setcanceltype: fix function name in comment
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-02-21 20:32:49 +08:00
Huang Qi
f452dd7ab4 sched: Mark pthread as non-cancelable to avoid additional calls to pthread_exit()
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-20 15:36:07 +01:00
Oki Minabe
682984e9ba add the kernel stack allocation in pthread create. 2022-02-19 19:32:21 +08: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
patacongo
cfee589a4a Update sched/wdog/wd_start.c
Co-authored-by: David Sidrane <David.Sidrane@Nscdg.com>
2022-02-10 22:33:47 +08:00
Gregory Nutt
8af4d65c9a Added comment to wdog_start
Add a comment briefly explaining why one timer tick is added to the watchdog delay.  This has confused a lot of people and has resulted in numerous awkward discussions and ill-informed attempts to modify the code to remove that addition.  Perhaps a rather lengthy comment will reduce that confusion and put an end to this thrashing.
2022-02-10 22:33:47 +08:00
chao.an
b3d45fd6c0 sched/mqueue: remove unused leave_cancellation_point
should be removed by:

commit fca07be1df
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Tue Oct 10 08:43:10 2017 -0600

    Squashed commit of the following:

        Change all calls to mq_send() and mq_timedsend() in the OS to calls to
        nxmq_send() and nxmq_timedsend(), making appropriate changes for differences
        in return values.

        sched/mqueue:  Add internal function nxmq_send() and nxmq_timedsend() that are
        equivalent to mq_send() and mq_timedsend() except that they do not create
        cancellation points and do to not modify the errno variable.

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 22:33:21 +08:00
chao.an
479d196208 sched/module: remove redundant unlock
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 22:31:51 +08:00
Xiang Xiao
d426875fcf tools/mkconfig: Remove the unnecessary config option correction
since Kconfig can handle the dependence correctly for us

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-09 14:34:38 -03:00
Huang Qi
8bf7f94d39 pthread: Call cleanup callback while asyncrhonous cancel
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-09 21:21:43 +08:00
Huang Qi
c0a0de97ce Revert "libc: Call pthread_exit in user-space by up_pthread_exit"
This reverts commit f4a0b7aedd.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-09 21:21:43 +08:00
Huang Qi
6814b1416f Revert "pthread: Avoid recursive pthread_exit call"
This reverts commit a2941532bd.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-09 21:21:43 +08:00
Xiang Xiao
0000e61da6 task: Always implement posix_spawnp as macro
Since there is no benefit to implement it as
function when CONFIG_LIBC_ENVPATH equals y

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-09 20:09:11 +08:00
Xiang Xiao
ab3b0d0162 sched: Implement sysinfo function
specify here:
https://man7.org/linux/man-pages/man2/sysinfo.2.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-08 10:27:38 +08:00
Xiang Xiao
0499979908 sched: Disable pthread by default when DEFAULT_SMALL is enabled
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-07 12:04:03 +08:00
Xiang Xiao
ef1abbbea0 Fix signal/sig_default.c:195:21: error: unused variable 'rtcb'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-07 12:04:03 +08:00
Xiang Xiao
5c5f1dec08 sched: Don't duplicate caller file handler when creating kernel thread
kernel thread should have only the starndard file i/o just like idle thread

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-01 08:22:45 +09:00
Xiang Xiao
d48946063a Revert "sched: Don't duplicate caller file handler when creating kernel thread"
This reverts commit 512676cb06.
2022-02-01 08:22:45 +09:00
Xiang Xiao
a9d7a776c4 sched: Remove SDCLONE_DISABLE option and config
since the related code was removed by:
commit 4d5a964f29
Author: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date:   Tue Feb 23 18:04:13 2021 +0800

    net: unify socket into file descriptor

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-31 19:03:20 +01:00
Xiang Xiao
512676cb06 sched: Don't duplicate caller file handler when creating kernel thread
kernel thread should have only the starndard file i/o just like idle thread

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-31 14:44:29 +01:00
ligd
d8c2610157 idle: remove heap & stack check in idle thread
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-29 00:53:47 +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
chao.an
e781787cb9 sched/critmonitor: remove the assertion if counter == 0
Perf timer interface generally uses the hardware cycle counter
provided by the arch chip directly(such as DWT_CYCCNT(cortex-m)),
CYCCNT is a free running counter and counting upwards.
It wraps around to 0 on overflow.

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-25 20:24:58 +08:00
Xiang Xiao
a24ae559c2 arch: Decouple up_critmon_[gettime|convert] from critmon
and rename to up_perf_[gettime|convert] since it's useful in other case

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-25 14:43:34 +08:00
Petro Karashchenko
c0881feca9 boards/arm/samv7/same70-qmtech: fix description in README.txt
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-23 20:08:10 -03:00
Xiang Xiao
77792a1598 sched: Define CONFIG_SMP_NCPUS to 1 in no SMP case
to simplify the SMP related code logic

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-20 23:21:21 +08:00
Petro Karashchenko
08043fb5bc net: unify FAR keyword usage for all net buffer memory mapped buffers
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-20 01:42:56 +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
ligd
cb502a869c clock: update clock_synchronize() to support with time
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-18 22:48:15 +08:00
ligd
0a51f13ca5 rpmsg_rtc: merge the rpmsg_rtc_init to same place
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-18 22:48:15 +08:00
Xiang Xiao
1b77ae88ef fs/procfs: Remove the unnecessary strcmp
since the procfs already make the same check for us

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-12 07:19:40 +01:00
Petro Karashchenko
a743fed63d file_operations: get back C89 compatible initializer
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-11 02:14:00 +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
Xiang Xiao
964f4b7ed7 sched/Kconfig: Remove CONFIG_ prefix from SCHED_HPWORK
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-06 18:45:13 -03:00
Zeng Zhaoxiu
fb43fd73ed signal: signal handler may cause task's state error
For example, task is blocked by nxsem_wait(sem1), use nxsem_wait(sem2)
in signal handler, and take sem2 successfully, after exit from signal
handler to task, nxsem_wait(sem1) returns OK, but the correct result
should be -EINTR.

Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
2022-01-05 21:36:44 +09:00
walker.zeng
76b2f7199d sched: fix the bug of task's tmeslice
The BUG is as follow:
 1. Suppose there are two ready tasks t1 and t2 have the same priority, and t1 is the running.
 2. A new, higher priority task t0 (such as hpwork) is ready, then switch to t0.
 3. After t0 is suspended, then switch to t1 and reset the t1's timeslice.
 4. goto 2
The t2 will have no chance to run.

Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
2021-12-30 18:01:56 +08:00
Xiang Xiao
dd942f0b04 sched/backtrace: Dump the complete stack regardless the depth
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-29 12:09:54 +08:00
ligd
0bb32f27c0 init: use exec_spawn instead of exec
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-24 08:23:30 -06:00
ligd
10ccba6671 init: move USERMAIN_XX out of INIT_ENTRYPOINT
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-24 08:23:30 -06:00
ligd
e5420c8eee wqueue: fix NO leave_critical_section() when only CONFIG_SCHED_HPWORK
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-23 02:27:34 -06: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
Juha Niskanen
422ceec99b Fix typos in comments and Kconfig files
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2021-12-21 03:26:16 -06: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