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.

This commit is contained in:
Gregory Nutt
2015-07-23 13:16:32 -06:00
parent 13e837b957
commit 9095e8eab4
22 changed files with 352 additions and 144 deletions
+21 -7
View File
@@ -51,13 +51,27 @@
/* Default pthread attribute initializer */
#define PTHREAD_ATTR_INITIALIZER \
{ \
PTHREAD_STACK_DEFAULT, /* stacksize */ \
PTHREAD_DEFAULT_PRIORITY, /* priority */ \
SCHED_RR, /* policy */ \
PTHREAD_EXPLICIT_SCHED, /* inheritsched */ \
}
#ifdef CONFIG_SCHED_SPORADIC
# define PTHREAD_ATTR_INITIALIZER \
{ \
PTHREAD_DEFAULT_PRIORITY, /* priority */ \
SCHED_RR, /* policy */ \
PTHREAD_EXPLICIT_SCHED, /* inheritsched */ \
0, /* low_priority */ \
0, /* max_repl */ \
PTHREAD_STACK_DEFAULT, /* stacksize */ \
{0, 0}, /* repl_period */ \
{0, 0}, /* budget */ \
}
#else
# define PTHREAD_ATTR_INITIALIZER \
{ \
PTHREAD_DEFAULT_PRIORITY, /* priority */ \
SCHED_RR, /* policy */ \
PTHREAD_EXPLICIT_SCHED, /* inheritsched */ \
PTHREAD_STACK_DEFAULT, /* stacksize */ \
}
#endif
/****************************************************************************
* Public Data
+3 -2
View File
@@ -485,7 +485,8 @@ struct tcb_s
uint8_t base_priority; /* "Normal" priority of the thread */
#endif
#ifdef CONFIG_SCHED_SPORADIC
int32_t low_priority; /* Sporadic low priority */
uint8_t low_priority; /* Sporadic low priority */
uint8_t max_repl; /* Max. replenishments */
#endif
uint8_t task_state; /* Current state of the thread */
@@ -498,7 +499,7 @@ struct tcb_s
#endif
#ifdef CONFIG_SCHED_SPORADIC
uint32_t spstart; /* Start time of execution budget */
uint32_t replen; /* Sporadic replenishment interval */
uint32_t repl_period; /* Sporadic replenishment period */
uint32_t budget; /* Sporadic execution budget */
#endif
+16 -5
View File
@@ -1,7 +1,7 @@
/********************************************************************************
* include/pthread.h
*
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011-2012, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -166,10 +166,21 @@ typedef pthread_startroutine_t pthread_func_t;
struct pthread_attr_s
{
size_t stacksize; /* Size of the stack allocated for the pthread */
int16_t priority; /* Priority of the pthread */
uint8_t policy; /* Pthread scheduler policy */
uint8_t inheritsched; /* Inherit parent prio/policy? */
uint8_t priority; /* Priority of the pthread */
uint8_t policy; /* Pthread scheduler policy */
uint8_t inheritsched; /* Inherit parent prio/policy? */
#ifdef CONFIG_SCHED_SPORADIC
uint8_t low_priority; /* Low scheduling priority*/
uint8_t max_repl; /* Maximum pending replenishments */
#endif
size_t stacksize; /* Size of the stack allocated for the pthread */
#ifdef CONFIG_SCHED_SPORADIC
struct timespec repl_period; /* Replenishment period */
struct timespec budget; /* Initial budget */
#endif
};
typedef struct pthread_attr_s pthread_attr_t;
+11 -2
View File
@@ -49,7 +49,6 @@
/********************************************************************************
* Pre-processor Definitions
********************************************************************************/
/* Task Management Definitions **************************************************/
/* POSIX-like scheduling policies */
@@ -71,7 +70,17 @@
struct sched_param
{
int sched_priority;
int sched_priority; /* Base thread priority */
#ifdef CONFIG_SCHED_SPORADIC
int sched_ss_low_priority; /* Low scheduling priority for sporadic
* server */
struct timespec sched_ss_repl_period; /* Replenishment period for sporadic
* server. */
struct timespec sched_ss_init_budget; /* Initial budget for sporadic server */
int sched_ss_max_repl; /* Maximum pending replenishments for
* sporadic server. */
#endif
};
/********************************************************************************
+14 -1
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* include/spawn.h
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -78,6 +78,7 @@
* because the user will be required to allocate this memory.
*/
struct timespec;
struct posix_spawnattr_s
{
/* Used by posix_spawn, posix_spawnp, and task_spawn */
@@ -85,6 +86,12 @@ struct posix_spawnattr_s
uint8_t flags; /* See POSIX_SPAWN_ definitions */
uint8_t priority; /* Task scheduling priority */
uint8_t policy; /* Task scheduling policy */
#ifdef CONFIG_SCHED_SPORADIC
uint8_t low_priority; /* Low scheduling priority*/
uint8_t max_repl; /* Maximum pending replenishments */
#endif
#ifndef CONFIG_DISABLE_SIGNALS
sigset_t sigmask; /* Signals to be masked */
#endif
@@ -94,6 +101,12 @@ struct posix_spawnattr_s
size_t stacksize; /* Task stack size */
#endif
#ifdef CONFIG_SCHED_SPORADIC
struct timespec repl_period; /* Replenishment period */
struct timespec budget; /* Initial budget */
#endif
};
typedef struct posix_spawnattr_s posix_spawnattr_t;
+35 -21
View File
@@ -68,31 +68,45 @@
/* POSIX feature set macros */
#define POSIX_VERSION
#undef _POSIX_SAVED_IDS
#undef _POSIX_JOB_CONTROL
#define _POSIX_REALTIME_SIGNALS 1
#define _POSIX_MESSAGE_PASSING 1
#undef _POSIX_MAPPED_FILES
#undef _POSIX_SHARED_MEMORY_OBJECTS
#define _POSIX_PRIORITY_SCHEDULING 1
#define _POSIX_TIMERS 1
#undef _POSIX_MEMLOCK
#undef _POSIX_MEMLOCK_RANGE
#undef _POSIX_FSYNC
#define _POSIX_SYNCHRONIZED_IO 1
#undef _POSIX_ASYNCHRONOUS_IO
#undef _POSIX_PRIORITIZED_IO
#define POSIX_VERSION
#undef _POSIX_SAVED_IDS
#undef _POSIX_JOB_CONTROL
#define _POSIX_REALTIME_SIGNALS 1
#define _POSIX_MESSAGE_PASSING 1
#undef _POSIX_MAPPED_FILES
#undef _POSIX_SHARED_MEMORY_OBJECTS
#define _POSIX_PRIORITY_SCHEDULING 1
#define _POSIX_TIMERS 1
#undef _POSIX_MEMLOCK
#undef _POSIX_MEMLOCK_RANGE
#undef _POSIX_FSYNC
#define _POSIX_SYNCHRONIZED_IO 1
#ifdef CONFIG_FS_AIO
# define _POSIX_ASYNCHRONOUS_IO 1
#else
# undef _POSIX_ASYNCHRONOUS_IO
#endif
#undef _POSIX_PRIORITIZED_IO
#ifdef CONFIG_SCHED_SPORADIC
# define _POSIX_SPORADIC_SERVER 1
# define _POSIX_THREAD_SPORADIC_SERVER 1
#else
# undef _POSIX_SPORADIC_SERVER
# undef _POSIX_THREAD_SPORADIC_SERVER
#endif
/* Execution time constants (not supported) */
#undef _POSIX_CHOWN_RESTRICTED
#undef _POSIX_NO_TRUNC
#undef _POSIX_VDISABLE
#undef _POSIX_CHOWN_RESTRICTED
#undef _POSIX_NO_TRUNC
#undef _POSIX_VDISABLE
#define _POSIX_SYNC_IO 1
#undef _POSIX_ASYNC_IO
#undef _POSIX_PRIO_IO
#define _POSIX_SYNC_IO 1
#undef _POSIX_ASYNC_IO
#undef _POSIX_PRIO_IO
#define fdatasync(f) fsync(f)