Skip to content

solve virtio_inject_irq's concurrency issue#70

Merged
KouweiLee merged 2 commits intosyswonder:mainfrom
liulog:main
Jan 20, 2026
Merged

solve virtio_inject_irq's concurrency issue#70
KouweiLee merged 2 commits intosyswonder:mainfrom
liulog:main

Conversation

@liulog
Copy link
Contributor

@liulog liulog commented Jan 20, 2026

Related to #68.

void virtio_inject_irq(VirtQueue *vq) {
    ......
    pthread_mutex_lock(&RES_MUTEX);
    while (is_queue_full(virtio_bridge->res_front,
                         virtio_bridge->res_rear,
                         MAX_REQ)) {
    }
    ......
    pthread_mutex_unlock(&RES_MUTEX);
    ......
}

When multiple threads arrive simultaneously, the thread that acquires the lock is given priority.

It continuously polls is_queue_full rather than having multiple threads fairly contend for the lock continuously.

This logic is sound here.

Given that access to the critical section is exclusive to this location, it is acceptable for the lock to be held for long durations.

@liulog liulog requested a review from KouweiLee January 20, 2026 10:30
Copy link
Collaborator

@KouweiLee KouweiLee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close #68

@KouweiLee KouweiLee merged commit 1c2729f into syswonder:main Jan 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants