testing: getprime: Introduce configurable thread priority
Summary: - This commit introduces configurable thread priority - Also, thread policy is set based on RR_INTERVAL Impact: - getprime only Testing: - Tested with spresense:wifi_smp Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
parent
c4bcd8254a
commit
faaec6513c
@ -27,4 +27,8 @@ config TESTING_GETPRIME_STACKSIZE
|
||||
int "getprime stack size"
|
||||
default DEFAULT_TASK_STACKSIZE
|
||||
|
||||
config TESTING_GETPRIME_THREAD_PRIORITY
|
||||
int "getprime thread priority"
|
||||
default 10
|
||||
|
||||
endif
|
||||
|
@ -111,7 +111,6 @@ static FAR void *thread_func(FAR void *param)
|
||||
static void get_prime_in_parallel(int n)
|
||||
{
|
||||
pthread_t thread[MAX_THREADS];
|
||||
struct sched_param sparam;
|
||||
pthread_attr_t attr;
|
||||
pthread_addr_t result;
|
||||
int status;
|
||||
@ -120,16 +119,24 @@ static void get_prime_in_parallel(int n)
|
||||
status = pthread_attr_init(&attr);
|
||||
ASSERT(status == OK);
|
||||
|
||||
sparam.sched_priority = sched_get_priority_min(SCHED_FIFO);
|
||||
struct sched_param sparam;
|
||||
sparam.sched_priority = CONFIG_TESTING_GETPRIME_THREAD_PRIORITY;
|
||||
status = pthread_attr_setschedparam(&attr, &sparam);
|
||||
ASSERT(status == OK);
|
||||
|
||||
printf("Set thread priority to %d\n", sparam.sched_priority);
|
||||
|
||||
#if CONFIG_RR_INTERVAL > 0
|
||||
status = pthread_attr_setschedpolicy(&attr, SCHED_RR);
|
||||
ASSERT(status == OK);
|
||||
|
||||
printf("Set thread policy to SCHED_RR \n");
|
||||
#else
|
||||
status = pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
|
||||
ASSERT(status == OK);
|
||||
|
||||
printf("Set thread policy to SCHED_FIFO \n");
|
||||
#endif
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user