"manish.mishra" <manish.mishra@nutanix.com> wrote:
On 26/04/23 4:35 pm, Juan Quintela wrote:
"manish.mishra" <manish.mishra@nutanix.com> wrote:
On 26/04/23 3:58 pm, Juan Quintela wrote:
Before:
while (true) {
....
sem_post(channels_ready)
}
And you want to add to the initialization a counter equal to the number
of channels.
Now:
while (true) {
sem_post(channels_ready)
....
}
It is semantically the same, but when we setup it ready it means that
when we set it to 1, we now that the channel and thread are ready for
action.
May be we can do one thing let the sem_post in while loop at same
position itself. But we can do another post just before start
I can see how this can make any difference.
of this while loop, as that will be called only once it should do work
of initialising count equal to multiFD channels?
Yeap. But I can see what difference do we have here.
Later, Juan.
Thanks Juan,
Just confirming if i misunderstood something :)
I meant your approach makes sense, i was just suggesting a small change. To do
something like this.
qemu_sem_init(&multifd_send_state->channels_ready, 0);
static void *multifd_send_thread(void *opaque) {
...
sem_post(channels_ready); // Post once at start of thread and let one in
loop as it is.
while (true) {
....
sem_post(channels_ready)
}
}
Something like below has issue that we are marking channel_ready even
before channel is actually ready,
I think it is exactly the same.
i meant if network is slow it may
take some time to update pending_job and hence we can busy loop in
send_multifd_page().
No difference from send_multifd_page() point of view.
Notice that I mank that the channel is ready before I do any work.
send_multifd_page() does a sem_wait() before doing anything related to
this channel, so I can't see how it can be a differnce.
static void *multifd_send_thread(void *opaque) {
...
while (true) {
sem_post(channels_ready);
....
}
}
Not sure if we are already in agreement :) just confirming.
sem_post(channels_ready); // Post once at start of thread and let one in
loop as it is.
while (true) {
...
sem_post(channels_ready)
}
and
while (true) {
sem_post(channels_ready)
...
}
When "..." is exactly the same don't make any difference, the only
difference is that in one case we "write" to semposts, and in the other
we write just one.
Or I am missing something.
Later, Juan.