bigsys-gnu / mvcc-os

KhronOS, a scalable operating systems based on sv6 (MIT) with MV-RLU (multi-version concurrency control mechanism)
Other
1 stars 0 forks source link

wrong usage of mutex lock in thread lib (ulib.c) #18

Closed MadPlayer closed 3 years ago

MadPlayer commented 3 years ago
int
thread_create(void (*start_routine)(void*), void *arg)
{
    lock_t lk;
    lock_init(&lk);
    lock_acquire(&lk);
    void *stack= malloc(PGSIZE*2);
    lock_release(&lk);

    if((uint)stack % PGSIZE)
        stack = stack + (PGSIZE - (uint)stack % PGSIZE);

    int result = clone(start_routine,arg,stack);
    return result;
}

int thread_join(){
    void *stack = malloc(sizeof(void*));
    int result= join(&stack);

    lock_t lk;
    lock_init(&lk);
    lock_acquire(&lk);
    free(stack);
    lock_release(&lk);

    return result;
}

여기에 보시면 mutex lock을 사용하려고 시도는 하지만 구현할 적절한 방법을 찾지못한 것으로 보입니다.

bigsys-gnu commented 3 years ago

그러게요.. lock(lk)변수를 지역변수로 사용하는 부분 말이죠? thread_join( ) 다른 구현 참고할만하게 있는지 볼 필요가 있겠네요.

그리고 어제했던 thread test에서는 join이 문제없이 되죠?