Commit Graph

1044 Commits

Author SHA1 Message Date
ryancw 91fe5ec1b8 [src][clock] RT_TICK_PER_SECOND为1000时tick不用进行转换 2024-10-29 18:19:18 -04:00
Yuqiang Wang b3d59050b0
[kernel] Specification interrupt nested level variable declaration type (#9568) 2024-10-23 17:08:29 -04:00
zhangjing fed7c9acda [src][signal]:fix issue with inconsistency between sig_mask and sigaddset implementations when using musl libc 2024-10-22 20:59:05 +08:00
heyuanjie87 b14a14057c 解决编译错误 2024-10-21 13:05:08 +08:00
heyuanjie87 08888b6e23 去除多余空格 2024-10-21 13:05:08 +08:00
heyuanjie87 063e6e7c0c 解决编译警告 2024-10-21 13:05:08 +08:00
heyuanjie87 1045bcb9df 给使用独立的defunct线程添加限制条件 2024-10-21 13:05:08 +08:00
heyuanjie87 2351981e83 分离defunct 2024-10-21 13:05:08 +08:00
heyuanjie87 e2b311c3b5 [kernel]在smart模式也启用"回收线程"
lwp的某些资源回收放到了后台,其中会引起线程挂起,而idle不应该被挂起
2024-10-21 13:05:08 +08:00
Shell 645b3c6015 feat: remove RT_USING_SCHED_THREAD_CTX
Prepare for the next release by removing the compatible codes for v5.1.0
and before.

Changes:

- Remove the compatible macros and Kconfig options for the old struct
  rt_thread layout.

Signed-off-by: Shell <smokewood@qq.com>
2024-10-19 15:19:41 -04:00
Shell 5796e0d646 feat: arm64: update thread self on sp-switch
This patch improves the atomicity of context switching by ensuring that
the stack pointer (sp) and thread self updates occur simultaneously.
This enhancement is crucial for maintaining thread safety and
preventing potential inconsistencies during context switches.

Changes:
- Modified `cpuport.h` to use `ARM64_THREAD_REG` for thread self access.
- Added an `update_tidr` macro in `context_gcc.S` to streamline thread ID
  updates.
- Adjusted `rt_hw_context_switch_to` and `rt_hw_context_switch` to call
  `update_tidr`, ensuring atomic updates during context switches.
- Cleaned up `scheduler_mp.c` by removing redundant thread self
  assignments.

Signed-off-by: Shell <smokewood@qq.com>
2024-10-11 00:09:01 -04:00
Meco Man ee5014d32f [klibc] add kerrno.h 2024-09-23 21:30:37 +08:00
Meco Man cee64a41a4 [klibc] format comments after #9459 2024-09-22 18:25:47 -04:00
wdfk-prog 5ec20c4289
fix:[kstdio]Disable "-Wimplicit-fallthrough" below GNUC V7 (#9459)
fix:Disable "-Wimplicit-fallthrough" below GNUC V7
2024-09-22 09:49:59 +08:00
zms123456 08221b54d0
[kernel][mutex] fix bug of thread exit without releasing mutex & add error check log 2024-09-11 18:03:43 -04:00
zms123456 9631f04abe
[utest]add mutex_pi_tc
* add mutex_pi
* fix assertion error when thread wakeup while waiting mutex
2024-09-06 17:44:02 -04:00
Shell d2160d352c
fixup: ipc: protect taken_list on shared lock
为什么提交这份PR (why to submit this PR)
Issue: using iperf server with sshd together and the kernel will get stuck occasionally.

taken_list is accessed from other mutex when updating priority.

你的解决方案是什么 (what is your solution)
protect taken_list on shared lock, but not on mutex local spinlock.

Signed-off-by: Shell <smokewood@qq.com>
2024-09-03 22:06:16 -04:00
Yaochenger 7469edd165 [fix][device] 修正使用rt_device_create创建设备,使用rt_device_destroy删除失败的问题 2024-09-03 18:24:45 -04:00
Shell dfd8ccf262 feat: kernel/libcpu: fit into ilp32d 2024-09-01 15:12:34 -04:00
Shell cbf6b641c2 feat: add memset zero for rt_thread_init
`rt_object_allocate()` will clear memory after new rt_thread allocate in
`rt_thread_create()`. However, in `rt_thread_init()` the same behavior
is missing, which corrupt the consistence of the API.

Changes:
- Added `memset()` zero for `rt_thread_init()` in the entry

Signed-off-by: Shell <smokewood@qq.com>
2024-08-27 00:48:06 -04:00
CrazyJhq d87f30cf21
mem: fix some log issue in src/slab.c 2024-08-18 18:33:52 -04:00
wdfk-prog 8d3ad68caf [src][tick]rt_tick setting arbitrary value function is added to support low-power wake-up tick compensation 2024-07-19 11:51:39 +08:00
rcitachi 14fb55933b
[lwp][vdso] Add VDSO functionality under the aarch64 architecture (#9176)
Add VDSO functionality under the aarch64 architecture
2024-07-15 17:58:29 +08:00
zms123456 c018a3e3fd
[src][thread]fix rt_thread_resume return value error (#9114)
fix rt_thread_resume return value error
2024-06-29 11:27:39 +08:00
supperthomas b79d5013ff [doc][doxygen] Fix hook struct error.
Signed-off-by: supperthomas <78900636@qq.com>
2024-06-27 23:05:12 +08:00
supperthomas 038ff8b2e5 [doc][doxygen]: Fix doxygen warning in comment
kservice.c:474: warning: The following parameter of rt_backtrace_to_buffer(rt_thread_t thread, struct rt_hw_backtrace_frame *frame, long skip, rt_ubase_t *buffer, long buflen) is not documented:
  parameter 'thread'
kernel.h:157: warning: unable to resolve reference to '_rt_errno' for \ref command

Signed-off-by: supperthomas <78900636@qq.com>
2024-06-26 01:21:57 +08:00
zms123456 59193dfeeb
[timer]add all soft timer config (#9048)
* add all soft timer

* update wq

* add timer test

* shield LOG_D
2024-06-20 04:20:38 +08:00
Shell 65c9947225
[libcpu] rv64: support for ARCH_REMAP_KERNEL (#9067)
* [libcpu] support for ARCH_REMAP_KERNEL

These changes introduce support for the ARCH_REMAP_KERNEL configuration,
which isolates kernel space in high virtual address regions. This feature
is necessary to enhance memory protection and management by segregating
user and kernel spaces more effectively.

Changes:
- Updated conditional macros to check for ARCH_REMAP_KERNEL instead of
  ARCH_KERNEL_IN_HIGH_VA in board initialization files to reflect the new
  configuration option.
- Modified qemu-virt64-riscv Kconfig and SConstruct files to include and
  utilize ARCH_REMAP_KERNEL.
- Created a new linker script `link_smart.lds` for smart linking in qemu-virt64-riscv.
- Updated rtconfig.py to use a more flexible execution path setup.
- Enhanced user address space definitions in `lwp_arch.h` to support the
  new virtual address mappings.
- Adjusted kernel memory initialization and mapping logic in `c906/mmu.c`
  and `virt64/mmu.c` to account for high virtual address regions.
- Added Kconfig option to enable ARCH_REMAP_KERNEL for RISCV64 architectures.
- Enhanced memory setup functions to support new mapping scheme, including
  updates to early page table setup and address relocation logic.

These modifications ensure that the system can utilize high memory
addresses for the kernel, improving memory isolation and system stability.

Signed-off-by: Shell <smokewood@qq.com>

* fixup: CI run failed

* bsp: default config without using smart

* fixup: static checks

* restore rt_hw_mmu_kernel_map_init for D1

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-06-18 11:15:59 +08:00
zms123456 1e287b2591
[src][kservice]fix shutdown log (#9061)
fix shutdown log
2024-06-13 16:09:56 +08:00
Shell e5b7f3fdd8
[kservice] Enhance support for backtrace service (#9037)
[feat] Enhance support for backtrace service

rt_backtrace_formatted_print() and rt_backtrace_to_buffer() to help
debug routines.

Also, following modification are included:
- make rt_backtrace_frame patchable with weak attr
- replace lwp backtrace with sync output

Signed-off-by: Shell <smokewood@qq.com>
2024-06-13 08:55:53 +08:00
Shell 6ca327d8ce
[smart] add CPU/thread usage tracing config (#8947)
* [smart] add CPU usage tracing config

This patch introduces following features:

- Added CPU usage tracing functionality, enabled by default, for
  applications like 'top'
- update time as smart independent

Signed-off-by: Shell <smokewood@qq.com>

* fixup: add ump idle thread

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-06-04 00:06:41 +08:00
wdfk-prog 8e54e31c74
[IDLE] 修改注释,避免造成歧义 (#9010) 2024-05-29 22:18:13 +08:00
Shell f17f994f8c
[arm64] add hw thread self (#8942)
* [libcpu] arm64: Add hardware thread_self support

This patch introduces hardware-based thread self-identification
for the AArch64 architecture. It optimizes thread management by
using hardware registers to store and access the current thread's
pointer, reducing overhead and improving overall performance.

Changes include:
- Added `ARCH_USING_HW_THREAD_SELF` configuration option.
- Modified `rtdef.h`, `rtsched.h` to conditionally include
  `critical_switch_flag` based on the new config.
- Updated context management in `context_gcc.S`, `cpuport.h`
  to support hardware-based thread self.
- Enhanced `scheduler_mp.c` and `thread.c` to leverage the new
  hardware thread self feature.

These modifications ensure better scheduling and thread handling,
particularly in multi-core environments, by minimizing the
software overhead associated with thread management.

Signed-off-by: Shell <smokewood@qq.com>

* fixup: address suggestion

* fixup: rt_current_thread as global

* scheduler: add cpu object for UP scheduler

Also, maintain the rt_current_thread in cpu object on UP scheduler.

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-28 14:27:55 +08:00
Shell 6b12bce22f
[quality] fixup compiler warning (#8961)
Signed-off-by: Shell <smokewood@qq.com>
2024-05-21 19:47:42 +08:00
zms123456 6101f1fd29
[components][driver]add isr statistics (#8955)
add isr statistics
2024-05-21 09:01:42 +08:00
Shell e82c53559b
[utest] add device find (#8959)
* [utest] add device find

Signed-off-by: Shell <smokewood@qq.com>

* fixup: add test

* fixup: ptr aliasing

* quality: meaning parameter

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-21 08:56:35 +08:00
Shell f2d6325b43
[smart] select console device dynamically (#8949)
* [smart] select console device dynamically

- Fixed compiler warning on terminal subsystem for
  `components/lwp/terminal/terminal.h`
- Updated default console setup to dynamically select an appropriate tty
  device based on the configured console device name.

Signed-off-by: Shell <smokewood@qq.com>

* fixup: remove useless codes

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-17 13:19:00 +08:00
Shell e25fc8b511
[libcpu/arm64] add C11 atomic ticket spinlock (#8882)
* [libcpu/arm64] add C11 atomic ticket spinlock

Replace the former implementation of flag-based spinlock which is unfair

Besides, C11 atomic implementation is more readable (it's C anyway),
and maintainable. Cause toolchain can use their builtin optimization and
tune for different micro-architectures. For example armv8.5 introduces a
better instruction. The compiler can help with that when it knows your
target platform in support of it.

Signed-off-by: Shell <smokewood@qq.com>

* fixup: RT_CPUS_NR

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-16 15:45:12 +08:00
Shell 989cc61f48
[hrtimer] fixup use-after-free (#8928)
Signed-off-by: Shell <smokewood@qq.com>
2024-05-11 08:53:42 +08:00
Shell 017b2a5a44
[smart] fixup arm64 aspace switch (#8925)
* [smart] fixup arm64 aspace switch

Signed-off-by: Shell <smokewood@qq.com>

* fixup: arm add arch_kernel_mmu_table_get

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-10 09:17:19 +08:00
geniusgogo f770f543a6 fix RT_DEBUGING_ASSERT 2024-05-09 00:33:32 -04:00
Meco Man 0871140759 [kernel][timer] remove wordy logs 2024-05-07 21:50:52 -04:00
wdfk-prog 7879986e38
[timer] The rt_timer_check and _soft_timer_check functions are merged (#8884) 2024-05-08 09:27:38 +08:00
Shell 48bd0e49f2
[ipc] support of lockless rt_completion (#8887)
* [ipc] lockless rt_completion implementation

The new rt_completion implemented by lockless algorithm can improve timer resolution for up to ~12%, compare to sem IPC.

Signed-off-by: Shell <smokewood@qq.com>

* fixup: error

* remove useless changes

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-08 09:25:57 +08:00
Shell 6977cf9101
[src] add rt_hw_cpu_id() wrapper API (#8894)
* [src] add rt_hw_cpu_id() wrapper API

rt_hw_cpu_id() is an unsafe API which should not be used by most codes
directly. It's error-prone because it must be used in proper context,
otherwise it can lead to errors and unpredictable behavior.

This patch adds a wrapper API for rt_hw_cpu_id() to address this risk.
It includes the context-checking functionality and provides a safer
alternative for obtaining CPU IDs, ensuring that it is used correctly
within the appropriate context.

Signed-off-by: Shell <smokewood@qq.com>

* fixup UMP

* update API & comment

* ci: cpp_check

---------

Signed-off-by: Shell <smokewood@qq.com>
2024-05-08 09:22:09 +08:00
zms123456 9112dffec8
[src][Kconfig]make RT_ASSERT independent of RT_USING_DEUBG 2024-05-06 20:40:30 -04:00
Shell 2c9b7c10b9
[kernel] add rt_thread_close()
* [thread] Add rt_thread_close()

This patch introduces a new function `rt_thread_close()` to enhances the
usability and maintainability by providing a dedicated mechanism for
closing threads.

- A new function `rt_thread_close()` is added to the API, providing a
  standardized approach for closing threads.
- The `rt_thread_close()` function removes a thread from the thread
  queue, updates its status to indicate closure, and performs the thread
  timer detaching which is a embedded timer in thread object.
- Additionally, the `rt_thread_detach()` function is modified to utilize
  `rt_thread_close()` internally, streamlining the thread detachment
  process.

Signed-off-by: Shell <smokewood@qq.com>
2024-05-01 00:49:09 -04:00
zms123456 fa1c473a96
[src][thread]bind cpu fixup (#8872)
bind cpu fixup
2024-04-28 15:19:50 +08:00
wdfk-prog 52ebdf6bdb
[mem]When using SLAB, calls to memcheck and memtrace will be abnormal (#8862)
* [mem]When using SLAB, calls to memcheck and memtrace will be abnormal

* [mem]The memtrace printing system does not match the display
2024-04-27 18:27:33 +08:00
Meco Man d68e47eb25 [klibc] organize and renmae macros, and add CI check 2024-04-20 21:52:49 -04:00