/* * Validate the signal number and thread. If valid process the signal. */ int pthread_kill(pthread_t pthread, int sig) { int ret; if (sig >= 0 && sig < NSIG) { ret = _find_thread(pthread); if (ret == 0 && sig != 0) { if (_thread_sigact[sig - 1].sa_handler != SIG_IGN) { _thread_kern_sig_defer(); if (pthread->state == PS_SIGWAIT && sigismember(pthread->data.sigwait, sig)) { PTHREAD_NEW_STATE(pthread,PS_RUNNING); pthread->signo = sig; } else { _thread_kill_siginfo(sig); _thread_signal(pthread,sig); } _thread_kern_sig_undefer(); } } } else ret = EINVAL; return ret; }
int _pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param) { int ret; if ((param == NULL) || (policy == NULL)) /* Return an invalid argument error: */ ret = EINVAL; /* Find the thread in the list of active threads: */ else if ((ret = _find_thread(pthread)) == 0) { /* Return the threads base priority and scheduling policy: */ param->sched_priority = PTHREAD_BASE_PRIORITY(pthread->base_priority); *policy = pthread->attr.sched_policy; } return(ret); }
int _pthread_attr_get_np(pthread_t pid, pthread_attr_t *dst) { int ret; if (pid == NULL || dst == NULL || *dst == NULL) return (EINVAL); if ((ret = _find_thread(pid)) != 0) return (ret); memcpy(*dst, &pid->attr, sizeof(struct pthread_attr)); /* * Special case, if stack address was not provided by caller * of pthread_create(), then return address allocated internally */ if ((*dst)->stackaddr_attr == NULL) (*dst)->stackaddr_attr = pid->stack; return (0); }