posix: rename priority in sched_param struct
Priority member in the sched_param struct should be named sched_priority. Fixes #13470 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
40b63e5dc8
commit
04743c9a79
7 changed files with 23 additions and 22 deletions
|
@ -21,7 +21,7 @@ extern "C" {
|
||||||
#endif /* SCHED_RR */
|
#endif /* SCHED_RR */
|
||||||
|
|
||||||
struct sched_param {
|
struct sched_param {
|
||||||
int priority;
|
int sched_priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -84,7 +84,7 @@ static s32_t posix_to_zephyr_priority(u32_t priority, int policy)
|
||||||
int pthread_attr_setschedparam(pthread_attr_t *attr,
|
int pthread_attr_setschedparam(pthread_attr_t *attr,
|
||||||
const struct sched_param *schedparam)
|
const struct sched_param *schedparam)
|
||||||
{
|
{
|
||||||
int priority = schedparam->priority;
|
int priority = schedparam->sched_priority;
|
||||||
|
|
||||||
if ((attr == NULL) || (attr->initialized == 0) ||
|
if ((attr == NULL) || (attr->initialized == 0) ||
|
||||||
(is_posix_prio_valid(priority, attr->schedpolicy) == false)) {
|
(is_posix_prio_valid(priority, attr->schedpolicy) == false)) {
|
||||||
|
@ -262,7 +262,7 @@ int pthread_setschedparam(pthread_t pthread, int policy,
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_prio = posix_to_zephyr_priority(param->priority, policy);
|
new_prio = posix_to_zephyr_priority(param->sched_priority, policy);
|
||||||
|
|
||||||
if (is_posix_prio_valid(new_prio, policy) == false) {
|
if (is_posix_prio_valid(new_prio, policy) == false) {
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
@ -306,7 +306,7 @@ int pthread_getschedparam(pthread_t pthread, int *policy,
|
||||||
|
|
||||||
priority = k_thread_priority_get((k_tid_t) thread);
|
priority = k_thread_priority_get((k_tid_t) thread);
|
||||||
|
|
||||||
param->priority = zephyr_to_posix_priority(priority, policy);
|
param->sched_priority = zephyr_to_posix_priority(priority, policy);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ int pthread_attr_getschedparam(const pthread_attr_t *attr,
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
schedparam->priority = attr->priority;
|
schedparam->sched_priority = attr->priority;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ void test_posix_normal_mutex(void)
|
||||||
int schedpolicy = SCHED_FIFO;
|
int schedpolicy = SCHED_FIFO;
|
||||||
int ret, type, protocol, temp;
|
int ret, type, protocol, temp;
|
||||||
|
|
||||||
schedparam.priority = 2;
|
schedparam.sched_priority = 2;
|
||||||
ret = pthread_attr_init(&attr);
|
ret = pthread_attr_init(&attr);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
zassert_false(pthread_attr_destroy(&attr),
|
zassert_false(pthread_attr_destroy(&attr),
|
||||||
|
@ -126,7 +126,7 @@ void test_posix_recursive_mutex(void)
|
||||||
int schedpolicy = SCHED_FIFO;
|
int schedpolicy = SCHED_FIFO;
|
||||||
int ret, type, protocol, temp;
|
int ret, type, protocol, temp;
|
||||||
|
|
||||||
schedparam2.priority = 2;
|
schedparam2.sched_priority = 2;
|
||||||
ret = pthread_attr_init(&attr2);
|
ret = pthread_attr_init(&attr2);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
zassert_false(pthread_attr_destroy(&attr2),
|
zassert_false(pthread_attr_destroy(&attr2),
|
||||||
|
|
|
@ -22,7 +22,7 @@ static void *thread_top(void *p1)
|
||||||
pthread = (pthread_t) pthread_self();
|
pthread = (pthread_t) pthread_self();
|
||||||
pthread_getschedparam(pthread, &policy, ¶m);
|
pthread_getschedparam(pthread, &policy, ¶m);
|
||||||
printk("Thread %d scheduling policy = %d & priority %d started\n",
|
printk("Thread %d scheduling policy = %d & priority %d started\n",
|
||||||
(s32_t) p1, policy, param.priority);
|
(s32_t) p1, policy, param.sched_priority);
|
||||||
|
|
||||||
ret = pthread_rwlock_tryrdlock(&rwlock);
|
ret = pthread_rwlock_tryrdlock(&rwlock);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -84,7 +84,7 @@ void test_posix_rw_lock(void)
|
||||||
"Unable to create pthread object attrib");
|
"Unable to create pthread object attrib");
|
||||||
|
|
||||||
/* Setting scheduling priority */
|
/* Setting scheduling priority */
|
||||||
schedparam.priority = i + 1;
|
schedparam.sched_priority = i + 1;
|
||||||
pthread_attr_setschedparam(&attr[i], &schedparam);
|
pthread_attr_setschedparam(&attr[i], &schedparam);
|
||||||
|
|
||||||
/* Setting stack */
|
/* Setting stack */
|
||||||
|
|
|
@ -66,7 +66,7 @@ void *thread_top_exec(void *p1)
|
||||||
|
|
||||||
pthread_getschedparam(pthread_self(), &policy, &schedparam);
|
pthread_getschedparam(pthread_self(), &policy, &schedparam);
|
||||||
printk("Thread %d starting with scheduling policy %d & priority %d\n",
|
printk("Thread %d starting with scheduling policy %d & priority %d\n",
|
||||||
id, policy, schedparam.priority);
|
id, policy, schedparam.sched_priority);
|
||||||
/* Try a double-lock here to exercise the failing case of
|
/* Try a double-lock here to exercise the failing case of
|
||||||
* trylock. We don't support RECURSIVE locks, so this is
|
* trylock. We don't support RECURSIVE locks, so this is
|
||||||
* guaranteed to fail.
|
* guaranteed to fail.
|
||||||
|
@ -187,7 +187,7 @@ void *thread_top_term(void *p1)
|
||||||
int val = (u32_t) p1;
|
int val = (u32_t) p1;
|
||||||
struct sched_param param, getschedparam;
|
struct sched_param param, getschedparam;
|
||||||
|
|
||||||
param.priority = N_THR_T - (s32_t) p1;
|
param.sched_priority = N_THR_T - (s32_t) p1;
|
||||||
|
|
||||||
self = pthread_self();
|
self = pthread_self();
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ void *thread_top_term(void *p1)
|
||||||
"Unable to get thread priority!");
|
"Unable to get thread priority!");
|
||||||
|
|
||||||
printk("Thread %d starting with a priority of %d\n", (s32_t) p1,
|
printk("Thread %d starting with a priority of %d\n", (s32_t) p1,
|
||||||
getschedparam.priority);
|
getschedparam.sched_priority);
|
||||||
|
|
||||||
if (val % 2) {
|
if (val % 2) {
|
||||||
ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
|
ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
|
||||||
|
@ -233,13 +233,13 @@ void test_posix_pthread_execution(void)
|
||||||
size_t stacksize;
|
size_t stacksize;
|
||||||
|
|
||||||
sem_init(&main_sem, 0, 1);
|
sem_init(&main_sem, 0, 1);
|
||||||
schedparam.priority = CONFIG_NUM_COOP_PRIORITIES - 1;
|
schedparam.sched_priority = CONFIG_NUM_COOP_PRIORITIES - 1;
|
||||||
min_prio = sched_get_priority_min(schedpolicy);
|
min_prio = sched_get_priority_min(schedpolicy);
|
||||||
max_prio = sched_get_priority_max(schedpolicy);
|
max_prio = sched_get_priority_max(schedpolicy);
|
||||||
|
|
||||||
ret = (min_prio < 0 || max_prio < 0 ||
|
ret = (min_prio < 0 || max_prio < 0 ||
|
||||||
schedparam.priority < min_prio ||
|
schedparam.sched_priority < min_prio ||
|
||||||
schedparam.priority > max_prio);
|
schedparam.sched_priority > max_prio);
|
||||||
|
|
||||||
/* TESTPOINT: Check if scheduling priority is valid */
|
/* TESTPOINT: Check if scheduling priority is valid */
|
||||||
zassert_false(ret,
|
zassert_false(ret,
|
||||||
|
@ -310,8 +310,9 @@ void test_posix_pthread_execution(void)
|
||||||
|
|
||||||
pthread_attr_setschedparam(&attr[i], &schedparam);
|
pthread_attr_setschedparam(&attr[i], &schedparam);
|
||||||
pthread_attr_getschedparam(&attr[i], &getschedparam);
|
pthread_attr_getschedparam(&attr[i], &getschedparam);
|
||||||
zassert_equal(schedparam.priority, getschedparam.priority,
|
zassert_equal(schedparam.sched_priority,
|
||||||
"scheduling priorities do not match!");
|
getschedparam.sched_priority,
|
||||||
|
"scheduling priorities do not match!");
|
||||||
|
|
||||||
ret = pthread_create(&newthread[i], &attr[i], thread_top_exec,
|
ret = pthread_create(&newthread[i], &attr[i], thread_top_exec,
|
||||||
(void *)i);
|
(void *)i);
|
||||||
|
@ -372,7 +373,7 @@ void test_posix_pthread_termination(void)
|
||||||
PTHREAD_CREATE_DETACHED);
|
PTHREAD_CREATE_DETACHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
schedparam.priority = 2;
|
schedparam.sched_priority = 2;
|
||||||
pthread_attr_setschedparam(&attr[i], &schedparam);
|
pthread_attr_setschedparam(&attr[i], &schedparam);
|
||||||
pthread_attr_setstack(&attr[i], &stack_t[i][0], STACKS);
|
pthread_attr_setstack(&attr[i], &stack_t[i][0], STACKS);
|
||||||
ret = pthread_create(&newthread[i], &attr[i], thread_top_term,
|
ret = pthread_create(&newthread[i], &attr[i], thread_top_term,
|
||||||
|
@ -390,7 +391,7 @@ void test_posix_pthread_termination(void)
|
||||||
zassert_equal(ret, EINVAL, "invalid policy set!");
|
zassert_equal(ret, EINVAL, "invalid policy set!");
|
||||||
|
|
||||||
/* TESTPOINT: Try setting invalid priority */
|
/* TESTPOINT: Try setting invalid priority */
|
||||||
schedparam.priority = PRIO_INVALID;
|
schedparam.sched_priority = PRIO_INVALID;
|
||||||
ret = pthread_setschedparam(newthread[0], SCHED_RR, &schedparam);
|
ret = pthread_setschedparam(newthread[0], SCHED_RR, &schedparam);
|
||||||
zassert_equal(ret, EINVAL, "invalid priority set!");
|
zassert_equal(ret, EINVAL, "invalid priority set!");
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ void test_posix_multiple_threads_single_key(void)
|
||||||
"Unable to create pthread object attr");
|
"Unable to create pthread object attr");
|
||||||
}
|
}
|
||||||
|
|
||||||
schedparam.priority = 2;
|
schedparam.sched_priority = 2;
|
||||||
pthread_attr_setschedparam(&attr[i], &schedparam);
|
pthread_attr_setschedparam(&attr[i], &schedparam);
|
||||||
pthread_attr_setstack(&attr[i], &stackp[i][0], STACKSZ);
|
pthread_attr_setstack(&attr[i], &stackp[i][0], STACKSZ);
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ void test_posix_single_thread_multiple_keys(void)
|
||||||
"Unable to create pthread object attr");
|
"Unable to create pthread object attr");
|
||||||
}
|
}
|
||||||
|
|
||||||
schedparam.priority = 2;
|
schedparam.sched_priority = 2;
|
||||||
pthread_attr_setschedparam(&attr, &schedparam);
|
pthread_attr_setschedparam(&attr, &schedparam);
|
||||||
pthread_attr_setstack(&attr, &stackp[0][0], STACKSZ);
|
pthread_attr_setstack(&attr, &stackp[0][0], STACKSZ);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ void initialize_thread_attr(pthread_attr_t *attr)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
schedparam.priority = 1;
|
schedparam.sched_priority = 1;
|
||||||
|
|
||||||
ret = pthread_attr_init(attr);
|
ret = pthread_attr_init(attr);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue