Advertisement
Guest User

Untitled

a guest
May 9th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
  2. index 49f2f72..92191ca 100644
  3. --- a/src/thread/pthread_create.c
  4. +++ b/src/thread/pthread_create.c
  5. @@ -132,8 +132,11 @@ static int start(void *p)
  6. {
  7. pthread_t self = p;
  8. if (self->startlock[0]) {
  9. - __wait(self->startlock, 0, 1, 1);
  10. - if (self->startlock[0]) {
  11. + if (self->startlock[0] == 1) {
  12. + __wait(self->startlock, 0, 1, 1);
  13. + }
  14. +
  15. + if (self->startlock[0] == 2) {
  16. self->detached = 2;
  17. pthread_exit(0);
  18. }
  19. @@ -295,7 +298,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
  20. if (do_sched) {
  21. ret = __syscall(SYS_sched_setscheduler, new->tid,
  22. attr._a_policy, &attr._a_prio);
  23. - a_store(new->startlock, ret<0 ? 2 : 0);
  24. + a_store(new->startlock, ret<0 ? 2 : 3);
  25. __wake(new->startlock, 1, 1);
  26. if (ret < 0) return -ret;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement