From: darcagn <da...@us...> - 2024-04-26 22:42:01
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via b51c6aa33c13fa0b68f6485e06108bf19c53d812 (commit) via a1d833d6b5c9f98bf88a0711a135ccdc28083cff (commit) via a28cee7b7fd1be0bced87e4bf9561302d50ec888 (commit) via 91eaa0ccb0258865cab89baf93ad760900e6eeb3 (commit) via d179912c8550963494b03ecc57a897b0986fdf31 (commit) from 04c59b4b3ff9a5a0b42bd203a3603f609dded7f0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b51c6aa33c13fa0b68f6485e06108bf19c53d812 Merge: a1d833d6 a28cee7b Author: darcagn <da...@pr...> Date: Fri Apr 26 16:40:32 2024 -0600 Merge pull request #518 from KallistiOS/dc_chain_no_phobos Updated dc-chain for DLang + BETA m4-single support commit a1d833d6b5c9f98bf88a0711a135ccdc28083cff Author: Falco Girgis <gyr...@gm...> Date: Fri Apr 26 15:29:05 2024 -0500 Dynamically Modify Scheduler Frequency HZ at Runtime (#520) * Added ability to modify scheduler HZ at runtime - thd_set_hz(): sets the current scheduler frequency (1-1000 hz) - thd_get_hz(): gets the current scheduler frequency * Updated sysconf() return for _SC_CLK_TCK. commit a28cee7b7fd1be0bced87e4bf9561302d50ec888 Author: Falco Girgis <gyr...@gm...> Date: Fri Apr 26 15:26:32 2024 -0500 Update utils/dc-chain/config/config.mk.13.2.1-dev.sample Co-authored-by: Lawrence Sebald <ljs...@us...> commit 91eaa0ccb0258865cab89baf93ad760900e6eeb3 Author: Falco Girgis <gyr...@gm...> Date: Sun Apr 21 18:49:33 2024 -0500 Updated dc-chain changelog.txt. commit d179912c8550963494b03ecc57a897b0986fdf31 Author: Falco Girgis <gyr...@gm...> Date: Sat Apr 20 23:52:54 2024 -0500 Updated dc-chain for DLang + m4-single support - Added an option for D to the pass2 langauges list, with a note that dependencies must already have been installed. - Added --disable-libphobos flag to the pass2 script to prevent it from being built with D, but it's also gracefully ignored without D. - Added -m4-single to the default list of FP configurations to build WHILE STILL KEEPING a strict warning about early beta support for it. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + include/kos/thread.h | 25 +++++++++++++++++++ kernel/arch/dreamcast/include/arch/arch.h | 11 ++++++++- kernel/libc/posix/sysconf.c | 18 +++++++++++--- kernel/thread/thread.c | 26 ++++++++++++++++---- utils/dc-chain/config/config.mk.13.2.1-dev.sample | 29 +++++++++++++---------- utils/dc-chain/doc/changelog.txt | 3 +++ utils/dc-chain/scripts/gcc-pass2.mk | 1 + 8 files changed, 93 insertions(+), 21 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 0850517e..7a1706e0 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -221,6 +221,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Added new driver for the SH4's UBC + high-level breakpoint API [FG] - DC Add support for French AZERTY keyboards [PC] - DC Increased the resolution of pvr_stats_t from milli to nanoseconds [FG] +- *** Added support for modifying scheduler frequency at runtime [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/include/kos/thread.h b/include/kos/thread.h index 6c09dd5a..0649f0c1 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -3,6 +3,8 @@ include/kos/thread.h Copyright (C) 2000, 2001, 2002, 2003 Megan Potter Copyright (C) 2009, 2010, 2016 Lawrence Sebald + Copyright (C) 2023 Colton Pawielski + Copyright (C) 2023, 2024 Falco Girgis */ @@ -598,6 +600,29 @@ int thd_set_mode(int mode) __deprecated; */ int thd_get_mode(void) __deprecated; +/** \brief Set the scheduler's frequency. + + Sets the frequency of the scheduler interrupts in hertz. + + \param hertz The new frequency in hertz (1-1000) + + \retval 0 The frequency was updated successfully. + \retval -1 \p hertz is invalid. + + \sa thd_get_hz(), HZ +*/ +int thd_set_hz(unsigned int hertz); + +/** \brief Fetch the scheduler's current frequency. + + Queries the scheduler for its interrupt frequency in hertz. + + \return Scheduler frequency in hertz. + + \sa thd_set_hz(), HZ +*/ +unsigned thd_get_hz(void); + /** \brief Wait for a thread to exit. \relatesalso kthread_t diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h index e16b4eec..0562fc36 100644 --- a/kernel/arch/dreamcast/include/arch/arch.h +++ b/kernel/arch/dreamcast/include/arch/arch.h @@ -52,7 +52,16 @@ extern uint32 _arch_mem_top; /** \brief Base address of available physical pages. */ #define page_phys_base 0x8c010000 -/** \brief Number of timer ticks per second. */ +/** \brief Scheduler interrupt frequency + + Timer interrupt frequency for the KOS thread scheduler. + + \note + This value is what KOS uses initially upon startup, but it can be + reconfigured at run-time. + + \sa thd_get_hz(), thd_set_hz() +*/ #define HZ 100 /** \brief Default thread stack size. */ diff --git a/kernel/libc/posix/sysconf.c b/kernel/libc/posix/sysconf.c index 06eeed4e..59b7b200 100644 --- a/kernel/libc/posix/sysconf.c +++ b/kernel/libc/posix/sysconf.c @@ -1,30 +1,42 @@ /* KallistiOS ##version## sysconf.c - Copyright (C) 2023 Falco Girgis + Copyright (C) 2023, 2024 Falco Girgis */ #include <arch/arch.h> #include <kos/netcfg.h> #include <kos/fs.h> +#include <kos/thread.h> #include <malloc.h> #include <unistd.h> #include <errno.h> +#include <limits.h> +#include <stdint.h> long sysconf(int name) { switch(name) { case _SC_HOST_NAME_MAX: return sizeof ((netcfg_t *)NULL)->hostname; + case _SC_CHILD_MAX: + return 1; + case _SC_CLK_TCK: - return HZ; + return thd_get_hz(); case _SC_OPEN_MAX: return FD_SETSIZE; case _SC_PAGESIZE: return PAGESIZE; + + case _SC_SEM_NSEMS_MAX: + return UINT32_MAX; + + case _SC_SEM_VALUE_MAX: + return UINT32_MAX; case _SC_PHYS_PAGES: return page_count; @@ -35,7 +47,7 @@ long sysconf(int name) { case _SC_NPROCESSORS_CONF: case _SC_NPROCESSORS_ONLN: return 1; - + default: errno = EINVAL; return -1; diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c index 6addff22..37a1105e 100644 --- a/kernel/thread/thread.c +++ b/kernel/thread/thread.c @@ -3,6 +3,8 @@ kernel/thread/thread.c Copyright (C) 2000, 2001, 2002, 2003 Megan Potter Copyright (C) 2010, 2016 Lawrence Sebald + Copyright (C) 2023 Colton Pawielski + Copyright (C) 2023, 2024 Falco Girgis */ #include <stdlib.h> @@ -11,6 +13,7 @@ #include <malloc.h> #include <stdio.h> #include <stdlib.h> +#include <assert.h> #include <reent.h> #include <errno.h> #include <kos/thread.h> @@ -22,7 +25,6 @@ #include <arch/irq.h> #include <arch/timer.h> #include <arch/arch.h> -#include <assert.h> /* @@ -50,6 +52,9 @@ static inline size_t align_to(size_t address, size_t alignment) { /*****************************************************************************/ /* Thread scheduler data */ +/* Scheduler timer interrupt frequency (Hertz) */ +static unsigned int thd_sched_ms = 1000 / HZ; + /* Thread list. This includes all threads except dead ones. */ static struct ktlist thd_list; @@ -760,7 +765,7 @@ static void thd_timer_hnd(irq_context_t *context) { //printf("timer woke at %d\n", (uint32_t)now); thd_schedule(0, now); - timer_primary_wakeup(1000 / HZ); + timer_primary_wakeup(thd_sched_ms); } /*****************************************************************************/ @@ -940,6 +945,19 @@ int thd_get_mode(void) { return thd_mode; } +unsigned thd_get_hz(void) { + return 1000 / thd_sched_ms; +} + +int thd_set_hz(unsigned int hertz) { + if(!hertz || hertz > 1000) + return -1; + + thd_sched_ms = 1000 / hertz; + + return 0; +} + /* Delete a TLS key. Note that currently this doesn't prevent you from reusing the key after deletion. This seems ok, as the pthreads standard states that using the key after deletion results in "undefined behavior". @@ -1048,9 +1066,9 @@ int thd_init(void) { timer_primary_set_callback(thd_timer_hnd); /* Schedule our first wakeup */ - timer_primary_wakeup(1000 / HZ); + timer_primary_wakeup(thd_sched_ms); - dbglog(DBG_INFO, "thd: pre-emption enabled, HZ=%d\n", HZ); + dbglog(DBG_INFO, "thd: pre-emption enabled, HZ=%u\n", thd_get_hz()); return 0; } diff --git a/utils/dc-chain/config/config.mk.13.2.1-dev.sample b/utils/dc-chain/config/config.mk.13.2.1-dev.sample index 7576900c..6239c8cf 100644 --- a/utils/dc-chain/config/config.mk.13.2.1-dev.sample +++ b/utils/dc-chain/config/config.mk.13.2.1-dev.sample @@ -114,24 +114,27 @@ install_mode=install-strip # detected on some OS. makejobs=-j2 -# Languages (c|c++|objc|obj-c++) -# Set the languages to build for pass 2 of building gcc for sh-elf. The default -# here is to build C, C++, Objective C, and Objective C++. You may want to take -# out the latter two if you're not worried about them and/or you're short on -# hard drive space. +# Languages (c|c++|objc|obj-c++|d) +# Set the languages to build for sh-elf gcc compilation pass 2. The default is +# to build everything used by all KOS examples; however, only C is actually +# required for KOS itself. D may also be enabled optionally on POSIX platforms +# which have its external dependencies installed. pass2_languages=c,c++,objc,obj-c++ -# Floating point precision support (m4|m4-single|m4-single-only) +# Floating point precision support (m4-single-only|m4-single|m4) # Build support for various SH4 floating-point operation ABIs. KallistiOS only -# officially supports single-precision-only mode. Add m4 (double precision) or -# m4-single (single precision) to build experimental support for those ABIs. -precision_modes=m4-single-only -#precision_modes=m4,m4-single,m4-single-only - -# Default floating point mode (m4|m4-single|m4-single-only) +# officially supports single-precision-only mode (m4-single-only); however, +# experimental support for single-precision-default mode (m4-single) has just +# been added to allow for the use of full 64-bit doubles. You may also add m4 +# (double-precision-default) which hasn't been tested, or you can simply stick +# with m4-single-only to save disk space. +precision_modes=m4-single-only,m4-single +#precision_modes=m4-single-only,m4-single,m4 + +# Default floating point mode (m4-single-only|m4-single|m4) # Choose the default floating point precision ABI used when GCC is invoked. This # can be overridden by using passing -m4, -m4-single, or -m4-single-only to GCC. -# KallistiOS currently only supports m4-single-only, so that is the default. +# KOS currently only officially supports m4-single-only, so it is the default. default_precision=m4-single-only # GCC threading model (single|kos|posix*) diff --git a/utils/dc-chain/doc/changelog.txt b/utils/dc-chain/doc/changelog.txt index 5ba1e808..3d86f1f4 100644 --- a/utils/dc-chain/doc/changelog.txt +++ b/utils/dc-chain/doc/changelog.txt @@ -1,3 +1,6 @@ +2024-04-21: Added D to list of supported languages, added m4-single as a + default precision mode, added --disable-libphobos to gcc-pass2 + (Falco Girgis) 2024-01-14: Added config option for disabling native language support (NLS) in GCC. (Falco Girgis) 2024-01-06: Update documentations (Mickaël Cardoso) diff --git a/utils/dc-chain/scripts/gcc-pass2.mk b/utils/dc-chain/scripts/gcc-pass2.mk index 38a2abb9..74292f62 100644 --- a/utils/dc-chain/scripts/gcc-pass2.mk +++ b/utils/dc-chain/scripts/gcc-pass2.mk @@ -18,6 +18,7 @@ $(build_gcc_pass2): logdir --with-gnu-ld \ --with-newlib \ --disable-libssp \ + --disable-libphobos \ --enable-threads=$(thread_model) \ --enable-languages=$(pass2_languages) \ --enable-checking=release \ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |