Commit Graph

173 Commits

Author SHA1 Message Date
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
Arjun Hary
b274a97840 Miscellaneous fixes from astyle tool. 2017-08-14 17:19:27 -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
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
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
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
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
b07d3fc305 Rename CONFIG_MUTEX_TYPES to CONFIG_PTHREAD_MUTEX_TYPES 2017-03-27 09:08:14 -06:00
Gregory Nutt
f2f798cb29 pthread mutexes: Finish logic to support configuration mutex robustness. 2017-03-27 08:50:45 -06:00
Gregory Nutt
666208cf23 pthread mutexes: Add option to support both unsafe and robust mutexes via pthread_mutexattr_get/setrobust(). 2017-03-26 18:37:24 -06:00
Gregory Nutt
8b3c554e45 pthreads: Add a configuration option to disable robust mutexes and revert to the traditional unsafe mutexes. 2017-03-26 17:37:28 -06:00
Gregory Nutt
86ab384d77 Forget to add some files in previous commits 2017-03-26 15:46:19 -06:00
Gregory Nutt
8b23c16b90 pthreads: pthread_mutex_consistent() needs to clear flags. 2017-03-26 14:44:57 -06:00
Gregory Nutt
34c5e1c18f Minor cleanup from recent changes. 2017-03-26 14:04:07 -06:00
Gregory Nutt
5a69453e16 pthreads: Add some assertions. 2017-03-26 13:54:43 -06:00
Gregory Nutt
fe03ef02c4 when pthread exits or is cancelled, mutexes held by thread are marked inconsistent and the highest priority thread waiting for the mutex is awakened. 2017-03-26 13:37:05 -06:00
Gregory Nutt
6e623ce06f pthreads: Partial implementation of final part of robust mutexes: Keep list of all mutexes held by a thread in a list in the TCB. 2017-03-26 12:46:57 -06:00
Gregory Nutt
2c37d369ab pthread: Fix return value of pthread_give/takesemaphore(). Add option to pthread_takesemaphore to ignore EINTR or not. 2017-03-26 11:22:17 -06:00
Gregory Nutt
363403fb1f pthreads: Add more robustness characteristics: pthread_mutex_lock() and trylock() will now return EOWNERDEAD if the mutex is locked by a thread that no longer exists. Add pthread_mutex_consistent() to recover from this situation. 2017-03-26 10:35:23 -06:00
Gregory Nutt
5fb85451cb Update some comments 2017-03-22 08:08:43 -06:00
Gregory Nutt
4dbc0a27c6 pthread_create: g_pthreadname[] is not used if CONFIG_TASK_NAME_SIZE==0. 2017-02-26 18:15:16 -06:00
Gregory Nutt
cb7c5f9921 Implement strings.h macros as inline functions when possible for better C++ compatibility. 2017-02-22 10:20:58 -06:00
Gregory Nutt
d5b1ca14e2 Update README and some comments. 2017-01-02 13:54:07 -06:00
Gregory Nutt
d648f9c8b4 Add task_testcancel() 2016-12-10 16:34:14 -06:00
Gregory Nutt
f132960789 Add task_setcanceltype() 2016-12-10 16:06:14 -06:00
Gregory Nutt
5fb207eb36 Add task_setcancelstate() 2016-12-10 15:16:46 -06:00
Gregory Nutt
698597a838 task_delete() now obeys all cancellation point semantics. 2016-12-10 14:39:19 -06:00
Gregory Nutt
b52e4e5ecd Move cancellation point definitions to their own header file. 2016-12-10 09:08:26 -06:00
Gregory Nutt
bc3ca25cc7 Cancellation points: Close up some logic to eliminte some race conditions. 2016-12-10 08:36:58 -06:00
Gregory Nutt
e62b3bccd3 pthread_setcanceltype() and pthread_testcancel() do not have to be system calls if cancellation points are not enabled. 2016-12-10 07:40:48 -06:00
Gregory Nutt
a0f567f4a3 Update TODO, cosmetic changes, spelling -- US English spells it canceled and canceling vs cancelled and cancelling. No idea why. 2016-12-09 18:39:40 -06:00
Gregory Nutt
a76e729b0d Trivial, cosmetic 2016-12-09 17:27:57 -06:00
Gregory Nutt
78cdc9f113 Fix a typo in a debug assertion. 2016-12-09 16:59:10 -06:00
Gregory Nutt
7ee0862e67 Merge remote-tracking branch 'origin/master' into cancelpt 2016-12-09 16:54:15 -06:00
Gregory Nutt
b07964461e pthread_mutex_destroy(): Fix an error in destorynig a mutex which can occur after a pthread has been canceled while holding the mutex. 2016-12-09 16:53:29 -06:00
Gregory Nutt
7fce8022c6 Finishes all cancellation point logic 2016-12-09 16:50:34 -06:00
Gregory Nutt
d8783a7345 Update Documentation 2016-12-09 14:41:54 -06:00
Gregory Nutt
c9ca97b4b5 cancellation points are basically function. More tested is needed and additional cancellation points must be implemented before this can be merged back to master. 2016-12-09 12:01:18 -06:00
Gregory Nutt
018db84567 Flesh out more cancellation point logic. 2016-12-09 10:31:40 -06:00
Gregory Nutt
d35e589d56 Flesh basic cancellation point support 2016-12-09 09:44:23 -06:00
Gregory Nutt
82a79b9c1b Add framework for cancellation point support. 2016-12-09 08:13:28 -06:00
Gregory Nutt
acaae12e8b Add pthread_testcancel(), pthread_testcancel(), and definitiions for cancellation types. 2016-12-09 07:23:00 -06:00
Gregory Nutt
6224e47533 pthread cleanup stack: Replace critical section with sched_lock/unlock(). The cleanup stack modification only needs to have the TCB stationary. The stack is never modified from interrupt level logic 2016-12-08 14:33:02 -06:00
Gregory Nutt
ab43681f15 Update TODO and some comments. 2016-12-08 10:24:40 -06:00
Gregory Nutt
a1fbc2ad0d pthreads: Add pthread_cleanup_push() and pthread_cleanup_pop() 2016-12-08 09:27:13 -06:00
Gregory Nutt
796969f6b6 Update TODO. Provide do-nothing stubs for mutex attribute interfaces if features not enabled. pthread_cond includes a signaling semaphore and should call sem_setprotocol. 2016-11-05 11:06:52 -06:00
Gregory Nutt
0d5bd30943 Fix a type in include file name 2016-11-03 12:58:02 -06:00
Gregory Nutt
1da3a5fa61 sched: Disable priority inheritance on all semaphores used for signaling 2016-11-03 12:42:02 -06:00
Gregory Nutt
d5b4d848d3 Move protoypes for the non-standard include/semaphore.h file to the non-standard include/nuttx/semaphore.h with the other non-standard semaphore interfaces. 2016-11-02 14:43:03 -06:00
Gregory Nutt
92d3022411 Add pthread_mutexattr_get/set_protocol and non-standard sem_get/set_protocol. These may use to enable or disable priority inheritance on a single semaphore. 2016-11-02 09:05:18 -06:00
Gregory Nutt
8669183852 sched/pthread and task: When a pthread is started, there is a small bit of logic that will run on the thread of execution of the new pthread. In the case where the new pthread has a lower priority than the parent thread, then this could cause both the parent thread and the new pthread to be blocked at the priority of the lower priority pthread (assuming that CONFIG_PRIORITY_INHERITANCE is not selected).
This change temporarily boosts the priority of the new pthread to at least the priority of the new pthread to at least the priority of the parent thread.  When that bit of logic has executed on the thread of execution of the new pthread, it will then drop to the correct priority (if necessary) before calling into the new pthread's entry point.
2016-10-01 11:38:22 -06:00
Gregory Nutt
18ce4ff57b sched/: Review and correct some stylistic inconsistencies 2016-08-07 08:25:30 -06:00
Gregory Nutt
830af912a1 Add sig_raise() 2016-07-04 09:32:36 -06:00
Gregory Nutt
f3ec664f63 Debug output level (error, warning, info) is now selectable on a per-subsystem, per-driver basis 2016-06-12 13:08:23 -06:00
Gregory Nutt
13cac3b592 sched/: Change some *err() message to *info() messages if what was a *dbg() message does not indicate and error condition. 2016-06-11 16:42:42 -06:00
Gregory Nutt
a1469a3e95 Add CONFIG_DEBUG_ERROR. Change names of *dbg() * *err() 2016-06-11 15:50:49 -06:00
Gregory Nutt
fc3540cffe Replace all occurrences of vdbg with vinfo 2016-06-11 11:59:51 -06:00
Gregory Nutt
143d287f11 Fix some missing header file inclusions and a misplaced semi-colon from recent commits 2016-02-21 11:27:55 -06:00
Gregory Nutt
5a590e99b9 Add SYSCALLS for pthread_setaffinity() and pthread_getaffinity() 2016-02-19 18:13:06 -06:00
Gregory Nutt
1b5e296cf2 Add pthread_setaffinity() and pthread_getaffinity() 2016-02-19 17:59:19 -06:00
Gregory Nutt
a633353ec3 Add a CPU affinity set to the TCB if SMP is enable and use this CPU set as a mask for determining which CPUs the thread may run on. Add an affinity field to the attrributes to permit controlling which CPUs a pthread may run on. Implements pthread_att_setaffinity_np() and pthread_attr_getaffinity_np(). 2016-02-19 17:33:35 -06:00
Gregory Nutt
3994b094c5 Remove some empty C file section comments; Update some text in TODO file 2016-02-19 10:01:15 -06:00
Gregory Nutt
6e3107650d nuttx/sched: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section() 2016-02-14 08:17:46 -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
48da5aa496 sched/pthread/: CRITICAL BUGFIX: Logic was wiping out the indication that of the type of a pthread. Hence, it could be confused as a task. Found because this was causing a crash when /proc/nnn/cmdline was printed. 2015-11-28 10:05:36 -06:00
Gregory Nutt
78ae661223 One more trivial spacing issue 2015-10-07 20:13:49 -06:00
Gregory Nutt
79d554939e sched/: Fix some spacing issues 2015-10-07 19:59:14 -06:00
Gregory Nutt
16b32bbadd Standardize the width of all comment boxes in C files 2015-10-03 07:25:53 -06:00
Gregory Nutt
5b51a9fcdd Standardize the width of all comment boxes in C files 2015-10-02 17:43:18 -06:00
Gregory Nutt
cb9e27c3b0 Standardize naming used for public data and function groupings 2015-10-02 16:30:35 -06:00
Gregory Nutt
768d892188 Add si_errno to siginfo_t 2015-08-14 10:10:32 -06:00
Anton D. Kachalov
4a16bc6924 [sched/pthread/pthread_kill] Add missed header for enabled CONFIG_SCHED_HAVE_PARENT
Signed-off-by: Anton D. Kachalov <mouse@yandex-team.ru>
2015-07-30 18:51:37 +03:00
Gregory Nutt
27e21710fd This is basically a complete redesign of the sporadic scheduling logic due to limitations in the initial design 2015-07-25 12:50:53 -06:00
Gregory Nutt
a1031417e8 Comment out part of sporadic scheduler logic: Part of replenishment logic is bogus 2015-07-24 18:18:58 -06:00
Gregory Nutt
ea7dbc984b Add basic sporadic schedule state machine 2015-07-24 09:03:21 -06:00
Gregory Nutt
3b1306078b Sporadic Scheduler: Ensure that the replenishment period is greater than or equal to the budget period 2015-07-23 15:08:41 -06:00
Gregory Nutt
5baa738019 Most cosmetic, but includes some fixes to some range checking 2015-07-23 14:36:49 -06:00
Gregory Nutt
9095e8eab4 include/, sched/, and libc/: Add support for sporadic scheduling parameters in struct sched_param, posix_spawnattr_t, and pthread_attr_t. Update all user interfaces to pass sporadic scheduling parameters. Feature is dependent on EXPERIMENTAL and no changes have yet been made to core scheduling logic. 2015-07-23 13:16:32 -06:00
Gregory Nutt
aa90da2bc8 pthread_create: Fix an (unlikely) error in fallback value in the event of a failure (which should never occur) 2015-07-23 11:25:25 -06:00
Gregory Nutt
146bdc3c93 TCB: Increase the size of the scheduling policy field from 1 to 2 bits to allow additional, planned scheduling policies 2015-07-23 10:15:07 -06:00
Jussi Kivilinna
13d9383679 Group binding needs to be cleared before sched_releasetcb(), as otherwise group_leave() will be called and group->tg_nmembers decremented or group being released. group_leave() should be called only after group_join() is called, not after group_bind(). From Jussi Kivilinna. 2015-07-01 06:24:34 -06:00
Juha Niskanen
e1846dff82 sched/pthread: Implement pthread_mutex_trylock() for recursive mutexes 2015-06-16 08:32:20 -06:00
Juha Niskanen
d16053c33c sched/pthread: Use -1 instead of 0 as PID for unclaimed mutexes 2015-06-16 08:27:38 -06:00
Gregory Nutt
cc77a28f40 If HAVE_GROUP_MEMBERS is not defined, then pthread_kill() really is the same as kill() 2015-05-13 20:34:21 -06:00