- pthread_t self = p;
- if (self->startlock[0]) {
- __wait(self->startlock, 0, 1, 1);
- if (self->startlock[0]) {
- self->detached = 2;
- pthread_exit(0);
+ struct start_args *args = p;
+ if (args->attr) {
+ pthread_t self = __pthread_self();
+ int ret = -__syscall(SYS_sched_setscheduler, self->tid,
+ args->attr->_a_policy, &args->attr->_a_prio);
+ if (a_swap(args->perr, ret)==-2)
+ __wake(args->perr, 1, 1);
+ if (ret) {
+ self->detach_state = DT_DYNAMIC;
+ __pthread_exit(0);