From: kosmirror <kos...@us...> - 2025-05-22 14:02:46
|
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 f643745ca6342e44612a115f7fe28b0a95435a6a (commit) from f4657b17a449c13502114404a53835c38de5c3a5 (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 f643745ca6342e44612a115f7fe28b0a95435a6a Author: darc <da...@pr...> Date: Wed May 21 16:27:14 2025 -0500 libpthread: Add support for pthread_getschedparam() and pthread_setschedparam() ----------------------------------------------------------------------- Summary of changes: addons/libpthread/Makefile | 3 ++- addons/libpthread/pthread_getschedparam.c | 31 +++++++++++++++++++++++++++++++ addons/libpthread/pthread_setschedparam.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 addons/libpthread/pthread_getschedparam.c create mode 100644 addons/libpthread/pthread_setschedparam.c diff --git a/addons/libpthread/Makefile b/addons/libpthread/Makefile index 54f2879a..a50f2c46 100644 --- a/addons/libpthread/Makefile +++ b/addons/libpthread/Makefile @@ -66,6 +66,7 @@ OBJS += pthread_barrierattr_init.o pthread_barrierattr_destroy.o \ # Misc. OBJS += pthread_atfork.o pthread_getsetconcurrency.o pthread_yield.o \ - pthread_setprio.o pthread_getprio.o + pthread_setprio.o pthread_getprio.o \ + pthread_setschedparam.o pthread_getschedparam.o include $(KOS_BASE)/addons/Makefile.prefab diff --git a/addons/libpthread/pthread_getschedparam.c b/addons/libpthread/pthread_getschedparam.c new file mode 100644 index 00000000..30da35a2 --- /dev/null +++ b/addons/libpthread/pthread_getschedparam.c @@ -0,0 +1,31 @@ +/* KallistiOS ##version## + + pthread_getschedparam.c + Copyright (C) 2025 Eric Fradella +*/ + +#include "pthread-internal.h" +#include <pthread.h> +#include <sched.h> +#include <errno.h> +#include <kos/thread.h> + +int pthread_getschedparam(pthread_t thread, int *__RESTRICT policy, + struct sched_param *__RESTRICT param) { + kthread_t *thd = (kthread_t *)thread; + + if(!thd) + return EINVAL; + + if(!policy) + return EINVAL; + + if(!param) + return EFAULT; + + *policy = SCHED_RR; + + param->sched_priority = (int)thd_get_prio(thd); + + return 0; +} diff --git a/addons/libpthread/pthread_setschedparam.c b/addons/libpthread/pthread_setschedparam.c new file mode 100644 index 00000000..4f5ae223 --- /dev/null +++ b/addons/libpthread/pthread_setschedparam.c @@ -0,0 +1,30 @@ +/* KallistiOS ##version## + + pthread_setschedparam.c + Copyright (C) 2025 Eric Fradella +*/ + +#include "pthread-internal.h" +#include <pthread.h> +#include <sched.h> +#include <errno.h> +#include <kos/thread.h> + +int pthread_setschedparam(pthread_t thread, int policy, + const struct sched_param *param) { + kthread_t *thd = (kthread_t *)thread; + + if(!thd) + return EINVAL; + + if(policy != SCHED_RR) + return EINVAL; + + if(!param) + return EFAULT; + + if(thd_set_prio(thd, (prio_t)param->sched_priority)) + return EINVAL; + + return 0; +} hooks/post-receive -- A pseudo Operating System for the Dreamcast. |