Commit Graph

1160 Commits

Author SHA1 Message Date
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
Nobutaka Toyoshima 150036eb8b sched: Fix tg_flags check with GROUP_FLAG_NOCLDWAIT
Jira: PDFW15IS-208
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2017-04-14 14:50:44 +09:00
Juha Niskanen (Haltian) b4747286b1 Add logic to disable cancellation points within the OS. This is useful when an internal OS function that is NOT a cancellation point calls an OS function which is a cancellation point. In that case, irrecoverable states may occur if the cancellation is within the OS. 2017-04-11 11:03:25 -06:00
Gregory Nutt c08ba10d32 include/: Add some definitions needed by apps/wireless/wapi 2017-04-10 14:56:23 -06:00
Gregory Nutt c36bf090f0 pthread: Minor logic fix in pthread_mutex_consistent. Updat some comments. 2017-04-10 10:10:41 -06:00
Gregory Nutt 948332ca34 pthreads: Backed most of last pthread changes. Found the 'real' root poblem. A one like error in pthread_mutex.c. 2017-04-10 09:51:03 -06:00
Gregory Nutt b51b72b2db pthreads: Re-order some operations so that mutexes are placed in the inconsistent state BEFORE the clean-up callbacks are called. 2017-04-10 08:11:16 -06:00
Jussi Kivilinna dffb8a67e3 Add entropy pool and strong random number generator
Entropy pool gathers environmental noise from device drivers, user-space, etc., and returns good random numbers, suitable for cryptographic use. Based on entropy pool design from *BSDs and uses BLAKE2Xs algorithm for CSPRNG output.

Patch also adds /dev/urandom support for using entropy pool RNG and new 'getrandom' system call for getting randomness without file-descriptor usage (thus avoiding file-descriptor exhaustion attacks). The 'getrandom' interface is similar as 'getentropy' and 'getrandom' available on OpenBSD and Linux respectively.
2017-03-30 07:38:37 -06:00
Gregory Nutt eb344d7260 Fix an assertion noted by Jussi Kivilinna.
This was a consequence of the recent robust mutex changes.  If robust mutexes are selected, then each mutex that a thread takes is retained in a list in threads TCB.  If the thread exits and that list is not empty, then we know that the thread exitted while holding mutexes.  And, in that case, each will be marked as inconsistent and the any waiter for the thread is awakened.

For the case of pthread_mutex_trywait(), the mutex was not being added to the list!  while not usually a fatal error, this was caught by an assertion when pthread_mutex_unlock() was called:  It tried to remove the mutex from the TCB list and it was not there when, of course, it shoule be.

The fix was to add pthread_mutex_trytake() which does sem_trywait() and if successful, does correctly add the mutext to the TCB list.  This should eliminated the assertion.
2017-03-29 07:50:40 -06:00
Gregory Nutt 941360bf12 Correct some spacing 2017-03-27 10:49:41 -06:00