Commit Graph

2024 Commits

Author SHA1 Message Date
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
Xiang Xiao
76803f4a07 sched/environ: Replace get_environ_ptr with environ
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 22:55:47 +03:00
Xiang Xiao
9794068a9c sched/environ: Remove the unneeded cast in env_dup
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 22:55:47 +03:00
Xiang Xiao
ce49c80976 sched/task: Correct the comment about environment variable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 22:55:47 +03:00
Ville Juven
4c1b66246d env_dup: Fix copying of env between address environments
If address environments are in use, it is not possible to simply
memcpy from from one process to another. The current implementation
of env_dup does precisely this and thus, it fails at once when it is
attempted between two user processes.

The solution is to use the kernel's heap as an intermediate buffer.
This is a simple, effective and common way to do a fork().

Obviously this is not needed for kernel processes.
2022-04-21 18:38:37 +08:00
Xiang Xiao
2c82bef702 sched/environ: Refine the environment variables storage layout
to confirm the standard and then implement get_environ_ptr correctly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-18 10:33:37 +03:00
Petro Karashchenko
ebffcdc992 semaphore: fix usage of NXSEM_INITIALIZER
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-04-17 11:38:34 +08:00
Xiang Xiao
701bbaac74 sched/environ: Ensure tg_envp terminated by double '\0'
so we can compute the whole environ string length from it

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-14 07:49:00 +03:00
anjiahao
a191d9bc3c sched/pthread_create:fix bug,delete data_sem
if a pthread set attr is detach,and when call pthread_create,
new thread exit quikly,new thread's tcb be free,then pthread_create
use new thread's tcb will crash.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-14 01:42:16 +08:00
chao.an
a594a5d7a8 sched/init: drivers_initialize() should be late than up_initialize()
up_initialize
|
 ->up_serialinit
   |
    ->uart_register  /* ("/dev/console", &CONSOLE_DEV); */

drivers_initialize
|
 ->syslog_console_init
   |
    ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-12 07:51:34 +09:00
Xiang Xiao
51ffa3edb0 sched/irq: Fix array overrun in coverity check
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-08 21:02:13 -03:00
Xiang Xiao
aed5dadc3d sched/irq: Remove CONFIG_SCHED_IRQMONITOR when define CALL_VECTOR
since up_perf_ API doesn't couple with CONFIG_SCHED_IRQMONITOR

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-08 21:02:13 -03:00
Xiang Xiao
bf3da321c9 sched/wqueue: Simplify CALL_WORKER dispatch condition
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-08 21:02:13 -03:00
chao.an
8cb008c3c7 sched/note: correct flatten format
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-08 02:41:25 +08:00
anjiahao
47304e7254 sched/pthread:need check pthread is DETACHED
pthread_join need check thread is DETACHED,
Whether to wait according to the result.And,
if a thread is DETACHED,it will not set a new
attr.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-08 01:41:06 +08:00
zhuyanlin
26ab4e9200 mod_insmod: fix coverity warning
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-04-02 20:09:42 +08:00
zhuyanlin
c46a926e2b sched_note: fix buffer size warning in coverity
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-04-02 20:09:42 +08:00
zhuyanlin
497d24f145 timerexpiration:fix DEADCODE when RR_INTERVAL or SCHED_SPORADIC not select
tmp is always true for CONFIG_RR_INTERVAL > 0
and CONFIG_SCHED_SPORADIC not select

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-04-02 12:52:08 +03:00
chao.an
6e0ba2bed5 sched/note: add support of trace section mark
The implementation of this feature is based on android systrace:

https://source.android.com/devices/tech/debug/ftrace

Application developers are more concerned about the performance of
the specified application section,
added two APIs to implement performance measurement:

void sched_note_begin(uintptr_t ip, FAR const char *buf);
void sched_note_end(uintptr_t ip, FAR const char *buf);
or
SCHED_NOTE_BEGIN();  /* defined to sched_note_begin(_THIS_IP_, __FUNCTION__) */
SCHED_NOTE_END();    /* defined to sched_note_end(_THIS_IP_, __FUNCTION__) */

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-01 21:06:00 +08:00
chao.an
e05f64735f sched/trace: correct the note print format
note print should with Instruction pointer.

e.g:

        trace_printk("hello NuttX");

trace dump:

hello-6  [000] .... 23080.367994: 0xc044a005: hello NuttX

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-01 21:06:00 +08:00
chao.an
6c86e77dee sched/note: unify the data format
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-01 21:06:00 +08:00
Jiuzhu Dong
37ef22b106 sigact: get free sigact from freelist always successful
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-01 13:38:29 +08:00
ligd
e9f17947b7 task: don't set default signal in kernal thread
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:53:14 +09:00
ligd
0c1f63625a signal: Don't do schedule_sigaction when there is no action
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 10:53:14 +09:00
ligd
d09be7d658 workqueue: add work_foreach support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-29 18:03:08 +08:00
zhuyanlin
0460367a70 irq_csection: fix assert warning
constant 65535 with expression of type 'int16_t' (aka 'short')
is always true

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-03-29 13:44:01 +08:00
Petro Karashchenko
98ba65c422 c89: get rid of designated initializers in common code
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-28 13:39:27 +08:00
zouboan
466063ac9e sched/sched/sched_timerexpiration: change from sched_time to eventtime
Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-27 18:22:58 +03:00