Commit Graph

1823 Commits

Author SHA1 Message Date
Xiang Xiao
d7d3177668 sched/wdog: Remove flags field from wdog_s to save memory
since WDOG_ISACTIVE can check func field instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I21d7f9cfe6195c8ccb6cc5925ff66f3c89822f9d
2021-07-01 19:27:10 -03:00
Nathan Hartman
a8cbcd084f signal: Fix docs and comments related to SIGWORK and its config
Documentation/reference/os/wqueue.rst:

    * CONFIG_SIG_SIGWORK: Fix sentence that was cut off in the
      middle.

include/signal.h:

    * SIGWORK: Fix grammar in comment.

sched/Kconfig:

    * config SIG_SIGWORK: Fix ---help--- text to indicate that
      this user-configured signal number may be used by various
      internal worker threads.
2021-06-30 21:22:49 -05:00
Xiang Xiao
13780dada3 sched: Add kthread_create_with_stack
let caller customize the stack buffer

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I878818ec1ce5650165dbbe2d72a4618cb2e6a094
2021-06-27 12:35:13 -03:00
Abdelatif Guettouche
0a4982a80e Introduce ARCH_HAVE_EXTRA_HEAPS, this config is going to be used for
chips that have multiple separate heaps.
For now it's used to enable APIs to initialize the different heaps
during the start sequence but can be extended for other purposes that
manage those heaps.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-06-26 09:52:43 -05:00
Xiang Xiao
ae9b5fd306 Replace mktime with timegm in rtc and fs driver
since kernel component should use UTC instead local time

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Icf939e1ab0af8e577105f539d2553bc67b3b3d10
2021-06-23 13:43:32 -03:00
Juha Niskanen
ea1144630d sched/task/task_spawn.c: initialize variables explicitly
'pid' cannot really be used uninitialized, but Clang analyzer does not
see it.  Add initializer to silence it and also make debugging slightly
easier.

Explicitly set pid's address to NULL to fix this complaint:

  "Address of stack memory associated with local variable 'pid' is still
   referred to by the global variable 'g_spawn_parms' upon returning to
   the caller."

No functional change.

Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2021-06-22 03:44:02 -05:00
Abdelatif Guettouche
af5e0c620f Rename MODULE_TEXT to TEXT_HEAP as the latter is more generic.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-06-18 07:14:17 -05:00
Xiang Xiao
bec68ad8ea sched/posix_spawn: Don't insert name at the begin of argv
since the standard require the caller pass the name explicitly
https://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html:
The argument argv is an array of character pointers to null-terminated strings.
The last member of this array shall be a null pointer and is not counted in argc.
These strings constitute the argument list available to the new process image.
The value in argv[0] should point to a filename that is associated with the
process image being started by the posix_spawn() or posix_spawnp() function.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-15 07:32:33 -06:00
Xiang Xiao
90f71bd017 Revert "sched/posix_spawn: Don't insert name at the begin of argv"
This reverts commit 032086870d.
2021-06-15 07:32:33 -06:00
Xiang Xiao
032086870d sched/posix_spawn: Don't insert name at the begin of argv
since the standard require the caller pass the name explicitly
https://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html:
The argument argv is an array of character pointers to null-terminated strings.
The last member of this array shall be a null pointer and is not counted in argc.
These strings constitute the argument list available to the new process image.
The value in argv[0] should point to a filename that is associated with the
process image being started by the posix_spawn() or posix_spawnp() function.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id79ffcc501ae9552dc4e908418ff555f498be7f1
2021-06-14 07:11:53 -06:00
chao.an
6e6eecaa73 arch: adjust idle stack offset to reserve space of stack info
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-09 13:30:13 -05:00
YAMAMOTO Takashi
b3e8535ad6 Revert "tls: Move pthread key destructor to libc"
This reverts commit cc514d7791.

* It introduced a regression.
  https://github.com/apache/incubator-nuttx/issues/3868

* It seems conceptually wrong to have per-process data in
  the main thread's stack.
2021-06-09 07:59:44 -05:00
Xiang Xiao
5b2a17b892 Include assert.h in necessary place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-08 13:06:08 -07:00
Huang Qi
cc514d7791 tls: Move pthread key destructor to libc
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-06-06 15:25:56 -06: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
Xiang Xiao
ae216cf9e9 sched/task: Simplify the syscall handling of task_spawn
It's better to save one argument by returning pid directly.
This change also follow the convention of task_create.
BTW, it is reasonable to adjust the function prototype a
little bit from both implementation and consistency since
task_spawn is NuttX specific API.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-01 12:45:10 +09:00
Xiang Xiao
d7f96003cf Don't include debug.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-01 06:42:02 +09:00
Alin Jerpelea
c0ed011874 sched: update licenses to Apache
Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-05-25 08:46:53 -05:00
Nathan Hartman
f61214cc0d mqueue, btqueue: Fix some typos (e.g., essage -> message)
include/nuttx/mqueue.h:
sched/mqueue/mq_msgqfree.c:
wireless/bluetooth/bt_queue.c:

    * Fix typos in comments only. No functional changes.
2021-05-25 07:39:24 +09:00
Xiang Xiao
001e7c3e76 sched: Don't include nuttx/sched.h inside sched.h
But let nuttx/sched.h include sched.h instead to
avoid expose nuttx kernel API to userspace.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-05-24 12:11:53 +09:00
Huang Qi
a2941532bd pthread: Avoid recursive pthread_exit call
pthread_exit will be called recursive when pthread_cancel
or other cleanup operation with syscalls that support
cancellation, to avoid this by mark current tcb flag as
TCB_FLAG_CANCEL_DOING instead of TCB_FLAG_CANCEL_PENDING.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-05-21 22:46:52 -06:00
Huang Qi
d374d55926 pthread: Implement destructor of pthread_key_create
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: I6aafba9680257cba071bf1f72ae2ec2c475f5fb0
2021-05-21 22:46:52 -06:00
Huang Qi
f4a0b7aedd libc: Call pthread_exit in user-space by up_pthread_exit
Drop to user-space in kernel/protected build with up_pthread_exit,
now all pthread_cleanup functions executed in user mode.

* A new syscall SYS_pthread_exit added
* A new tcb flag TCB_FLAG_CANCEL_DOING added
* up_pthread_exit implemented for riscv/arm arch

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-05-21 22:46:52 -06:00
Huang Qi
81a01d089b libc/pthread: Fix comment and document issue
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-05-21 22:46:52 -06:00
Huang Qi
f1a92e9cbb libc: Move pthread_cleanup to user space
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-05-21 22:46:52 -06:00
Huang Qi
54eef9f639 libc: Move pthread_exit to userspace
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-05-21 22:46:52 -06:00
Gregory Nutt
bb9b58bdde libc: Move pthread_create to user space
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: I5c447d94077debc79158686935f288e4c8e51e01
2021-05-21 22:46:52 -06:00
Xiang Xiao
8afb16ca55 Don't include errno.h from spawn.h
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-05-19 10:11:15 +02:00
Jiuzhu Dong
5ec3ef0e56 group/group_signal: cancel dispatch signal when
the number of members in the group is zero.

Repetition step:
If using waitpid() to wait a task has exited, the waitpid will use
nxsing_kill with signal number 0 to determine if that task is still
alive, and will call group_signal to dispatch signal for each member
of the group and perform signal handing checks, it will assert at
sched/group/group_signal.c:261.

Change-Id: I75ef015a261101277436d742897ce68fed44b5da
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-05-17 07:14:27 -05:00
Nathan Hartman
8af9d39667 Documentation, comments: Minor improvements and typos fixed 2021-05-09 19:12:13 -07:00
Masayuki Ishikawa
0ec5563a60 sched: group: Fix group_signal() for SMP
Summary:
- This commit fixes the signest_test issue with lc823450-xgevk

Impact:
- SMP with CONFIG_SCHED_CHILD_STATUS=y

Testing:
- Tested with ostest with lc82345-xgevk:rndis
- NOTE: need to revert the commit 65274d5fdf

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-04-23 03:25:14 -05:00
Masayuki Ishikawa
1b00e5d518 spinlock: Remove SP_SECTION
Summary:
- SP_SECTION was introduced to allocate spinlock in non-cachable
  region mainly for Cortex-A to stabilize the NuttX SMP kernel
- However, all spinlocks are now allocated in cachable area and
  works without any problems
- So SP_SECTION should be removed to simplify the kernel code

Impact:
- None

Testing:
- Build test only

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-04-20 22:41:44 -05:00
YAMAMOTO Takashi
418e11b8b3 modlib: Always use separate allocation for text and data
Pros:

* Reduce code differences
* Smaller allocations for !CONFIG_ARCH_USE_MODULE_TEXT

Cons:

* Likely to use more memory for !CONFIG_ARCH_USE_MODULE_TEXT in total

Tested with:

* sim:module on macOS
* esp32-devkit:nsh + CONFIG_MODULE on qemu
* lm3s6965-ek:qemu-protected + CONFIG_EXAMPLES_SOTEST on qemu
2021-04-19 22:20:20 -05:00
Masayuki Ishikawa
1a9e7efde5 smp: Remove CONFIG_SMP_IDLETHREAD_STACKSIZE
Summary:
- The CONFIG_SMP_IDLETHREAD_STACKSIZE was introduced to optimize
  the idle stack size for other than CPU0
- However, there are no big differences between the idle stacks.
- This commit removes the config to simplify the kernel code

Impact:
- All SMP configurations

Testing:
- Tested with ostest with the following configs
- spresense:smp, spresense:rndis_smp
- esp32-devkitc:smp (QEMU), maix-bit:smp (QEMU)
- sabre-6quad:smp (QEMU), sabre-6quad:netnsh_smp (QEMU)
- raspberrypi-pico:smp, sim:smp (x86_64)

Signed-off-by: Masayuki Ishikawa <asayuki.Ishikawa@jp.sony.com>
2021-04-19 21:46:39 -05:00
Xiang Xiao
2335b69120 arch: Allocate the space from the beginning in up_stack_frame
arch: Allocate the space from the beginning in up_stack_frame

and modify the affected portion:
1.Correct the stack dump and check
2.Allocate tls_info_s by up_stack_frame too
3.Move the stack fork allocation from arch to sched

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-04-16 12:41:41 +09:00
YAMAMOTO Takashi
51490bad55 modlib: Implement sh_addralign handling
I've seen a module with 16 bytes .rodata alignment for xmm operations.
It was getting SEGV on sim/Linux because of the alignment issue.
The same module binary seems working fine after applying this patch.

Also, tested on sim/macOS and esp32 on qemu,
using a module with an artificially large alignment. (64 bytes)
2021-04-14 21:17:07 -05:00
Anthony Merlino
9c8c2b0db2 Separate CLOCK_TIMEKEEPING and SCHED_TICKLESS. 2021-04-13 11:42:31 -05:00
Masayuki Ishikawa
a51a60d485 sched: task: Fix to initialize the task-specific data
Summary:
- I noticed that getopt() test in ostest wailed with
  esp32-devkitc:smp and spresense:smp
- Finally, I found that the task-specific data is not
  initialized.
- This commit fixes this issue

Impact:
- None

Testing:
- Tested with ostest esp32-devkitc:smp and spresense:smp

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-04-03 08:32:46 -06:00
Gregory Nutt
2ccc0da0c7 Move getopt() variables into TLS
getopt() in the FLAT build environment is not thread safe.  This is because global variables that are process-specific in Unix are truly global in the FLAT build.  Moving the getopt() variables into TLS resolves this issue.

No side-effects are expected other than to getopt()

Tested with sim:nsh
2021-03-31 21:13:01 -05:00
Xiang Xiao
bea6e0ddd7 sched/signal: Implement SA_NODEFER and SA_RESETHAND
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I9baa72b272c8877022cd94722824f393c7087721
2021-03-31 18:27:01 -03:00
Alan C. Assis
c172ced3ba sched: Move the default Task Stack size to Stack menu 2021-03-31 02:29:04 -05:00
YAMAMOTO Takashi
bf93b1d9d1 sched/module/mod_insmod.c: Fix ELF64-related printf formats 2021-03-23 02:48:42 -07:00
Xiang Xiao
e14c458747 mm/heap: Move semaphore related declaration to private header
since other subsystem doesn't need call these function anymore

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Idfb217c412db62d9f17f427310b75bb78785dc50
2021-03-22 15:35:32 +01:00
Gregory Nutt
2208aabbc6 Correct elapsed time calculation
Elapsed time calculation must always be be the current time minus a time in the past.  Not vice versa.

Also corrects and improves some comments.
2021-03-19 23:18:28 -07:00
Gregory Nutt
5b7dfa0213 Sporadic scheduler: Fix compile errors when assertions are enabled:
Fix missing semicolon at the end of a DEBUGASSERT statement:

sched/sched_sporadic.c: In function 'sporadic_budget_expire':
sched/sched_sporadic.c:512:15: error: expected ';' before 'period'
  512 |               period = (sporadic->repl_period >> 1) - unrealized;
      |               ^~~~~~
sched/sched_sporadic.c: In function 'nxsched_resume_sporadic':
sched/sched_sporadic.c:1078:19: error: expected ';' before 'period'
 1078 |                   period = (sporadic->repl_period >> 1) - unrealized;
      |                   ^~~~~~

Fix use of uninitialized variable in DEBUGASSERT statement:

sched/sched_sporadic.c:466:27: warning: 'sporadic' may be used uninitialized in this function [-Wmaybe-uninitialized]
  466 |                   sporadic->nrepls > 0);

Also fixes some typos.

There should be no unexpected side-effects of this changed.

Tested with the stm32f4discovery:sporadic configuration (see PR #3097
2021-03-19 23:18:28 -07:00
Masayuki Ishikawa
2976bb212e sched: pthread: Remove a redundant critical section in pthread_condclockwsait.c
Summary:
- This commit removes a redundant critical section in pthread_condclockwait.c

Impact:
- None

Testing:
- Tested with ostest with the following configs
  - maix-bit:smp, esp32-devkitc:smp, sabre-6quad:smp
  - spresense:smp, sim:smp
  - maix-bit:nsh, sabre-6quad:nsh
  - sprsesnse:wifi, sim:ostest
- Tested with nxplayer with the folowing configs
  - spresense:wifi_smp, spresense:rndis_smp

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-03-19 23:01:20 -07:00
Jiuzhu Dong
e96c8b9283 fs: allocate file/socket dynamically
Change-Id: I8aea63eaf0275f47f21fc8d5482b51ffecd5c906
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-03-17 06:46:42 -07:00
Masayuki Ishikawa
7758f3dcb1 sched: semaphore: Remove a redundant critical section in nxsem_tickwait()
Summary:
- This commit removes a redundant critical section in nxsem_tickkwait()

Impact:
- None

Testing:
- Tested with ping with the following configs
- spresense:rndis, spresense:rndis_smp

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-03-16 19:50:18 -07:00
Masayuki Ishikawa
65dec5d10a sched: semaphore: Remove a redundant critical section in nxsem_clockwait()
Summary:
- This commit removes a redundant critical section in nxsem_clockwait()

Impact:
- None

Testing:
- Tested with ostest with the following configurations
- maix-bit:smp (QEMU), sim:smp, esp32-devkitc:smp (QEMU)
- sabre-6quad:smp (QEMU), spresense:smp
- maix-bit:nsh (QEMU), sim:ostest, esp32-devkitc:ostest (QEMU)
- sabre-6quad:nsh (QEMU), spresense:wifi

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-03-16 19:50:18 -07:00
Gustavo Henrique Nihei
330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00