Commit Graph

2051 Commits

Author SHA1 Message Date
larry
2721e01fc2 sched/timer: timer_settime not fully satisfy IEEE 1003.1
If the specified time has already passed, the function
shall succeed and the expiration notification shall be made.
2022-07-18 12:30:28 +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
b1c72c023c libc/stdio: enable long long formating by CONFIG_HAVE_LONG_LONG
and remove CONFIG_LIBC_LONG_LONG option to simplify the usage.
note: the size will increase 668
before change:
   text    data     bss     dec     hex filename
 168440     348    4480  173268   2a4d4 nuttx

after change:
   text    data     bss     dec     hex filename
 169108     348    4480  173936   2a770 nuttx

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-13 09:50:38 -03:00
Nathan Hartman
1867bc2210 Fix compiler warnings (-Wunused-parameter) in various functions
Fixes the -Wunused-parameter warning in:
* group/group_signal.c: group_signal()
* irq/irq_unexpectedisr.c: irq_unexpected_isr()
* task/task_spawn.c: nxtask_spawn_proxy()
* timer/timer_getoverrun.c: timer_getoverrun()
* misc/dev_null.c: devnull_read(), devnull_write(), devnull_poll()
* misc/dev_zero.c: devzero_read(), devzero_write(), devzero_poll()
* syslog/syslog_channel.c: syslog_default_write()
* syslog/syslog_device.c: syslog_dev_flush()
* grp/lib_initgroups.c: initgroups()
* misc/lib_mknod.c: mknod()
* misc/lib_glob.c: ignore_err()
* pthread/pthread_barrierinit.c: pthread_barrier_init()
* pthread/pthread_atfork.c: pthread_atfork()
* semaphore/sem_init.c: nxsem_init()
* stream/lib_nullinstream.c: nullinstream_getc()
* stream/lib_nulloutstream.c: nulloutstream_putc()
* stream/lib_libnoflush.c: lib_noflush()
* stream/lib_libsnoflush.c: lib_snoflush()
* string/lib_strerror.c: strerror()
* time/lib_gettimeofday.c: gettimeofday()
* time/lib_settimeofday.c: settimeofday()
* unistd/lib_pathconf.c: fpathconf(), pathconf()
* unistd/lib_getrusage.c: getrusage()
* unistd/lib_setrlimit.c: setrlimit()
* unistd/lib_getrlimit.c: getrlimit()
* unistd/lib_setpriority.c: setpriority()
2022-07-12 11:42:34 +08:00
chao.an
e5b3d52486 clock/settime: minor fix compile warning
clock/clock_settime.c: In function ‘clock_settime’:
clock/clock_settime.c:120:45: warning: passing argument 1 of ‘clock_timekeeping_set_wall_time’
                              discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  120 |       ret = clock_timekeeping_set_wall_time(tp);
      |                                             ^~
In file included from clock/clock_settime.c:37:
sched/clock/clock_timekeeping.h:40:58: note: expected ‘struct timespec *’
                                       but argument is of type ‘const struct timespec *’
   40 | int clock_timekeeping_set_wall_time(FAR struct timespec *ts);
      |

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-10 20:44:21 +03:00
Nathan Hartman
849f760b77 Fix various typos 2022-07-08 02:15:54 +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
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
Ville Juven
dc2b2dcb3f sched/env: Check for incoming parameter validity in unsetenv()
Something the function did not do, check the incoming parameter is vlaid
2022-06-14 10:39:52 +03:00
Ville Juven
1b32fc1642 sched/env: Fix the return value of unsetenv()
If the environment variable does not exist, the function succeeds, as
defined by POSIX.
2022-06-14 10:39:52 +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
Xiang Xiao
11c8f3125d sched/tls: Wrap up_info_size into tls_info_size
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-08 19:07:33 +09:00
Xiang Xiao
8543df7e4c sched/init: Initialize the idle thread local storage by tls_init_info
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-08 19:07:33 +09:00
Xiang Xiao
01c8bebf58 sched/tls: Add task_init_info and task_uninit_info
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-03 23:56:50 +03:00
Xiang Xiao
47b707bbf8 sched/tls: Add tls_init_info and tls_dup_info
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-03 23:56:50 +03:00
Xiang Xiao
3e32b605fe libc/tls: Make tls_get_info as the pulibc function instead up_tls_info
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-03 23:56:50 +03:00
Xiang Xiao
33a6aa2f48 sched/tls: Don't compensate the tls size to the stack size
it isn't good to change the stack size passed by caller

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-03 23:56:50 +03:00
chao.an
5f46a21c25 signal: add define of SIGHUP/SIGTTIN
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-03 12:50:14 +08:00
zhuyanlin
656f851f20 cpuload: use correct pm cpuload tick.
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-05-31 07:57:43 +03:00
Xiang Xiao
3b136771ff sched: Move the call of pthread_mutex_inconsistent to nxtask_recover
to avoid it spread around all possible exit path

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-27 09:39:09 +03:00
Xiang Xiao
feb54fc272 sched/pthread: Should call up_exit in pthread_exit
since _exit may kill all sibling thread when
HAVE_GROUP_MEMBERS equal true. Regressed by:
commit 622677d4a1
Author: Ville Juven <ville.juven@unikie.com>
Date:   Mon May 2 15:15:06 2022 +0300

    libc: Implement exit, atexit, on_exit and cxa_exit on the user side

    For CONFIG_BUILD_KERNEL using the sched/task/task_exithook implementation
    will just not work. It calls user code with kernel privileges which is
    a bit of a security issue.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-26 08:16:46 +03:00
Ville Juven
a54c3d13f9 sched: Remove SCHED_ATEXIT / SCHED_ONEXIT
Remove the kernel side implementations altogether. These will be
replaced by user land implementations.
2022-05-25 15:28:43 +08:00
Ville Juven
622677d4a1 libc: Implement exit, atexit, on_exit and cxa_exit on the user side
For CONFIG_BUILD_KERNEL using the sched/task/task_exithook implementation
will just not work. It calls user code with kernel privileges which is
a bit of a security issue.
2022-05-25 15:28:43 +08:00
Xiang Xiao
efc863217b Fix error: converting the result of '<<' to a boolean always evaluates to true
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-19 23:23:01 +03:00
Xiang Xiao
5b0b4bd586 sched/wdog: Change the return type of wd_gettime from int to sclock_t
to handle 64bits sclock_t correctly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-19 23:21:54 +03:00
jihandong
89338a6914 sched/pthread/pthread_condclockwait.c: follow POSIX.
pthread_condclockwait() can not distinguish between interrupt and timeout,
which cause these API not follow POSIX:
	pthread_rwlock_timedrdlock()
	pthread_rwlock_timedwrlock()
	pthread_condtimedwait()
POSIX:
	Upon return from the signal handler the thread resumes waiting for
	the condition variable as if it wasnot interrupted
	These functions shall not return an error code of [EINTR].

Replacing nxsem_wait() with nxsem_clockwait_uninterruptible() can solve it.

Signed-off-by: jihandong <jihandong@xiaomi.com>
2022-05-19 14:57:33 +08:00
zhuyanlin
1c977e97d2 pthread_mutexinit: fix deadcode in pthread_mutexinit
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-05-16 10:20:52 +03:00
zhuyanlin
3bac0d8367 timer:settime: check return value of clock_abstime2ticks
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-05-16 10:20:52 +03: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
Xiang Xiao
08002a0a38 sched: Replace pthread_sem_take with nxsem_wait_uninterruptible
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-14 20:47:34 +03:00
Xiang Xiao
9072eecc30 sched/wqueue: Change the return type of work_notifier_teardown to void
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-14 00:35:29 +03:00
Ville Juven
5bcd1dbb64 sched: Remove task_restart in case of CONFIG_BUILD_KERNEL
Same treatment as task_delete, this is not usable in kernel build
either.
2022-05-12 22:08:19 +08:00
Ville Juven
b1d92159fa sched: Remove task_delete in case of CONFIG_BUILD_KERNEL
Deleting a task from another task's context will not do, so shut
this gate down for BUILD_KERNEL. In this case if a task wants another
task to terminate, it must ask the other task to politely kill itself.

Note: kthreads still need this, also, the kernel can delete a task
without asking.
2022-05-12 03:27:25 +08:00
Xiang Xiao
b907a1fec7 cpuload: Support the internal computation in the tickless mode
just like how the same thing done in nxsched_process_timer

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-10 21:21:19 +08:00
Xiang Xiao
f47cf7ba04 sched: Add nxsched_process_cpuload_ticks prototype to sched/sched/sched.h
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-10 21:21:19 +08:00
zhuyanlin
de3bb757d2 sched:sched_cpuload_period: add time compensate for idle task
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-05-10 21:21:19 +08:00
zhuyanlin
c75f4b62e0 sched:sched_cpuload_oneshot: add time compensate for idle task
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-05-10 21:21:19 +08:00
zhuyanlin
6facf18a01 cpuload: nxsched_cpu_process_cpuload: add ticks parameter
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-05-10 21:21:19 +08:00
zhuyanlin
45fe3fb4c6 sched:cpuload_period: add pm callbacks
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-05-10 21:21:19 +08:00
zhuyanlin
1c2583eaad sched:cpuload_oneshot: add pm callcacks
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-05-10 21:21:19 +08:00
chao.an
f5b3d5a014 sched/note: fix build break
1. fix typo spilock -> spinlock
2. fix build break

sched/sched_note.c: In function ‘note_spincommon’:
sched/sched_note.c:435:3: error: aggregate value used where an integer was expected
  435 |   note.nsp_value = (uint8_t)*spinlock;
      |   ^~~~

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-05-09 12:27:57 +08:00
Oki Minabe
22787ee109 sched/group: addrenv: allocate current group for each cpu
Summary:
- In case of SMP and ADDRENV, allocate current group for each cpu
  - g_pid_current holds pid of the group and uses for addrenv switching
  - allocate g_group_current for each cpu in stead of g_pid_current
  - g_group_current is the array that pointed to the current task_group_s struct

Impact:
- ADDRENV=y and SMP=y

Testing:
- sabre-6quad:smp w/ qemu
- sabre-6quad:knsh w/ qemu
- sabre-6quad:knsh_smp w/ qemu (WIP)

Signed-off-by: Oki Minabe <minabe.oki@gmail.com>
2022-05-08 20:34:31 +03: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
1b4d8b3734 sched: remove DEBUGASSERT from nx_waitpid
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-04-22 15:06:26 -03:00
Xiang Xiao
55b5561fdb sched/task: Implement execle and execve
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-22 10:40:31 +03:00