summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src (follow)
Commit message (Collapse)AuthorAgeFilesLines
* score: Simplify _Objects_Name_to_string()Sebastian Huber2018-06-051-2/+12
| | | | | Do not use isprint() from <ctype.h> since it depends on the heavy weight C locale implementation in Newlib.
* mpci: Fix _MPCI_Enqueue_callout()Sebastian Huber2018-03-221-1/+2
| | | | | Update #3117. Update #3182.
* mpci: Update due to thread queue API changesSebastian Huber2018-03-221-6/+7
| | | | | Update #3117. Update #3182.
* Use _Thread_Dispatch_direct()Sebastian Huber2018-02-081-2/+2
| | | | | | | Use _Thread_Dispatch_direct() for operations that block the executing thread. This ensures that we get a fatal error (INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL) if we try to block in an invalid context, e.g. during system start or an interrupt handler.
* Add RTEMS thread APISebastian Huber2018-02-021-3/+96
| | | | Update #2843.
* score: Introduce new monotonic clockSebastian Huber2018-02-022-78/+66
| | | | | | | | Rename PER_CPU_WATCHDOG_MONOTONIC to PER_CPU_WATCHDOG_TICKS. Add new PER_CPU_WATCHDOG_MONOTONIC which is based on the system uptime (measured by timecounter). Close #3264.
* score: Rename _Watchdog_Realtime_from_*()Sebastian Huber2018-02-023-4/+4
| | | | | | Rename _Watchdog_Realtime_from_*() to _Watchdog_Ticks_from_*(). Update #3264.
* score: Optimize watchdog tickleSebastian Huber2018-02-022-34/+65
| | | | | | | Avoid unnecessary lock acquire/release operations. Get realtime via timecounter only if necessary. Update #3264.
* score: Use self-contained API mutexSebastian Huber2017-12-0415-143/+89
| | | | | | | | | | Use a self-contained recursive mutex for API_Mutex_Control. The API mutexes are protected against asynchronous thread cancellation. Add dedicated mutexes for libatomic and TOD. Close #2629. Close #2630.
* score: Simplify global constructionSebastian Huber2017-11-222-63/+46
| | | | Update #3243.
* score: Optimize scheduler priority updatesSebastian Huber2017-11-2016-628/+276
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thread priority changes may append or prepend the thread to its priority group on the scheduler ready queue. Previously, a separate priority value and a prepend-it flag in the scheduler node were used to propagate a priority change to the scheduler. Now, use an append-it bit in the priority control and reduce the plain priority value to 63 bits. This change leads to a significant code size reduction (about 25%) of the SMP schedulers. The negligible increase of the standard priority scheduler is due to some additional shift operations (SCHEDULER_PRIORITY_MAP() and SCHEDULER_PRIORITY_UNMAP()). Before: text filename 136 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleblock.o 464 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimplechangepriority.o 24 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimple.o 108 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleschedule.o 292 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleunblock.o 264 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleyield.o text filename 280 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityblock.o 488 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerprioritychangepriority.o 200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriority.o 164 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityschedule.o 328 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityunblock.o 200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityyield.o text filename 24112 arm-rtems5/c/imx7/cpukit/score/src/libscore_a-scheduleredfsmp.o text filename 37204 sparc-rtems5/c/gr740/cpukit/score/src/libscore_a-scheduleredfsmp.o text filename 42236 powerpc-rtems5/c/qoriq_e6500_32/cpukit/score/src/libscore_a-scheduleredfsmp.o After: text filename 136 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleblock.o 272 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimplechangepriority.o 24 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimple.o 108 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleschedule.o 292 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleunblock.o 264 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleyield.o text filename 280 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityblock.o 488 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerprioritychangepriority.o 208 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriority.o 164 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityschedule.o 332 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityunblock.o 200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityyield.o text filename 18860 arm-rtems5/c/imx7/cpukit/score/src/libscore_a-scheduleredfsmp.o text filename 28520 sparc-rtems5/c/gr740/cpukit/score/src/libscore_a-scheduleredfsmp.o text filename 32664 powerpc-rtems5/c/qoriq_e6500_32/cpukit/score/src/libscore_a-scheduleredfsmp.o
* score: Adjust _Scheduler_EDF_SMP_Insert_ready()Sebastian Huber2017-11-171-6/+4
| | | | | Use only one parameter to compute the next generation. Use index 0 for LIFO ordering, and index 1 for FIFO ordering.
* score: Fix priority ceiling updatesSebastian Huber2017-11-162-1/+8
| | | | | | | | | | | | We must not clear the priority updates in _Thread_queue_Extract_locked() since this function is used by the priority ceiling surrender operations after the ceiling priority handover from the previous owner to the new owner. This is especially important in SMP configurations. Move the _Thread_queue_Context_clear_priority_updates() invocation to the callers. Close #3237.
* score: Fix _Thread_queue_Flush_critical()Sebastian Huber2017-11-161-4/+14
| | | | | | | | | The thread queue extract operations performed by the _Thread_queue_Flush_critical() may result in a priority change of the thread queue owner. Carry out the scheduler priority update operation. This is especially important in SMP configurations. Close #3236.
* score: Change _Timecounter_Time_uptime to int32_tSebastian Huber2017-11-091-1/+2
| | | | | | | Move basic timecounter API shared with BSD network stack to <machine/_timecounter.h>. Update #3185.
* score: Use Processor_mask instead of cpu_set_tSebastian Huber2017-11-061-11/+5
|
* score: _Chain_Insert_ordered_unprotected()Sebastian Huber2017-11-064-19/+48
| | | | | | Change the chain order relation to use a directly specified left hand side value. This is similar to _RBTree_Insert_inline() and helps the compiler to better optimize the code.
* score: Add _IO_Printf() and _IO_Vprintf()Sebastian Huber2017-11-062-0/+396
| | | | | | | | | | | | | | The previous vprintk() implementation had a questionable licence header, lacks support for the 'z' and 'j' format specifiers, is not robust against invalid format specifiers, uses a global variable for output. Replace it with a stripped down version of the FreeBSD kernel kvprintf() function. The new implementation allows a low overhead rtems_snprintf() if necessary. Update #3199. Close #3216.
* score: Fix non-SMP buildSebastian Huber2017-10-291-1/+1
|
* score: Fix _Scheduler_Set_affinity()Sebastian Huber2017-10-282-5/+11
|
* score: Simplify SMP get lowest scheduledSebastian Huber2017-10-282-21/+14
| | | | | | There is no need to pass in the order relation since the scheduled threads reside on an already ordered chain. The caller will decide what to do with the lowest scheduled thread.
* score: Move thread queue timeout handlingSebastian Huber2017-10-2415-206/+227
| | | | | Update #3117. Update #3182.
* score: Rename function threadq support functionSebastian Huber2017-10-2410-10/+10
| | | | | | | | | Rename _Thread_queue_Context_set_do_nothing_enqueue_callout() into _Thread_queue_Context_set_enqueue_do_nothing_extra(). More _Thread_queue_Context_set_enqueue_*() functions will follow. Update #3117. Update #3182.
* score: Add _Thread_Continue()Sebastian Huber2017-10-241-8/+17
| | | | | Update #3117. Update #3182.
* score: Rename _Watchdog_Ticks_from_*()Sebastian Huber2017-10-242-2/+2
| | | | | | | | | | Rename _Watchdog_Ticks_from_*() to _Watchdog_Realtime_from_*(). This highlights that these routines are used for the CLOCK_REALTIME watchdogs (in contrast to CLOCK_MONOTONIC). Update #3117. Update #3182.
* score: Add _Thread_Add_timeout_ticks()Sebastian Huber2017-10-241-2/+1
| | | | | | | | Replace _Thread_Timer_insert_monotonic() with _Thread_Add_timeout_ticks(). Update #3117. Update #3182.
* score: Fix warningSebastian Huber2017-10-211-1/+1
|
* score: Rename watchdog variantsSebastian Huber2017-10-173-5/+5
| | | | | | | | | | | Rename PER_CPU_WATCHDOG_RELATIVE in PER_CPU_WATCHDOG_MONOTONIC to highlight the corresponding POSIX CLOCK_MONOTONIC. Rename PER_CPU_WATCHDOG_ABSOLUTE in PER_CPU_WATCHDOG_REALTIME to highlight the corresponding POSIX CLOCK_REALTIME. Update #3117. Update #3182.
* timecounter: Update FreeBSD identifiersSebastian Huber2017-10-121-1/+1
| | | | Update #3175.
* timecounter: Merge FreeBSD change r324528Konstantin Belousov2017-10-121-3/+1
| | | | | | | | | | | | The th_bintime, th_microtime and th_nanotime members of the timehand all cache the last system time (uptime + boottime). Only the format differs. Do not re-calculate the bintime and simply use the value used to calculate the microtime and nanotime. Group all the updates under the relevant comment. Remove obsoleted XXX part. Submitted by: Sebastian Huber <sebastian.huber@embedded-brains.de> MFC after: 1 week Update #3175.
* timecounter: Merge FreeBSD change r315287Eric van Gyzen2017-10-121-0/+10
| | | | | | | | | | | | | | | | | | Add missing pieces of r315280 I moved this branch from github to a private server, and pulled from the wrong one when committing r315280, so I failed to include two recent commits. Thankfully, they were only cosmetic and were included in the review. Specifically: Add documentation, polish comments, and improve style(9). Tested by: pho (r315280) MFC after: 2 weeks Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D9791 Update #3175.
* timecounter: Merge FreeBSD change r315280Eric van Gyzen2017-10-121-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the RTC is adjusted, reevaluate absolute sleep times based on the RTC POSIX 2008 says this about clock_settime(2): If the value of the CLOCK_REALTIME clock is set via clock_settime(), the new value of the clock shall be used to determine the time of expiration for absolute time services based upon the CLOCK_REALTIME clock. This applies to the time at which armed absolute timers expire. If the absolute time requested at the invocation of such a time service is before the new value of the clock, the time service shall expire immediately as if the clock had reached the requested time normally. Setting the value of the CLOCK_REALTIME clock via clock_settime() shall have no effect on threads that are blocked waiting for a relative time service based upon this clock, including the nanosleep() function; nor on the expiration of relative timers based upon this clock. Consequently, these time services shall expire when the requested relative interval elapses, independently of the new or old value of the clock. When the real-time clock is adjusted, such as by clock_settime(3), wake any threads sleeping until an absolute real-clock time. Such a sleep is indicated by a non-zero td_rtcgen. The sleep functions will set that field to zero and return zero to tell the caller to reevaluate its sleep duration based on the new value of the clock. At present, this affects the following functions: pthread_cond_timedwait(3) pthread_mutex_timedlock(3) pthread_rwlock_timedrdlock(3) pthread_rwlock_timedwrlock(3) sem_timedwait(3) sem_clockwait_np(3) I'm working on adding clock_nanosleep(2), which will also be affected. Reported by: Sebastian Huber <sebastian.huber@embedded-brains.de> Reviewed by: jhb, kib MFC after: 2 weeks Relnotes: yes Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D9791 Update #3175.
* timecounter: Merge FreeBSD change r310053Ed Schouten2017-10-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | Add labels to sysctls related to clocks. Sysctls like kern.eventtimer.et.*.quality currently embed the name of the clock device. This is problematic for the Prometheus metrics exporter for two reasons: - Some of those clocks have dashes in their names, which Prometheus doesn't allow to be used in metric names. - It doesn't allow for extracting the same property of all clocks on the system from within a single query. Attach these nodes to have a label, so that the Prometheus metrics exporter gives these metric a uniform name with the name of the clock attached as a label. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D8775 Update #3175.
* timecounter: Merge FreeBSD change r304285Konstantin Belousov2017-10-121-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement userspace gettimeofday(2) with HPET timecounter. Right now, userspace (fast) gettimeofday(2) on x86 only works for RDTSC. For older machines, like Core2, where RDTSC is not C2/C3 invariant, and which fall to HPET hardware, this means that the call has both the penalty of the syscall and of the uncached hw behind the QPI or PCIe connection to the sought bridge. Nothing can me done against the access latency, but the syscall overhead can be removed. System already provides mappable /dev/hpetX devices, which gives straight access to the HPET registers page. Add yet another algorithm to the x86 'vdso' timehands. Libc is updated to handle both RDTSC and HPET. For HPET, the index of the hpet device to mmap is passed from kernel to userspace, index might be changed and libc invalidates its mapping as needed. Remove cpu_fill_vdso_timehands() KPI, instead require that timecounters which can be used from userspace, to provide tc_fill_vdso_timehands{,32}() methods. Merge i386 and amd64 libc/<arch>/sys/__vdso_gettc.c into one source file in the new libc/x86/sys location. __vdso_gettc() internal interface is changed to move timecounter algorithm detection into the MD code. Measurements show that RDTSC even with the syscall overhead is faster than userspace HPET access. But still, userspace HPET is three-four times faster than syscall HPET on several Core2 and SandyBridge machines. Tested by: Howard Su <howard0su@gmail.com> Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential revision: https://reviews.freebsd.org/D7473 Update #3175.
* timecounter: Merge FreeBSD change r303548Konstantin Belousov2017-10-121-13/+11
| | | | | | | | | | Cache getbintime(9) answer in timehands, similarly to getnanotime(9) and getmicrotime(9). Suggested and reviewed by: bde (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 month Update #3175.
* timecounter: Merge FreeBSD change r303387Konstantin Belousov2017-10-121-46/+74
| | | | | | | | | | | | | | | | | | | Prevent parallel tc_windup() calls, both parallel top-level calls from setclock() and from simultaneous top-level and interrupt. For this, tc_windup() is protected with a tc_setclock_mtx spinlock, in the try mode when called from hardclock interrupt. If spinlock cannot be obtained without spinning from the interrupt context, this means that top-level executes tc_windup() on other core and our try may be avoided. The boottimebin and boottime variables should be adjusted from tc_windup(). To be correct, they must be part of the timehands and read using lockless protocol. Remove the globals and reimplement the getboottime(9)/getboottimebin(9) KPI using the timehands read protocol. Tested by: pho (as part of the whole patch) Reviewed by: jhb (same) Discussed wit: bde Sponsored by: The FreeBSD Foundation MFC after: 1 month X-Differential revision: https://reviews.freebsd.org/D7302 Update #3175.
* timecounter: Merge FreeBSD change r303384Konstantin Belousov2017-10-121-2/+2
| | | | | | | | | | Style. Sponsored by: The FreeBSD Foundation MFC after: 1 month X-Differential revision: https://reviews.freebsd.org/D7302 Update #3175.
* timecounter: Merge FreeBSD change r303383Konstantin Belousov2017-10-121-23/+12
| | | | | | | | | | | | | | | Reduce number of timehands to just two. This is useful because consumers can now be only one tc_windup() call late. Use C99 initialization. Tested by: pho (as part of the whole patch) Reviewed by: jhb (same) Discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 1 month X-Differential revision: https://reviews.freebsd.org/D7302 Update #3175.
* timecounter: Merge FreeBSD change r303382Konstantin Belousov2017-10-121-23/+45
| | | | | | | | | | | | | | | | | | | | | | Hide the boottime and bootimebin globals, provide the getboottime(9) and getboottimebin(9) KPI. Change consumers of boottime to use the KPI. The variables were renamed to avoid shadowing issues with local variables of the same name. Issue is that boottime* should be adjusted from tc_windup(), which requires them to be members of the timehands structure. As a preparation, this commit only introduces the interface. Some uses of boottime were found doubtful, e.g. NLM uses boottime to identify the system boot instance. Arguably the identity should not change on the leap second adjustment, but the commit is about the timekeeping code and the consumers were kept bug-to-bug compatible. Tested by: pho (as part of the bigger patch) Reviewed by: jhb (same) Discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 1 month X-Differential revision: https://reviews.freebsd.org/D7302 Update #3175.
* timecounter: Merge FreeBSD change r298819Pedro Giffuni2017-10-121-1/+1
| | | | | | | | sys/kern: spelling fixes in comments. No functional change. Update #3175.
* timecounter: Merge FreeBSD change r290257Ngie Cooper2017-10-121-1/+8
| | | | | | | | | Define `fhard` in pps_event(..) only when PPS_SYNC is defined to mute an -Wunused-but-set-variable warning Reported by: FreeBSD_HEAD_amd64_gcc4.9 jenkins job Sponsored by: EMC / Isilon Storage Division Update #3175.
* timecounter: Merge FreeBSD change r288216Konstantin Belousov2017-10-121-7/+14
| | | | | | | | | | | | | | Use per-cpu values for base and last in tc_cpu_ticks(). The values are updated lockess, different CPUs write its own view of timecounter state. The critical section is done for safety, callers of tc_cpu_ticks() are supposed to already enter critical section, or to own a spinlock. The change fixes sporadical reports of too high values reported for the (W)CPU on platforms that do not provide cpu ticker and use tc_cpu_ticks(), in particular, arm*. Diagnosed and reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Update #3175.
* timecounter: Merge FreeBSD change r286701Ian Lepore2017-10-121-5/+13
| | | | | | | | | If a specific timecounter has been chosen via sysctl, and a new timecounter with higher quality registers (presumably in a module that has just been loaded), do not undo the user's choice by switching to the new timecounter. Document that behavior, and also the fact that there is no way to unregister a timecounter (and thus no way to unload a module containing one). Update #3175.
* timecounter: Merge FreeBSD change r286429Ian Lepore2017-10-121-0/+3
| | | | | | | | | | | | Only process the PPS event types currently enabled in pps_params.mode. This makes the PPS API behave correctly, but isn't ideal -- we still end up capturing PPS data for non-enabled edges, we just don't process the data into an event that becomes visible outside of kern_tc. That's because the event type isn't passed to pps_capture(), so it can't do the filtering. Any solution for capture filtering is going to require touching every driver. Update #3175.
* timecounter: Merge FreeBSD change r286423Ian Lepore2017-10-121-2/+6
| | | | | | RFC 2783 requires a status of ETIMEDOUT, not EWOULDBLOCK, on a timeout. Update #3175.
* timecounter: Merge FreeBSD change r285286Konstantin Belousov2017-10-121-81/+101
| | | | | | | | | | | | | | | | | | | Reimplement the ordering requirements for the timehands updates, and for timehands consumers, by using fences. Ensure that the timehands->th_generation reset to zero is visible before the data update is visible [*]. tc_setget() allowed data update writes to become visible before generation (but not on TSO architectures). Remove tc_setgen(), tc_getgen() helpers, use atomics inline [**]. Noted by: alc [*] Requested by: bde [**] Reviewed by: alc, bde Sponsored by: The FreeBSD Foundation MFC after: 3 weeks Update #3175.
* timecounter: Merge FreeBSD change r284256Konstantin Belousov2017-10-121-3/+2
| | | | | | | | | | | | | | | | | Tweaks for r284178: Do not include machine/atomic.h explicitely, the header is already included by sys/systm.h. Force inlining of tc_getgen() and tc_setgen(). The functions are used more than once, which causes compilers with non-aggressive inlining policies to generate calls. Suggested by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Update #3175.
* timecounter: Merge FreeBSD change r282424Ian Lepore2017-10-121-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement a mechanism for making changes in the kernel<->driver PPS interface without breaking ABI or API compatibility with existing drivers. The existing data structures used to communicate between the kernel and driver portions of PPS processing contain no spare/padding fields and no flags field or other straightforward mechanism for communicating changes in the structures or behaviors of the code. This makes it difficult to MFC new features added to the PPS facility. ABI compatibility is important; out-of-tree drivers in module form are known to exist. (Note that the existing api_version field in the pps_params structure must contain the value mandated by RFC 2783 and any RFCs that come along after.) These changes introduce a pair of abi-version fields which are filled in by the driver and the kernel respectively to indicate the interface version. The driver sets its version field before calling the new pps_init_abi() function. That lets the kernel know how much of the pps_state structure is understood by the driver and it can avoid using newer fields at the end of the structure that it knows about if the driver is a lower version. The kernel fills in its version field during the init call, letting the driver know what features and data the kernel supports. To implement the new version information in a way that is backwards compatible with code from before these changes, the high bit of the lightly-used 'kcmode' field is repurposed as a flag bit that indicates the driver is aware of the abi versioning scheme. Basically if this bit is clear that indicates a "version 0" driver and if it is set the driver_abi field indicates the version. These changes also move the recently-added 'mtx' field of pps_state from the middle to the end of the structure, and make the kernel code that uses this field conditional on the driver being abi version 1 or higher. It changes the only driver currently supplying the mtx field, usb_serial, to use pps_init_abi(). Reviewed by: hselasky@ Update #3175.
* timecounter: Merge FreeBSD change r280012Ian Lepore2017-10-121-0/+1
| | | | | | Use sbuf_printf() for sysctl strings instead of stack buffers and snprintf(). Update #3175.
* timecounter: Merge FreeBSD change r279728Hans Petter Selasky2017-10-121-11/+3
| | | | | | | | | Add mutex support to the pps_ioctl() API in the kernel. Bump kernel version to reflect structure change. PR: 196897 MFC after: 1 week Update #3175.