Commit Graph

2372 Commits

Author SHA1 Message Date
chenxiaoyi
cc690f1d21 move task tls destruct to before _exit
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2023-08-29 12:05:57 +08:00
anjiahao
48c153db25 vfs:add nxsched_foreach to sched_lock avoid crash
If scheduling occurs in file_fsync,
fl_lock may be released, and an error may
occur when calling nxmutex_unlock

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-08-29 10:36:21 +08:00
SPRESENSE
57d9083844 assert: Fix the printing alignment of interrupt stack during assert
Fix the printing alignment of interrupt stack during assert.
2023-08-29 02:59:38 +08:00
Xiang Xiao
47faeeb360 tls: Move task_tls_alloc and task_tls_destruct to libc
so task_tls_destruct can be called from usrspace, which is required by:
https://github.com/apache/nuttx/pull/10288

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-08-28 11:02:18 +03:00
Xiang Xiao
cb8df39207 binfmt/elf: Fix the minor style issue
and remove the unused macros and unnecessary cast

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-08-27 18:46:40 -03:00
xinhaiteng
dbefe37a3a sigqueue: add signal type judgment logic
To determine whether a signal is real-time signal or standard signal, the POSIX standard https://www.man7.org/linux/man-pages/man7/signal.7.html defines a real-time signal between SIGRTMIN  and SIGRTMAX , which can store multiple copies, otherwise only one can be retained.

Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2023-08-21 15:35:45 +08:00
zhangyuan21
7737efd995 SMP: fix repeat entry timer_start
If we are running on a single CPU architecture, then we know interrupts
are disabled and there is no need to explicitly call enter_critical_section().
However, in the SMP case, enter_critical_section() is required prevent
multiple cpu to enter timer_start.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-08-21 13:20:56 +08:00
zhangyuan21
fb12e7530d sched/smp: flush dcache before start other cpus
core0 may write the data used by other cpu, this will cause cache inconsistency.
so need fulsh dcache before start other cpus.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-08-21 12:02:45 +08:00
yinshengkai
8fa4f2d61d add the startup process tracepoint
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-19 21:50:08 +08:00
Tiago Medicci Serrano
98985f48dd sched/semaphore: Remove restriction to use nxsem_trywait from ISR
Considering that `nxsem_trywait` is non-blocking, although not
recommended, it could be called from the interrupt handler.
2023-08-14 23:47:41 +08:00
yangyalei
50428979d0 fix wait after vfork return error
Signed-off-by: yangyalei <yangyalei@xiaomi.com>
2023-08-11 09:30:45 -06:00
ligd
e59f161fc2 pthread: remove unused temp change sched_priority
old:
pthread_create:

init_priority = prio;
if (sched_priority < parent_prio)
    sched_priority = parent_prio;    // don't need

pthread_start:

if (sched_priority > init_priority)
    sched_priority = init_priority

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-08-11 21:45:16 +08:00
yinshengkai
63252af054 sched: remove space in task name
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-11 13:27:17 +08:00
fangxinyong
896f34fde9 sched: implement effective uid and gid interfaces
Implement 'effective' setuid, getuid, setgid, and getgid interfaces.
These will be inheritance by all child task groups. These definitons
are explicitly specified here:
https://pubs.opengroup.org/onlinepubs/000095399/functions/geteuid.html
https://pubs.opengroup.org/onlinepubs/000095399/functions/getegid.html
https://pubs.opengroup.org/onlinepubs/000095399/functions/seteuid.html
https://pubs.opengroup.org/onlinepubs/000095399/functions/setegid.html

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-09 17:07:58 +08:00
Petro Karashchenko
d113722eb2 style: fix indentation issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-08 11:58:29 -03:00
Petro Karashchenko
1b0baa8337 nuttx: use lib_free for memory de-allocation after strdup or asprintf
The memory allocated with strdup and asprintf is done via lib_malloc
so we need to use lib_free to deallocate memory otherwise the assertion
"Free memory from the wrong heap" is hit with flat mode and user separated
heap enabled mode.

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-08 11:58:29 -03:00
anjiahao
3a808bab19 support stm32f429i-disco run open flash loader
We can use the driver in nuttx to download
files with debugger

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-05 12:40:02 -07:00
cuiziwei
7c8bb8c293 nuttx/tls: Remove the max key limiatation in task_tls_alloc and pthread_key_create
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2023-08-05 06:33:49 -07:00
cuiziwei
5334c065b4 nuttx/tls:Setting the candidtate index to null prevents dangling pointers.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2023-08-05 06:33:49 -07:00
cuiziwei
8ffde7cf16 nuttx/tls:Setting the candidtate index to null prevents dangling pointers.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2023-08-05 06:33:49 -07:00
yinshengkai
996be8f2cf sched/cpuload: use perf to implement cpuload without relying on external timers
Need to enable CONFIG_SCHED_CRITMONITOR

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-04 10:58:54 -07:00
yinshengkai
e8bf910c3d sched: rename nxsched_cpu_process_cpuload
put nxsched_process_cpuload_ticks partial implementation into nxsched_task_process_cpuload

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-04 10:58:54 -07:00
yinshengkai
08c4ac133b sched/cpuload: add SCHED_CPULOAD_OSCLK option
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-04 10:58:54 -07:00
cuiziwei
5e3df24092 replace nxsched_gettid with nxsched_getpid.
When we find the exit status entry in this task, we need to use pid instead of tid.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2023-08-04 04:21:08 -07:00
yinshengkai
9dabcf9ad2 sched: add CRITMONITOR time out panic
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-03 10:08:12 -07:00
ligd
395fa73870 sched: group_killchildren send signo SIGQUIT before cancel it
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-08-03 08:06:33 -07:00
ligd
1552e52e14 signal: fix group signal can't dispatch some parent group twice
reproduce:

static void *pthread(void *arg)
{
  system(arg);
}

void test (int argc, char *argv[])
{
  pthread_create(&pthread0, &attr, pthread, argv[1]);
  pthread_create(&pthread1, &attr, pthread, argv[2]);
}

only one pthread system() returnd, othres hanged

rootcause:

As we known, system() will create a new task called:
system -c XX

The example:
parent group               child groups

pthread0 -> waitpid() -> system -c ps -> exit() -> nxtask_signalparent()
pthread1 -> waitpid() -> system -c ls -> exit() -> nxtask_signalparent()

Each child group exit with function nxtask_signalparent(),

As we expect:

system -c ps will signal pthread0
system -c ls will signal pthread1

But actually:

system -c ps will signal pthread0/1
system -c ls will signal pthread0/1

As the spec, we know, this behavior is normal:
https://man7.org/linux/man-pages/man2/sigwaitinfo.2.html

So for this situation, when the signo is SIGCHLD, we broadcast.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-08-03 03:35:59 -07:00
yangguangcai
f324d1d8dd SMP: fix repeat entry oneshot_tick_start
Situation:

Assume we have 2 cpus.

CPU0                                CPU1
1. -> nxsched_alarm_expiration
2. -> nxshced_timer_start
3. -> ONESHOT_TICK_START
4. now timer in IRQ
                                    5. in thread
                                    6. -> wd_start
                                    7. -> nxshced_timer_start
                                    8. -> ONESHOT_TICK_START
                                    9. reentry timer crash

Fix:
Enter critical section before nxsched_timer_start

Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2023-08-03 03:20:40 -07:00
zhangyuan21
f2dc9402f6 assert: Remove unnecessary disable interrupts code
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-08-03 03:17:22 -07:00
zhangyuan21
3aa2aa4703 assert: add more information to panic notifier
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-08-03 03:17:22 -07:00
zhangyuan21
bfab486611 assert: add panic notifier data for notify more information
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-08-03 03:17:22 -07:00
zhangyuan21
ef48dec9f9 assert: Stop scheduling when an assert is invoked to prevent running task change
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-08-03 03:17:22 -07:00
ligd
9b6e5f22f9 assert: thread assert don't interrupt by IRQ
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-08-03 03:17:22 -07:00
zhangyuan21
671c5dc3d8 sched/pthread: Don't do cancel when it is already in the exit process
When the task is already in the exit process,
do not execute pthread cancel and return ESRCH.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-08-03 03:12:36 -07:00
yangjiao
ebfdda377b sched/mqueue/mq_sndinternal.c: Update the return value in description "Message queue opened not opened for writing".
Standard POSIX specification in URL “https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_timedsend.html” requires that "EBADF" be returned when message queue not opened for writing.So i update the related descriptions in this file, no function changed.

Signed-off-by: yangjiao <yangjiao@xiaomi.com>
2023-08-03 03:10:56 -07:00
yangjiao
59fd10000e sched/mqueue/mq_send: fix the wrong return value in mq_send function. And add the condition if message priority equal to MQ_PRIO_MAX.
Standard POSIX specification in URL “https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html” requires that "EBADF" be returned when mqdes is not open for writing. And message priorities range from 0 to {MQ_PRIO_MAX}-1. In this change, i update them to follow POSIX spec.

Signed-off-by: yangjiao <yangjiao@xiaomi.com>
2023-08-03 03:10:56 -07:00
yangjiao
391bf7b37c sched/mqueue/mq_receive: fix the wrong return value when message queue is not opened for reading.
In POSIX testcase "open_posix_testsuite/conformance/interfaces/mq_receive/11-2.c", it will return "EPERM" when message queue is not opened for reading, but the standard POSIX specification in URL “https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html” requires that "EBADF" be returned.So in this change, i update it.

Signed-off-by: yangjiao <yangjiao@xiaomi.com>
2023-08-03 03:10:56 -07:00
zhangyuan21
8f39ba6ae4 arch: update g_running_tasks when context switch occurred
When supporting high-priority interrupts, updating the
g_running_tasks within a high-priority interrupt may be
cause problems. The g_running_tasks should only be updated
when it is determined that a task context switch has occurred.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-08-01 09:35:18 -07:00
guanyi
55a727b1ce ltp: sigprocmask fix
1. change signal/sig_procmask.c and pthread/pthread_sigmask.c together
2. clear signals unconditionally

Signed-off-by: guanyi <guanyi@xiaomi.com>
2023-07-31 22:29:31 -07:00
yangyalei
30367fd4cd sched: inherit parent priority by default, except idle
Signed-off-by: yangyalei <yangyalei@xiaomi.com>

asdfas

Signed-off-by: yangyalei <yangyalei@xiaomi.com>
2023-07-31 07:50:10 -07:00
yangyalei
b2a9c6a3e5 sched: inherit parent priority by default
fix ltp pthread_cond_wait_1 test question, child should inherit parent
priority by default.
nsh> ltp_pthread_cond_wait_1
Error: the policy or priority not correct

Signed-off-by: yangyalei <yangyalei@xiaomi.com>
2023-07-31 07:50:10 -07:00
Ville Juven
c126ee8468 sched/assert.c: Fix style check error 2023-07-31 07:48:53 -07:00
Ville Juven
83105cfa49 sched/assert: Store table for all registers instead of buffer
This way the registers can be read easily
2023-07-31 07:48:53 -07:00
zhangyuan21
e50d1211df task_spawnparms: out of loop when ret less than 0
The nxspawn_dup2 function will return a value greater than 0,
so the loop should only exit if ret is less than 0.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-07-31 00:47:42 -07:00
Xiang Xiao
fc5e85da1b drivers: Format pointer through "%p" for kthread_create
to remove the unnecessary cast and unify the usage

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-30 23:40:59 +03:00
guoshichao
9d7f349664 libs/pthread/pthread_atfork: fulfill implement pthread_atfork function
1. add the pthread_atfork implementation
2. the pthread_atfork implementation are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_atfork.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-26 10:41:52 +02:00
guoshichao
0092b3e30f sched/signal/sig_nanosleep: fix the clock_nanosleep posix case
1. make the clock_nanosleep can pass
ltp/open_posix_testsuite/clock_nanosleep 13-1, 10-1, 9-1 cases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-23 22:02:03 -07:00
Xiang Xiao
97ed003842 pthread: Extend the up limit of PTHREAD_CLEANUP_STACKSIZE to 255
tos field is uint8_t, so it doesn't make sense to limit the max value to 32

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-20 08:11:30 +02:00
chao an
f10b54a081 cmake: fix CMake build break
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-15 23:32:36 +08:00
liaoao
8706d68318 assert: check intstack_sp when print last stack in irq context
Signed-off-by: liaoao <liaoao@xiaomi.com>
2023-07-14 21:36:11 +08:00