-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
solvedQuestion solvedQuestion solved
Description
안녕하세요,
if (server_ctx.list.head == NULL) return NULL;
pthread_mutex_lock(&server_ctx.lock);
target_node = server_ctx.list.head;
if (server_ctx.list.head == server_ctx.list.tail) {
server_ctx.list.head = NULL;
server_ctx.list.tail = NULL;
} else {
server_ctx.list.head = server_ctx.list.head->next;
}
server_ctx.list.count--;
pthread_mutex_unlock(&server_ctx.lock);
mcdonalds.c의 get_order()가 이렇게 구현되어 있는 상황인데, 이런 구현 하에서 list의 node가 하나 있고 thread가 두 개 있을 때,thread 1에서 list.head == NULL이 아님을 확인하고 context switch가 이루어져 thread 2에서 get_order()가 이루어지고 다시 thread1으로 context switch되는 경우 list.count가 -1이 되는 문제가 존재하는 것 같아 issue드립니다!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
solvedQuestion solvedQuestion solved