Commit Graph

135 Commits

Author SHA1 Message Date
Xiang Xiao 7990f90915 Indent the define statement by two spaces
follow the code style convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-21 09:52:08 -03:00
simbit18 bf9b8dfbfe sched: Fix nxstyle errors
error: Long line found
2023-05-11 11:25:58 -03:00
zhangyuan21 c239d19df0 nuttx: add more dependent header file
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-04-11 09:13:32 +03:00
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
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 a4b378a583 mqueue: use to DEBUGASSERT to cover some param check
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
chao an 205c8934a3 sched/msgq: add support of System V message queue
https://man.openbsd.org/msgget.2

Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-22 12:58:11 +08:00
chao an 96c3debe6a sched/mqueue: decoupling condition member to common prologue
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-22 12:58:11 +08:00
zhangyuan21 85d013f69a sched: mqueue wait list optimize 2022-09-28 18:08:37 +08: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
chao an e586f86918 sched/mqueue: fix resource leak in mq_timedsend()
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-15 01:56:35 +08:00
ligd 3b04450808 sched: fix corner case wd_cancel assert crash
There one ways can caused this:
mq_timedreceive
   TIMER IRQ do wd_timer -> wd_func1 mq_send
                         -> wd_func2 nxmq_rcvtimeout -> crash

Resolve:
Stop the watchdog when mq_send

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-09-07 10:50:28 +08:00
Xiang Xiao 1b04bfae20 sched: Remove the unnecessary weak_function
because not all compiler support the weak attribute, and
many features are either always used or guarded by config.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-30 09:42:24 +02:00
Xiang Xiao abc72ad128 net: Ensure sendmsg and sendfile return -EAGAIN in case of timeout
instead of -ETIMEOUT, as specify here:
https://pubs.opengroup.org/onlinepubs/009604599/functions/sendmsg.html
https://man7.org/linux/man-pages/man2/sendfile.2.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-28 06:19:13 +03:00
chao.an 7c12e5281e sched/mqueue: replace inline linklist to improve performance
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-12 00:34:05 +08:00
chao.an d09dc08eab sched/mqueue: do sanity check if DEBUG_FEATURES is enabled
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-11 12:42:47 -03:00
chao.an be33d66c05 sched/mqueue: minor code tuning of message queue
1. remove unnecessary temporary variables
2. adjust the protection scope of the critical section

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-11 14:51:46 +08:00
chao.an 8da798926d sched/mqueue: configurable mqueue notification
Add a configuration to disable the mqueue notification mechanism

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-11 14:51:09 +08:00
chao.an f5d4571abc sched/mqueue: remove sched_lock to improve performance
remove the sched_lock/unlock to improve the performance by 18%

mq_send Flow                        Cycle Count
mq_send                         Origin  Optimized
|
 ->nxmq_send                       24         24
   |
    ->file_mq_send                209        209
      |
      |->sched_lock               243        N/A  <-
      |->nxmq_do_send             391        348
      |  |
      |  |->sched_lock            434        N/A  <-
      |  |->up_unblock_task       545        459
      |   ->sched_unlock          675        N/A  <-
      |
       ->sched_unlock             684        N/A  <-
         |
          ->up_release_pending    701        N/A
            |
             ->arm_switchcontext  856        610

mq_receive
|
 ->arm_fullcontextrestore        1375       1133
   |
    ->up_block_task              1375       1133
      |
       ->nxmq_wait_receive       1530       1288
         |
          ->file_mq_receive      1606       1310
            |
             ->nxmq_receive      1616       1320
               |
                ->mq_receive     1628       1332  - 18%

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-10 07:23:42 +09:00
anjiahao 3dc07ac6b4 sched:fix mq_timedsend describe
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-27 02:09:18 +08: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
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
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
anjiahao 0aa14f832d mq_open: add long file name check and parameter check
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2021-10-21 11:01:45 -03:00
Jiuzhu Dong 11faf0cb20 fs/inode: add sanity check for inode to avoid nullpointer
Change-Id: Ib2c74ba308b8f15756fac4e69632c296243eb4ab
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-07-25 23:01:37 -07:00
Xiang Xiao 0148e1d501 fs: Support the root file system attributes(mode, uid, gid and time)
Note: all attributes is guarded by PSEUDOFS_ATTRIBUTES to save the space

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I664d60382e356068fd920f08aca5b4a49d8d92a9
2021-07-14 10:35:15 -03: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
Nathan Hartman f61214cc0d mqueue, btqueue: Fix some typos (e.g., essage -> message)
include/nuttx/mqueue.h:
sched/mqueue/mq_msgqfree.c:
wireless/bluetooth/bt_queue.c:

    * Fix typos in comments only. No functional changes.
2021-05-25 07:39:24 +09:00
Nathan Hartman 8af9d39667 Documentation, comments: Minor improvements and typos fixed 2021-05-09 19:12:13 -07:00
Gustavo Henrique Nihei 330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00
ligd 48d49e5a7c mqueue: add poll support
Change-Id: I7e908f6a6c00158c0946587dd79ae3dc5d279d37
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-03-04 07:11:43 -08:00
Masayuki Ishikawa 6f5793eefc sched: mqueue: Remove an unnecessary comment in mq_send.c
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-01-27 18:27:34 -08:00
ligd f63db66382 mqueue: add file_mq_xx for kernel use
Change-Id: Ida12f5938388cca2f233a4cde90277a218033645
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-01-05 02:40:43 -06:00
ligd 3bc33572e3 mqueue: simplify the mqueue reailize
1. remove descript management in mqueue, save code size
2. use i_ops instead of i_mqueue to remove the dup logic

Change-Id: Ie88960e50ddcae9c87977c9ad65a45297c663291
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-01-05 02:40:43 -06:00
Xiang Xiao c079760777 sched/mqueue: Make the pre-allocated irq messages configurable
the message can't be dynamically allocated in any irq handler
so it's important to let the user extend the number as needed

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ia26584c3815bac6cf24de4c88be0844ac8e8fba2
2020-12-20 19:31:59 +01:00
Xiang Xiao acca9fcc3b sched/wdog: Remove MAX_WDOGPARMS and related stuff
since the variable arguments are error prone and seldom used.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-14 08:19:50 -06:00
Xiang Xiao a0ce81d659 sched/wdog: Don't dynamically allocate wdog_s
to save the preserved space(1KB) and also avoid the heap overhead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I694073f68e1bd63960cedeea1ddec441437be025
2020-08-11 12:28:55 -06:00
Xiang Xiao 154852acb5 sched/mqueue: Reduce the initial memory consumption
Change the preallocated message and descriptor from 32/24 to 4.
The total size is reduce from 1892 to 532

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I79d199465daef678986868f773876289859f42fc
2020-08-10 08:07:50 +02:00
Xiang Xiao 4c706771c3 sched/wdog: Replace all callback argument from uint32_t to wdparm_t
and alwasy cast the argument of wd_start to wdparm_t

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-08 17:30:26 -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
Gregory Nutt 3dca5eba15 Completes the Implementation of the TLS-based errno
- Remove per-thread errno from the TCB structure (pterrno)
- Remove get_errno() and set_errno() as functions.  The macros are still available as stubs and will be needed in the future if we need to access the errno from a different address environment (KERNEL mode).
- Add errno value to the tls_info_s structure definitions
- Move sched/errno to libs/libc/errno.  Replace old TCB access to the errno with TLS access to the errno.
2020-05-07 23:11:34 +01:00
Gregory Nutt 621151a523 Fix some macOS sim warnings.
These warnings fix a class of warnings that I saw during CI checks for macOS sim builds.  For example:

    devif/devif_callback.c:111:49: warning: for loop has empty body [-Wempty-body]
                   prev = curr, curr = curr->nxtdev);
                                                    ^
    devif/devif_callback.c:111:49: note: put the semicolon on a separate line to silence this warning

I did not put the semi-colon on a separate line, but used braces.
2020-04-11 22:27:42 +01:00
ligd 231ad202ee global change: repace sched_xfree() to kxmm_free()
Changes:
sched_xfree() => kxmm_free()
remove garbage related APIs
remove ARCH_HAVE_GARBAGE

Cause garbage feature move to mm_heap, then don't need
garbage anymore.

Change-Id: If310790a3208155ca8ab319e8d038cb6ff92c518
Signed-off-by: ligd <liguiding@fishsemi.com>
2020-04-09 10:29:28 -06:00
Nakamura, Yuuichi 3cc336dddd Remove type casting to wdentry_t (sched/) 2020-04-07 06:23:15 -06:00