Commit Graph

55 Commits

Author SHA1 Message Date
hujun5 451f9372db sched/environ: There is no need to use sched_[un]lock
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-11 02:43:11 +08:00
Alin Jerpelea eb9030c891 sched: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-09-12 01:10:14 +08:00
pengyinjie 6b21bebcd1 [env]:Fixed spacing and typo issues in code comment descriptions
[Desc]: as title

Signed-off-by: pengyinjie <pengyinjie@xiaomi.com>
2024-08-27 21:52:56 +08:00
Yanfeng Liu 8a8c1f943e sched/tcb: use shared group for kthreads
Kthreads can share the group data so that to reduce overheads.
This implements shared kthread group via:

- use `tcb_s` instead of `task_tcb_s` for kthreads
- use `g_kthread_group` when creating kthreads
- use stackargs to start tasks and kthreads

see pull/12320 for test logs.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-06-23 22:24:19 +08:00
chao an ad4fb55d1f sched/environ: Improve performance of set/unset environment
reserve dimensional array of environment to avoid frequent scaling

Signed-off-by: chao an <anchao@lixiang.com>
2024-04-03 00:10:56 +08:00
chao an dfd1e38b40 sched/environ: check envcp validity before hold sched_lock()
check envcp validity before hold sched_lock() to avoid unnecessary schedule lock

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-05 22:24:14 +08:00
dongjiuzhu1 968e89303f env_dup: fix issue about USE_AFTER_FREE
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-26 00:11:14 +08: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
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
Xiang Xiao 6f6fce95a2 Replace all sprintf with snprintf
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-08 09:57:01 +02:00
wangbowen6 d77b53957c sched/env: add tg_envc in task_group_s to avoid some loops in code
this commit optimize the env api speed

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-02-25 23:10:37 +02:00
lilei19 38f64f559d change strcpy to strlcpy
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-02-24 12:15:40 +08:00
Xiang Xiao aed85964ff sched/env: Don't need copy env variable from parent in env_dup
since caller always pass them if needed

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-19 08:22:56 +09:00
chao.an 704b03f833 sched: fix visual studio Compiler Warning (level 4) C4706
D:\code\incubator-nuttx\sched\environ\env_dup.c(81):
  warning C4706: assignment within conditional expression
  [D:\code\nuttx\incubator-nuttx\vs20221\sched\sched.vcxproj]

Reference:
https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4706?view=msvc-170

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-17 18:33:44 +08: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
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
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
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
Ville Juven 3581668c6b env_dup: Allocate memory from the correct memory pool
When the initial proxy task is duplicated into the first user task,
the environment exists in kernel memory and this must be copied to user
memory.

The memory allocated for the new task was allocated with the parent's
priority which is incorrect. Use the new task's priority instead.

Follow-up for: #5753
2022-03-22 10:15:29 +08:00
Ville Juven 50578dc501 Fix the initial idle tasks environment
- User mode allocator was used for setting up the environment. This
  works in flat mode and probably in protected mode as well, as there
  is always a a single user allocator present
- This does not work in kernel mode, where each user task has its own
  heap allocator. Also, when the idle tasks environment is being set,
  no allocator is ready and the system crashes at once.

Fix this by using the group allocators instead:
- Idle task is a kernel task, so its group is privileged
- Add group_realloc
- Use the group_malloc/realloc functions instead of kumm_malloc
2022-03-16 20:21:19 +08: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
Alin Jerpelea dee641828f sched: nxstyle fixes
nxstyle fixes to pass CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Alin Jerpelea 8935ac4cc3 sched: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can mograte the licenses
to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08: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
Xiang Xiao cde88cabcc Run codespell -w with the latest dictonary again
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-02-23 22:27:46 +01:00
Xiang Xiao 68951e8d72 Remove exra whitespace from files (#189)
* Remove multiple newlines at the end of files
* Remove the whitespace from the end of lines
2020-01-31 09:24:49 -06:00
Xiang Xiao 6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
zhangyuan7 b33fc302f0 net/inet and net/tcp: Fix tcp close flow; free the connection after all tcp close process finished. 2019-08-30 06:44:43 -06:00
Gregory Nutt bde0509cae tools/nxstyle.c: Fix error in conditional logic that was preventing detection bad brace alignment. Add logic to handle alignment of braces in data initializators which following slightly different indentation rules. 2019-06-30 10:35:10 -06:00
Gregory Nutt f914ec6e2b tools/nxstyle.c: Fix logic that detects if an operator is correctly delimited with spaces. sched/: Various changes because sched/ C files were used as Guinea Pigs to test nstyle.c. 2019-03-01 10:50:02 -06:00
Gregory Nutt 4eeba49507 Documentation/NuttShell.html: Add a little more information for the NSH set command. 2018-10-02 11:57:39 -06:00
Gregory Nutt af50ab0088 sched/environ/env_unsetenv.c: Fix a memory leak introduced by the previous commit. 2018-09-30 11:45:59 -06:00
Gregory Nutt d3c2373940 sched/environ/env_unsetenv.c: Fix and error in unsetenv() when unsetting the last of the environment variables. 2018-09-30 11:40:10 -06:00
Gregory Nutt 9546481054 Fix some typographical errors. 2018-09-14 06:55:45 -06:00
Gregory Nutt 25fa50d504 fs/proc and sched/environ: Add support for a procfs entry that will permit examining the environment of any task. 2018-08-10 10:16:39 -06:00
Gregory Nutt b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Gregory Nutt 7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Gregory Nutt d33857002a sched/env_dup.c: Fix an error in the duplication of the child tasks environment in the special case where the parent's environment was created, but then all of the variables were unset. In that case, there is still an allocation in place but the size of the allocation is zero. This case was not being handled correctly when a child task attempts to create its environment and inherit the zero-size partent environment. Noted by Anthony Merlino. 2017-09-18 19:02:54 -06:00
Arjun Hary b274a97840 Miscellaneous fixes from astyle tool. 2017-08-14 17:19:27 -06:00
Gregory Nutt 18ce4ff57b sched/: Review and correct some stylistic inconsistencies 2016-08-07 08:25:30 -06:00
Gregory Nutt 6543c570d4 Remove some empty file section section header comments 2016-02-17 17:38:39 -06:00
Gregory Nutt 74db48202e sched/: Replace explict references to g_readytorun with indirect references via the this_task() macro 2016-02-06 17:44:41 -06:00
Gregory Nutt 79d554939e sched/: Fix some spacing issues 2015-10-07 19:59:14 -06:00
Gregory Nutt cb9e27c3b0 Standardize naming used for public data and function groupings 2015-10-02 16:30:35 -06:00
Gregory Nutt 322f9f401c Simplify how C source files are selected in the build 2014-10-07 07:42:36 -06:00
Gregory Nutt 54fa3b0b59 Rename kfree to kmm_free for consistency with other naming conventions 2014-08-31 17:04:02 -06:00
Gregory Nutt 9aca0c1c84 Rename kumalloc to kumm_malloc and kuzalloc to kumm_zalloc for consistency with other naming 2014-08-31 16:24:24 -06:00
Gregory Nutt 9ad7dae4c1 Rename kufree to kumm_free for consistency with other naming 2014-08-31 16:15:11 -06:00