Commit Graph

1369 Commits

Author SHA1 Message Date
xuanlin
2c93467436 pthreads: Add support static pthread stack. Add standard pthread_attr_setstack() and pthread_attr_getstack(). In all cases where the stack is released, add check to see which allocator must be used to free the stack: The user or the kernel allocator. 2018-08-23 09:49:20 -06:00
Xiang Xiao
377eb30129 binfmt: Add binfmt_initialize(). All binary formats are now registered centrally vs. in board-specific logic. This simplifies the usage of the binfmt subsystem. 2018-08-23 09:09:39 -06:00
Gregory Nutt
b56d5a7548 Revert "sched/init: Add option to mount block device for INIT_FILEPATH case"
This reverts commit e5f9b7d66b.
2018-08-22 07:29:55 -06:00
Xiang Xiao
e5f9b7d66b sched/init: Add option to mount block device for INIT_FILEPATH case 2018-08-22 06:57:00 -06:00
anchao
0124b629a9 sched/symtab: Reference default symtab name to binfmt 2018-08-22 06:21:20 -06:00
Gregory Nutt
8e203e09d4 Costmetic changes 2018-08-19 11:19:43 -06:00
Gregory Nutt
5a23ca37b1 Cosmetic update to comments. 2018-08-17 14:23:38 -06:00
Gregory Nutt
8c61c2f31b Remove trailing spaces at the end of lines. 2018-08-13 07:39:38 -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
3973640fff Update some comments. Remove references to non-existent CONFIG_MAX_TASK_ARG. 2018-08-08 17:06:46 -06:00
Gregory Nutt
a2428db499 configs/olimex-stm32_p407: Add logic to support initialization of the kernel module symbol table installed in the pass2/ directory during the application phase of the build. The kmodule configuration appears to be fully functional. 2018-08-07 10:50:25 -06:00
Masayuki Ishikawa
651f5e2622 Merged in masayuki2009/nuttx.nuttx/fix_loadable_elf_with_smp (pull request #706)
sched/group: Fix a deadlock when loading an ELF

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: GregoryN <gnutt@nuttx.org>
2018-08-06 03:36:14 +00:00
Gregory Nutt
c6adc4ba8e sched/pthread/pthread_initialize.c: Fix a warning found in build testing (that is actually and bug and would cause an incorrect value to be returned in many cases. 2018-08-05 16:23:07 -06:00
Gregory Nutt
c2267a57a0 Kconfig files: Fix several errors noted by Alex Denisov in Bitbucket issue 115. 2018-08-05 10:48:02 -06:00
Gregory Nutt
4fa546c5d8 Refresh a configuration: Fix an assertion that was messed up in the previous commit. 2018-08-05 08:41:32 -06:00
Gregory Nutt
20a86dfc1b binfmt/ and sched/group: Re-architect the way that loadable ELF or NXFLAT modules are unloaded. Memory resources must be recovered when the task loaded into memory exits. The originmal implementatino used the death-of-child SIGCHLD signal to perform the unload. There are several problems with this: It is overly complex, it requires that the parent task stay resident while the loaded task runs, and it has fatal logic flaws in the protected and kernel model builds because the user signal handler attempts to run in the kernel address space. This commit corrects with using a mindlessly simply BINFMT callback when the task exits. 2018-08-05 08:09:54 -06:00
Simon Liedl
6fe770bb21 Merged in sliedl/nuttx (pull request #700)
sched/mqueue/mq_notify.c: Fix - only part of struct copied to internal structure

As source adress the adress of the struct member sigev_value was used,
and it is not located the start of the struct.
This leads to invalid data being copied to internal structure.
Both source and destination should be of type struct sigevent* .

Approved-by: GregoryN <gnutt@nuttx.org>
2018-07-30 12:50:04 +00:00
Gregory Nutt
4c67062457 Squashed commit of the following:
binfmt/, libs/libc/unistd, and others:  Rename CONFIG_EXECFUNCS_SYMTAB to CONFIG_EXECFUNCS_SYMTAB_ARRAY.  Rename CONFIG_EXECFUNCS_NSYMBOLS to CONFIG_EXECFUNCS_NSYMBOLS_VAR.  Unlike CONFIG_EXECFUNCS_NSYMBOLS, CONFIG_EXECFUNCS_NSYMBOLS_VAR holds the name of an 'int' variable that contains the number of symbols in the symbol table.

    configs/sama5d4-ek:  Partial update to knsh build instructions.
2018-07-15 11:20:37 -06:00
Alan Carvalho de Assis
283b73edc5 Fix lots of typos in C comments and Kconfig help text 2018-07-08 18:24:45 -06:00
Gregory Nutt
8fca244f36 syscall: clock_systimer() is no longer a system call. It has been replaced with the equivalent, standard interface clock() as the system call.
sched/clock:  Move the implementation of clock() from libs/libc/time to sched/clock.  This is necessary because it calls the (now) internal OS function clock_systimer.  clock() is now accessed only via a system call in certain configuratins.
libs/libc/wqueue:  Replace calls to clock_systimer() with calls to the equivalent clock().
2018-06-16 12:50:28 -06:00
Gregory Nutt
8fdbb1e0a4 Elimate use of the non-standard type systime_t and replace it the equivalent, standard type clock_t
Squashed commit of the following:

    sched:  Rename all use of system_t to clock_t.
    syscall:  Rename all use of system_t to clock_t.
    net:  Rename all use of system_t to clock_t.
    libs:  Rename all use of system_t to clock_t.
    fs:  Rename all use of system_t to clock_t.
    drivers:  Rename all use of system_t to clock_t.
    arch:  Rename all use of system_t to clock_t.
    include:  Remove definition of systime_t; rename all use of system_t to clock_t.
2018-06-16 12:16:13 -06:00
Gregory Nutt
450e0809de sched/Kconfig: Add a dependency 2018-06-16 11:36:27 -06:00
Gregory Nutt
a6a88198c0 sched/modules: Be consistent use of binary loader debug instrumentation. Was mixed system and binary loader debug. libs/libc/modlib: Switch from systemb to binary load debug to be consistent with sched/modules. 2018-06-01 10:10:17 -06:00
Alan Carvalho de Assis
f3d940aac5 sched/module/mod_modhandle.c: Fix typo in debug statement. 2018-06-01 08:54:37 -06:00
EunBong Song
5951bcd837 Change ordering of round-robin time slice check (sched_process_scheduler()) and processing of wdog timers (wd_timer()). wd_timer()'s callback function can change current running task and, hence, must be done after the time slice check.
The time slice check will decrement the currently running task's time slice allotment.  If such a context switch occurs, then the newly started task will lost one could of that allotment before it even has a chance to run.
2018-04-13 07:38:15 -06:00
Masayuki Ishikawa
97ca4ef956 Merged in masayuki2009/nuttx.nuttx/change_copyright (pull request #621)
Change all Sony related copyright to conform with our company's internal rules.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2018-04-04 12:35:47 +00:00
Masayuki Ishikawa
1d958980bd Merged in masayuki2009/nuttx.nuttx/fix_smp_bugs (pull request #615)
Fix SMP related bugs

* sched/sched: Fix a deadlock in SMP mode

    Two months ago, I introduced sched_tasklist_lock() and
    sched_tasklist_unlock() to protect tasklists in SMP mode.
    Actually, this change works pretty well for HTTP audio
    streaming aging test with lc823450-xgevk.

    However, I found a deadlock in the scheduler when I tried
    similar aging tests with DVFS autonomous mode where CPU
    clock speed changed based on cpu load. In this case, call
    sequences were as follows;

    cpu1: sched_unlock()->sched_mergepending()->sched_addreadytorun()->up_cpu_pause()
    cpu0: sched_lock()->sched_mergepending()

    To avoid this deadlock, I added sched_tasklist_unlock() when calling
    up_cpu_pause() and sched_addreadytorun(). Also, added
    sched_tasklist_lock() after the call.

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

* libc: Add critical section in lib_filesem.c for SMP

    To set my_pid into fs_folder atomically in SMP mode,
    critical section API must be used.

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

* mm: Add critical section in mm_sem.c for SMP

    To set my_pid into mm_folder atomically in SMP mode,
    critical section API must be used.

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

* net: Add critical section in net_lock.c for SMP

    To set my pid (me) into fs_folder atomically in SMP mode,
    critical section API must be used.

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2018-03-20 12:34:38 +00:00
Gregory Nutt
90c6d71503 Update some comments. 2018-03-16 09:34:09 -06:00
Gregory Nutt
06e7533bb0 Update some comments. 2018-03-14 08:17:50 -06:00
Gregory Nutt
149f3bd471 Standardization of some function headers. 2018-03-13 09:56:16 -06:00
Gregory Nutt
b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Gregory Nutt
e6e7dae05b sched/clock: Fix a recently introduced name collision 2018-03-12 13:36:06 -06:00
Gregory Nutt
02df81bc5f Squashed commit of the following:
drivers/lcd:  Add an IOcTL to FT80x driver to write to FIFO CMD RAM.
2018-02-20 15:24:52 -06:00
Masayuki Ishikawa
7062ca2c03 Merged in masayuki2009/nuttx.nuttx/lc823450_smp_test (pull request #601)
lc823450 smp test

* sched/clock: Replace critical section APIs with spin lock APIs in clock_gettime.c

    This change will improve performance for SMP systems but nothing
    changes for non-SMP systems. (Pls see include/nuttx/irq.h)

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

* sched/sched: Remove unnecessary DEBUGASSERT in sched_removereadytorun.c

    In SMP mode, rtrtcb is not always at the g_readytorun.head.
    This change removes DEBUGASSERT() to avoid this condition.

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2018-02-15 14:18:25 +00:00
Gregory Nutt
3ddea73dc1 arch/arm/src/armv7-a: Port the SMP change by Masayuki Ishikawa to the ARMv7-A family. 2018-02-14 08:36:34 -06:00
Gregory Nutt
d7fae340c1 Trivial changes from review of last PR. 2018-02-14 08:20:40 -06:00
Masayuki Ishikawa
b9707776d6 Merged in masayuki2009/nuttx.nuttx/fix_signal_handing_for_smp (pull request #599)
Fix signal handing for smp

* sched/signal: Remove SMP related logic in sig_dispatch.c

    This change prevents from a deadlock in up_schedulesigaction.c
    where inter-CPU signal handling is actually implemented.

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

* arch/arm/src/armv7-m: Fix signal handling for SMP

    In previous implementation, signal handling for SMP was incorrect.
    Thus, for example, if an inter-CPU signal happened an incorret tcb
    was signaled and caused ASSERT().

    This change fixes the issues and works for both inter-CPU signal
    handling and signal handling on the same CPU.

    Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2018-02-14 14:10:32 +00:00
Gregory Nutt
50ab5d638a sched/task: It is not appropriate for logic in task_exit() to call the new version of this_task(). sched/irq: Remove redundant fetch of CPU index; configs/sabre-6qguad: update README. 2018-02-06 19:06:33 -06:00
Gregory Nutt
cce21bef32 sched/sched: sched_lock() and sched_unlock().. back out some changes I made recently. The seemed correct but apparently not. Also reorder to logic so that g_global_lockcount is incremented for the very minimum amount of time. 2018-02-06 13:49:21 -06:00
Gregory Nutt
de34b4523f sched/ and arch/arm/src/armv7-a: Replace a few more occurrences of this_task() with current_task(cpu) in an effort to get the i.MX6 working in SMP mode again. It does not yet work, sadly. 2018-02-06 11:17:33 -06:00
Gregory Nutt
0ba7853016 sched/irq: Fix a infinite recursion problem that a recent change introduced into the i.MX6 SMP implementation. 2018-02-06 09:18:03 -06:00
Alan Carvalho de Assis
fb50c44d08 Fix various issues noted by Coverity 2018-02-06 09:13:16 -06:00
Gregory Nutt
56bb76caca sched/irq: Fix an error in a assertion introduced in commit 37c9b3d54a. Noted by Masayuki Ishikawa. 2018-02-05 21:13:42 -06:00
Gregory Nutt
b884fb9fed sched/sched: Extend the last global lock change to work with the lc823450-xgevk which does not support the atomic fetch add but does support disabling interprocessor interrupts. Disabling interprocessor interrupts will also guarantee that the TCB addres calculation is atomic. 2018-02-05 13:32:09 -06:00
Gregory Nutt
37c9b3d54a sched/sched: Implements a global scheduler lock capability as part of SMP support. This allows the scheduler to be locked with no knowledge or access to the TCB of the currently running task. This is necessary because accessing the TCB of the currenlty running task is, itself, a non-atomic operation. This global scheduler lock cpability was add just to support that atomic access to the TCB. 2018-02-05 13:12:36 -06:00
Gregory Nutt
f51693e36a sched/sched: Clean up some logic that I committed yesterday. Add more comments and conditional logic to clarify the issues. 2018-02-05 08:31:21 -06:00
Gregory Nutt
8a48031615 Update some comments 2018-02-05 07:58:00 -06:00
Gregory Nutt
873ffd13bc sched/sched: Temporarily comment out some bad logic 2018-02-04 18:18:26 -06:00
Gregory Nutt
aaf1079fa7 sched/sched: Fix a typo in the previous commit 2018-02-04 18:15:45 -06:00
Masayuki Ishikawa
c8a372702a sched/sched: SMP: Fix this_task() to be an atomic operation. In the previous implementation, this_task() was defined in sched.h by using just a macro current_task(this_cpu()). However, I found that this is not atomic and actually sometimes switching CPU happened in executing the macro when we tested audio steaming plus executing commands via telnet. This change resolves this issue by implementing atomic this_task()in sched_thistask.c which is newly introduced. 2018-02-04 16:59:09 -06:00
Gregory Nutt
31278bc163 Kconfigs: Add comments and a dependency. 2018-02-04 16:32:14 -06:00
Gregory Nutt
5beab6fbf0 spin_lock_irqsave() and spin_unlock_irqrestore() are only valid if the CPU supports global disabling of interrupts. 2018-02-04 15:41:22 -06:00
Gregory Nutt
fad70bf90e Update some comments 2018-02-03 09:35:46 -06:00
Gregory Nutt
12474d2c38 Eliminate new warnings due to unused local variables noted in build testing. 2018-02-01 10:25:48 -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
d87b54099a Eliminate a warning. 2018-01-31 17:54:20 -06:00
Gregory Nutt
8191640320 sched/task: Correct a compile error introduced with last big set of changes. 2018-01-31 16:17:23 -06:00
Gregory Nutt
50ca32e254 Squashed commit of the following:
sched/:  Convert legitimate uses of task_create() to nxtask_create().  Review handling of returned values from all uses of kthread_create() (as well as nxtask_create()).
    graphics/:  Review return values for all calls to kthread_start() because it no longer returns an errno.
    drivers/:  threads started by drivers should be kernel threads, not user tasks.  Review return values for all calls to kthread_start() because it no longer returns an errno.
    configs/:  threads started by board bringup logic should be kernel threads, not user tasksi (part 2 of 2).
    sched/task:  Add nxtask_create().  Kthread_create() and nxtask_create() are internal OS functions and should not modify the errno variable.  configs/:  threads started by board bringup logic should be kernel threads, not user tasks.
2018-01-31 16:11:54 -06:00
Gregory Nutt
da50646bcf sched/wdog: wd_start() is an internal OS function and should not set the errno value. Reviewed and updated every call to wd_start() to verify if return value is used and if so if the errno value is accessed. 2018-01-31 10:09:14 -06:00
Masayuki Ishikawa
d295f11a3a SMP: Introduce a new global IRQ clearing logic and tasklist protection.
The previous implementation of clearing global IRQ in sched_addreadytorun()
and sched_removereadytorun() was done too early. As a result, nxsem_post()
would have a chance to enter the critical section even nxsem_wait() is
still not in blocked state. This patch moves clearing global IRQ controls
from sched_addreadytorun() and sched_removereadytorun() to sched_resumescheduler()
to ensure that nxsem_post() can enter the critical section correctly.

For this change, sched_resumescheduler.c is always necessary for SMP configuration.
In addition, by this change, task_exit() had to be modified so that it calls
sched_resumescheduler() because it calls sched_removescheduler() inside the
function, otherwise it will cause a deadlock.

However, I encountered another DEBUGASSERT() in sched_cpu_select() during
HTTP streaming aging test on lc823450-xgevk. Actually sched_cpu_select()
accesses the g_assignedtasks which might be changed by another CPU. Similarly,
other tasklists might be modified simultaneously if both CPUs are executing
scheduling logic. To avoid this, I introduced tasklist protetion APIs.

With these changes, SMP kernel stability has been much improved.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2018-01-31 15:35:36 +09:00
Gregory Nutt
3521aaf944 Squashed commit of the following:
binfmt/, configs/, grahics/, libc/, mm/, net/, sched/:  OS references to the errno variable should always use the set_errno(), get_errno() macros
    arch/arm/src/stm32 and stm32f7:  Architecture-specific code is not permitted to modify the errno variable.  drivers/ and libc/:  OS references to the errno variable should always use the set_errno(), get_errno() macros
2018-01-30 17:57:36 -06:00
Gregory Nutt
82982f7972 sched/: Fix several inappropriate accesses to get_errno() that were missed in previous changes (some going back to nuttx-.23). Add new nxsched_setscheduler() and nxsched_getaffinity() which are equivalent to their counterparts without the nx on front. These versions do not modify the errno value. Changed all calls within the OS to use these newer versions of the functions. 2018-01-30 16:16:41 -06:00
Gregory Nutt
170a50c690 Squashed commit of the following:
sched/sched:  Correct some build issues introduced by last set of changes.
    sched/sched:  Add new internal OS function nxsched_setaffinity() that is identical to sched_isetaffinity() except that it does not modify the errno value.  All usage of sched_setaffinity() within the OS is replaced with nxsched_setaffinity().
    sched/sched:  Internal functions sched_reprioritize() and sched_setpriority() no longer movidify the errno value.  Also renamed to nxsched_reprioritize() and sched_setpriority().
    sched/sched:  Add new internal OS function nxsched_getscheduler() that is identical to sched_getscheduler() except that it does not modify the errno value.  All usage of sched_getscheduler() within the OS is replaced with nxsched_getscheduler().
    sched/sched:  Add new internal OS function nxsched_setparam() that is identical to sched_setparam() except that it does not modify the errno value.  All usage of sched_setparam() within the OS is replaced with nxsched_setparam().
    sched/sched:  Add new internal OS function nxsched_getparam() that is identical to sched_getparam() except that it does not modify the errno value (actually, the previous value erroneously neglected to set the errno value to begin with, but this fixes both issues).  All usage of sched_getparam() within the OS is replaced with nxsched_getparam().
2018-01-30 11:08:18 -06:00
Gregory Nutt
12e3e47d3c Update comments, mostly spelling errors. 2018-01-27 09:37:46 -06:00
Gregory Nutt
bcffeae4fd Update README and some comments 2018-01-20 12:59:56 -06:00
Gregory Nutt
82cc0ead67 sched/sched: Fix some priority inheritance related issues noted during review of logic. Also add some REVISIT comments for some issues noted in the design. 2018-01-20 07:44:35 -06:00
Gregory Nutt
be3c2d1e36 Change ASSERT(false) to DEBUGPANIC(). 2018-01-19 09:07:19 -06:00
Gregory Nutt
f012fe96cb sched/sched/sched_sporadic.c: fix compiler error when priority inheritance is enabled. Noted by eunb.song@samsung.com 2018-01-19 08:54:29 -06:00
Masayuki Ishikawa
99b944fb6e sched/semaphore: Add ASSERT(false) in nxsem_post() if no waiting task is found.
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2018-01-19 22:17:58 +09:00
Masayuki Ishikawa
ab3fa89023 SMP: Introduce spin_lock_wo_note() and spin_unlock_wo_note()
These APIs are used in sched_note.c to protect instumentation data.
The deffrence between these APIs to exsiting spin_lock() and spin_unlock()
is that they do not perform insturumentation to avoid recursive call
when SCHED_INSTRUMENTATION_SPINLOCKS=y.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2018-01-17 13:29:42 +09:00
Gregory Nutt
e238c8b090 sched/clock/clock_systimer.c: Change the way that the 64-bit time is sampled. Previously, we disabled interrupts before sampling the 64-bit timer since the uint64_t access is not atomic on most CPUs. However, disabling (local) interrupts does not work in the SMP case. In that case, the timer interrupt will be running on only one of the CPUs; disabling interrupts on a different CPU will provide no protection from timer rollover. To work around this, logic was added that samples 64-bit timer is sampled twice and if 32-bit rollover was detected between samples, then loops until there is no rollover. 2018-01-15 11:05:45 -06:00
Masayuki Ishikawa
0ecef4dbcb clock_systimer: Replace critical section APIs with spinlock APIs. (64bit only)
If SMP=n or SMP=y && SPINLOCK_IRQ=n, this works in the same way as before.
If SMP=y && SPINLOCK_IRQ=y, performance will be improved.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2018-01-15 15:08:11 +09:00
Gregory Nutt
134bac3810 arch/arm/src/lpc54xx: Add configuration logic to the empty SPI driver. Still missing all data tranfer logic. 2018-01-13 15:38:55 -06:00
Gregory Nutt
fdf4e40b6a configs/lpcxpresso-lpc54628: Correct SRAM base address in all configurations. 2018-01-13 08:34:58 -06:00
Gregory Nutt
0080225473 sched/irq: Add a configuration option to show interrupt information via a procfs file. 2018-01-12 18:26:46 -06:00
Gregory Nutt
9f80e4ccf1 sched/: Various fixes for typos, improved parameter verification. 2018-01-12 18:26:45 -06:00
Gregory Nutt
7d131fe711 Update TODO list 2018-01-03 08:32:57 -06:00
Gregory Nutt
b2adb4917f arch/arm/src/lpc54xx: Add register level debug output for Ethernet testing. Fixed a few start up problems. Still hangs on start-up, however. 2017-12-31 11:11:57 -06:00
Masayuki Ishikawa
e1f71f988b sched/semaphore/spinlock.c: Add memory barrier operations in spin_unlock()
In ARM document regarding memory barrires, SP_DMB() must be issued
before changing a spinlock state to SP_UNLOCKED. However, we found
that SP_DSB() is also needed to ensure that spin_unlock() works
correctly for network streaming aging test.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2017-12-21 17:40:08 +09:00
Masayuki Ishikawa
27d4bb43e6 Merged in masayuki2009/nuttx.nuttx/lc823450_smp_test (pull request #557)
sched/sched: Remove DEBUGASSERT() in sched_mergepending()

Because this DEBUGASSERT() assumes that while loop executes only once.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2017-12-18 12:09:06 +00:00
Masayuki Ishikawa
6150299f54 Merged in masayuki2009/nuttx.nuttx/irq_spinlock (pull request #550)
SMP: Introduce spin_lock_irqsave() and spin_unlock_irqrestore()

These APIs are simplified version of enter_critical_section() and
leave_critical_section() to protect data (e.g. registers) in SMP mode.
By using these APIs inside drivers, performace will be improved.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2017-12-07 19:39:04 +00:00
Juha Niskanen
e8ee632378 sched/task/task_exithook.c: Clear atexit() function pointer before calling it. On most archs, up_assert() calls exit() so without this change, if atexit() function triggers an assertion we are in endless loop. 2017-11-30 06:41:57 -06:00
Masayuki Ishikawa
5acd26c88f sched/semaphore/spinlock.c: Disable local interrupts in spin_setbit() and spin_clrbit() in order to avoid a deadlock condition. 2017-11-23 06:55:53 -06:00
Gregory Nutt
b9fa3e167e Changes from review of clock_nanosleep(): Misplaced right bracket, but return value in one failure case. 2017-11-11 18:01:28 -06:00
Gregory Nutt
35ee844590 sched/signal/sig_nanosleep.c and libc/time/lib_nanosleep.c: Implement clock_nanosleep(). nanosleep() is now reduced to a libc wrapper around clock_nanosleep(). 2017-11-11 17:44:59 -06:00
Juha Niskanen
cc7af2b0d0 procfs: Fix uptime being close to maximum 32-bit value in certain config 2017-11-10 09:01:39 -06:00
Gregory Nutt
93f7cd2d53 sched/sched/sched_cpuselect.c: For SMP, In order to find the cpu with the lowest priority thread, we have to remember the already found lowest priority. Noted by Anonymous in Issue #75 2017-11-06 13:33:46 -06:00
Masayuki Ishikawa
09d4874509 Merged in masayuki2009/nuttx.nuttx/lc823450 (pull request #524)
Fix DEBUGASSERT() issues with nxhello on lc823450-xgevk

* sched/task: Remove DEBUGASSERT in task_exitstatus() and task_groupexit()

* graphics: Change DEBUGASSERT condition in nx_runinstance()

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2017-10-31 16:53:00 +00:00
Jussi Kivilinna
8eaa587c98 sched: move POSIX thread specific data from pthread TCB to common TCB structure. This change allows using pthread_getspecific/pthread_setspecific from main thread. Patch also enables using pthread data with config option CONFIG_DISABLE_PTHREAD=y. 2017-10-25 07:06:42 -06:00
Gregory Nutt
5b385f4d4d kthread_create(): Rename kernel_thread() to kthread_create() for better naming consistency with task_create() and kthread_delete(). 2017-10-16 11:38:00 -06:00
Gregory Nutt
b1a41b7620 task_delete(): Do not permit user applications to delete kernel threads. 2017-10-16 09:07:27 -06:00
Gregory Nutt
3c3c712887 nxsig_timedwait: Add logic to suppress the wait if there is a pending cancellation. 2017-10-12 09:53:17 -06:00
Gregory Nutt
fd58bfd9c0 sched/signal: Add logic to wake up a thread that is waiting on a signal if it is canceled. 2017-10-12 08:55:19 -06:00
Gregory Nutt
3cd41b0408 sched/task: task_exithook.c fails to link if signals are disabled because was unconditionally trying to send the SIGCHLD signal to the parent in certain configurations. Noted by Jeongchan Kim. 2017-10-11 10:43:30 -06:00
Gregory Nutt
eb79a575f6 Fix a few places where there was a semicolon following the 'if' condition, makeing the following logic unconditional. 2017-10-10 14:24:13 -06:00
Gregory Nutt
e11e3b2607 Squashed commit of the following:
Change all calls to mq_receive() and mq_timedreceive() in the OS to calls to nxmq_receive() and nxmq_timedreceive(), making appropriate changes for differences in return values.

    sched/mqueue:  Add nxmq_receive() and mxmq_timedreceive() which are functionally equivalent to the standard mq_receive and mq_timedreceive() except that (1) they do not create cancellation points, and (2) the do not modify the application's errno variable.
2017-10-10 09:57:40 -06:00
Gregory Nutt
fca07be1df Squashed commit of the following:
Change all calls to mq_send() and mq_timedsend() in the OS to calls to nxmq_send() and nxmq_timedsend(), making appropriate changes for differences in return values.

    sched/mqueue:  Add internal function nxmq_send() and nxmq_timedsend() that are equivalent to mq_send() and mq_timedsend() except that they do not create cancellation points and do to not modify the errno variable.
2017-10-10 08:44:12 -06:00
Gregory Nutt
9b61cc6b25 task: Add new cancellation point interface, check_cancellation_point(). 2017-10-09 09:43:04 -06:00
Gregory Nutt
e7c52bac60 Squashed commit of the following:
sched/mqueue:  Rename all private static functions for use the nxmq_ vs. mq_ naming.

    sched/mqueue:  Rename all OS internal functions declared in sched/mqueue/mqueue.h to begin with nxmq_ vs. mq_.  The mq_ prefix is reserved for standard application interfaces.
2017-10-09 09:06:46 -06:00
Gregory Nutt
a857cc04e4 Fix some build problems after recent separation of internal OS from application interfaces. The build problem only occurs in the PROTECTED and KERNEL builds where separate libraries are built for the applications and for use within the OS. In these cases, the correct interfaces must be used. This commit fixes a few of these, so I can get through build testing, but there are many more that need fixin'. 2017-10-08 08:13:47 -06:00
Gregory Nutt
d633c9bf8c Squashed commit of the following:
Replace all calls to sigprocmask() in the OS proper with calls to nxsig_procmask().

    sched/signal:  Add internal OS interface nxsig_procmask().  This internal interface is equivalent to the standard sigprocmask() used by applications except that it does not modify the errno value.  Also fixes a problem in that the original sigprocmask() was not setting the errno.
2017-10-07 12:16:10 -06:00
Gregory Nutt
4810499d3a Squashed commit of the following:
Replace all calls to sigqueue() in the OS proper with calls to nxsig_queue() to avoid accessing the errno variable.

    sched/signal:  Add nxsig_queue() which is functionally equivalent to sigqueue() except that it does not modify the errno variable.
2017-10-07 10:57:09 -06:00
Gregory Nutt
a20e4e7eef Eliminate a warning introduced with last commit. 2017-10-07 08:51:31 -06:00
Gregory Nutt
9e25d89223 Squashed commit of the following:
Replace all usage kill() in the OS proper with nxsig_kill().

    sched/signal:  Add nxsig_kill() which is functionally equivalent to kill() except that it does not modify the errno variable.
2017-10-07 08:22:18 -06:00
Gregory Nutt
936df1bcb5 Adds new OS internal functions nxsig_sleep() and nxsig_usleep. These differ from the standard sleep() and usleep() in that (1) they don't cause cancellation points, and (2) don't set the errno variable (if applicable). All calls to sleep() and usleep() changed to calls to nxsig_sleep() and nxsig_usleep().
Squashed commit of the following:

    Change all calls to usleep() in the OS proper to calls to nxsig_usleep()

    sched/signal:  Add a new OS internal function nxsig_usleep() that is functionally equivalent to usleep() but does not cause a cancellaption point and does not modify the errno variable.

    sched/signal:  Add a new OS internal function nxsig_sleep() that is functionally equivalent to sleep() but does not cause a cancellaption point.
2017-10-06 10:15:01 -06:00
Gregory Nutt
fdd0dcc0b6 This commit adds internal versions of the signal interfaces:
sigtimedwait() -> nxsig_timedwait()
  sigwaitinfo()  -> nxsig_waitinfo()
  nanosleep()    -> nxsig_nanosleep()

The internal OS versions differ from the standard application interfaces in that:

  - They do not create cancellation points, and
  - they do not modify the application's errno variable

Squashed commit of the following:

    sched/signal:  Replace all usage of sigwaitinfo(), sigtimedwait(), and nanosleep() with the OS internal counterparts nxsig_waitinfo(), nxsig_timedwait(), and nxsig_nanosleep().

    sched/signal:  Add nxsig_nanosleep().  This is an internal OS version of nanosleep().  It differs in that it does not set the errno varaiable and does not create a cancellation point.

    sched/signal:  Add nxsig_timedwait() and nxsig_waitinfo().  These are internal OS versions of sigtimedwait() and sigwaitinfo().  They differ in that they do not set the errno varaiable and they do not create cancellation points.
2017-10-06 08:28:20 -06:00
Gregory Nutt
21c97b16cf Revert "sem_wait.c edited online with Bitbucket. Fix some correct but useless code."
What was I thinking?  I missed that litle minus sign and the possibility that the errno might be some positive non-zero value.

This reverts commit 43880878e4.
2017-10-05 16:01:01 -06:00
Gregory Nutt
43880878e4 sem_wait.c edited online with Bitbucket. Fix some correct but useless code. 2017-10-05 21:55:24 +00:00
Gregory Nutt
8198ba6a6d This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.

Squashed commit of the following:

    sched/signal:  Fix a few compile warnings introduced by naming changes.

    sched/signal:  Rename all private, internal signl functions to use the nxsig_ prefix.

    sched/signal:  Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.

    sched/signal:  Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.

    sched/signal:  Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.

    sched/signal:  Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.

    sched/signal:  Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.

    sched/signal:  Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.

    sched/signal:  Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 13:25:25 -06:00
Gregory Nutt
7cc63f90d9 sched/semaphore: sem_trywait() modifies the errno value and, hence, should not be used within the OS. Use nxsem_trywait() instead. 2017-10-05 07:59:06 -06:00
Gregory Nutt
29b5b3667f sched/semaphore: sem_timedwait() is a cancellation point and, hence, cannot be called from within the OS. Created nxsem_timedwait() that is equivalent but does not modify the errno and does not cause cancellation. All calls to sem_timedwait() change to calls to nxsem_timedwait() in the OS. 2017-10-05 07:24:54 -06:00
Gregory Nutt
9568600ab1 Squashed commit of the following:
This commit backs out most of commit b4747286b1.  That change was added because sem_wait() would sometimes cause cancellation points inappropriated.  But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.

    In the OS, all calls to sem_wait() changed to nxsem_wait().  nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.

    In all OS functions (not libraries), change sem_wait() to nxsem_wait().  This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.

    sched/semaphore:  Add the function nxsem_wait().  This is a new internal OS interface.  It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
2017-10-04 15:22:27 -06:00
Gregory Nutt
42a0796615 Squashed commit of the following:
sched/semaphore:  Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable.  Changed all references to sem_post in the OS to nxsem_post().

    sched/semaphore:  Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable.  Changed all references to sem_destroy() in the OS to nxsem_destroy().

    libc/semaphore and sched/semaphore:  Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable.  Changed all references to sem_setprotocol in the OS to nxsem_setprotocol().  sem_getprotocol() was not used in the OS
2017-10-03 15:35:24 -06:00
Gregory Nutt
83cdb0c552 Squashed commit of the following:
libc/semaphore:  Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable.  Changed all references to sem_getvalue in the OS to nxsem_getvalue().

    sched/semaphore:  Rename all internal private functions from sem_xyz to nxsem_xyz.  The sem_ prefix is (will be) reserved only for the application semaphore interfaces.

    libc/semaphore:  Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable.  Changed all references to sem_init in the OS to nxsem_init().

    sched/semaphore:  Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.

    sched/semaphoate:  Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
2017-10-03 12:52:31 -06:00
Gregory Nutt
374f1bd46c binfmt: Don't schedule starthook if there are no constructors. 2017-10-02 14:04:50 -06:00
Bruno Herrera
24767a0c66 Fixes for problems found by Coverity in the nuttx repository:
net/socket/recvfrom.c: Check fromlen integrity before using it.

    net/socket/net_sockets.c: Always check for valid psock before using.

    net/tcp/tcp_send_unbuffered.c:  Avoid using psock beforing checking its integrity.

    sched/timer/timer_create.c: Fix watchdog resource leak if cannot allocate a new timer.
2017-09-25 07:17:09 -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
Gregory Nutt
9eebd4b0f4 sched/waitpid.c: Eliminate a warning detected by GCC 6 2017-09-15 13:04:25 -06:00
Gregory Nutt
808238c871 Update some comments. 2017-09-11 14:27:02 -06:00
Gregory Nutt
7fbceacb46 Mark an untested driver as EXPERIMENTAL in its Kconfig; Update some comments. 2017-09-11 09:35:39 -06:00
Boris Astardzhiev
087a0cf2c7 waitpid(): Corrects two problems when CONFIG_SCHED_HAVE_PARENT+CONFIG_SCHED_CHILD_STATUS are enabled: (1) Was erroring out if the waited for task had already exited, and (2) was not freeing resources when a wait was completed. 2017-09-04 17:10:37 -06:00
Gregory Nutt
4993b0cb66 Work queue: In a recent change for a problem noted by Pascal Speck, it was noted (again by Pascal Speck) that the cancellation of existing work and replacement with new work must be atomic. Thanks, Pascal. 2017-08-31 07:43:47 -06:00
Gregory Nutt
92f44c5607 Networking: Move net/inet/net_monitor.c to net/tcp/tcp_monitor.c in preparation for design change to fix monitoring of duplicated sockets. 2017-08-29 08:40:13 -06:00
Gregory Nutt
bbf4d5048a work_queue() must cancel existing work prior to queuing new work, otherwise the work queue can become corrupted. Problem noted by Pascal Speck. 2017-08-28 07:46:48 -06:00
Arjun Hary
b274a97840 Miscellaneous fixes from astyle tool. 2017-08-14 17:19:27 -06:00
Gregory Nutt
6579078287 Eliminate another warning. 2017-08-12 11:24:11 -06:00
Gregory Nutt
baf4c0d011 Minor change to last PR: errno should not be modified if no error occurred. 2017-08-07 06:33:53 -06:00
Masayuki Ishikawa
4530a72379 sched/: Fix return value in sched_setaffinity() 2017-08-07 15:00:31 +09:00
Gregory Nutt
6b6d7ce9b9 sig_timedwait: Pending signal structure used after it has been releasd. From anonymous Bitbucket Issue 59. 2017-07-27 12:32:47 -06:00
Gregory Nutt
031fbfc6bc sched/: Remove dangling space at the end of lines. 2017-06-28 13:33:04 -06:00
Gregory Nutt
5e8037390c Fix problems in last commit noted by Jeongchan Kim: last change returned -EINVAL vs EINVAL; Treat the case where the mutex is already unlocked just like the case where the mutex is held by another thread -- return EPERM. 2017-06-22 06:26:00 -06:00
Gregory Nutt
0c3aef9591 Trivial typo fix 2017-06-21 06:48:13 -06:00
Gregory Nutt
6618336a39 pthread_mutex_unlock(): Missing check for the case where pthread_mutex_lock() is called when the mutex is not locked. In that case, it would increment the underlying semaphore avove 1. This is the fix for a problem noted by initialkjc@yahoo.com. 2017-06-21 06:40:09 -06:00
Gregory Nutt
2d4ba3ee3f IEEE 802.15.4 MAC: Add list management and prioritization logic that will permit the MAC layer to support bound multiple clients. 2017-06-18 11:00:47 -06:00
Gregory Nutt
2245dddaf9 Break up some long lines 2017-06-14 13:42:56 -06:00
Gregory Nutt
23a6ff5846 pthreads: Move pthread_barrier_init, pthread_barrier_destroy, and pthread_barrier_wait from sched/pthreads to libc/pthreads. This just coordinate other OS interface calls but are not a fundamental OS interfaces and, hence, do not belong within the OS. 2017-06-14 07:59:54 -06:00
Gregory Nutt
ae168bffa0 pthreads: Move pthread_cond_init and pthread_cond_destory from sched/pthreads to libc/pthreads. This just coordinate other OS interface calls but are not a fundamental OS interfaces and, hence, do not belong within the OS. 2017-06-14 07:48:45 -06:00
Gregory Nutt
557fd6504f pthreads: Move pthread_once from sched/pthreads to libc/pthreads. pthread_once just coordinates other OS interface calls but is not a fundamental OS interface and, hence, does not belong within the OS. 2017-06-14 07:31:10 -06:00
Gregory Nutt
8ae5450268 pthreads: Move pthread_yield from sched/pthreads to libc/pthreads. it is a simple wrapper for sched_yield and does not belong within the OS. 2017-06-14 07:31:10 -06:00
Gregory Nutt
0fe9c2f3f9 pthread mutex: Remove bogus DEBUGASSERT. Problem noted by Jussi Kivilinna 2017-06-01 06:28:23 -06:00
Gregory Nutt
90dda9357e pthread robust mutexes: Fix memmory trashing problem: the main task may also use mutexes; need to check thread type before accessing pthread-specific mutex data structures. Problem noted by Jussi Kivilinna. 2017-05-31 10:55:37 -06:00
Gregory Nutt
a8708424c2 pthread_trylock: Fixes a problem in pthread_trylock() noted by initialkjc@yahoo.com. When CONFIG_PTHREAD_MUTEX_UNSAFE=y, the special return value EAGAIN was not being detected due to differences in reporting of returned values. 2017-05-29 07:05:06 -06:00
Gregory Nutt
0de294a586 Fix lots of occurrences of 'the the', 'the there', 'the these', 'the then', 'the they. 2017-05-11 13:35:56 -06:00
Gregory Nutt
ba12817f9c Upate some comments 2017-05-11 13:15:31 -06:00
EunBong Song
03bd3688bc pthread: Fix compilation error on pthread_cond_wait when CONFIG_CANCELLATION_POINTS and CONFIG_PTHREAD_MUTEX_UNSAFE are enabled. 2017-05-02 07:14:04 -06:00
Jussi Kivilinna
e835803166 yslog: use monotonic clock for timestamp when available 2017-04-26 10:38:15 -06:00
Gregory Nutt
d5207efb5a Be consistent... Use Name: consistent in function headers vs Function: 2017-04-21 16:33:14 -06:00
Jussi Kivilinna
33ddaa0b10 clock: add testing for 32-bit overflow of 64-bit system timer 2017-04-21 08:55:07 -06:00
Jussi Kivilinna
c57d49f420 clock: Add new type ssystime_t for relative 64-bit ticks, change ticks<->time conversion functions to use ssystime_t 2017-04-21 08:51:31 -06:00
Jussi Kivilinna
325ba1a803 clock: add clock_resynchronize and use subseconds RTC
Add clock_resynchronize for better synchronization of CLOCK_REALTIME and CLOCK_MONOTONIC to match RTC after resume from low-power state.

Add up_rtc_getdatetime_with_subseconds under CONFIG_ARCH_HAVE_RTC_SUBSECONDS to allow initializing (and resynchronizing) system clock with subseconds accuracy RTC.
2017-04-21 08:45:57 -06:00