/* Set thread scheduling policy and parameters. 
See IEEE 1003.1  */
int pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param)
/* Set thread scheduling policy and parameters. 
See IEEE 1003.1  */
int pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param)
{
	int ret = 0;
	int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO;
	struct posix_thread *t = NULL;
	if (param == NULL || !valid_posix_policy(policy) ||
	    !is_posix_policy_prio_valid(param->sched_priority, policy)) {
		return EINVAL;
	}
	K_SPINLOCK(&pthread_pool_lock) {
		t = to_posix_thread(pthread);
		if (t == NULL) {
			ret = ESRCH;
			K_SPINLOCK_BREAK;
		}
		new_prio = posix_to_zephyr_priority(param->sched_priority, policy);
	}
	if (ret == 0) {
		k_thread_priority_set(&t->thread, new_prio);
	}
	return ret;
}