Hi.
I’ve been trying to understand call flow in tcp packet recv/send flow. Particularly, I’m stuck on how threads work in Haiku kernel. In posix terms, I kinda understand threads but the syntax here is obviously different making it a lil confusing for me.
Here’s what I understand:
NIC —> rx_queue
NIC —> interrupt —> tcp_read_data → TCPEndpoint::ReadData
Now ReadData
and works as per TCP RFC which says that we can wait till buffer is full before sending the data up to userspace. But how it does from code is where I have some doubts.
First call reaches here: _WaitForCondition
From going into its definitions, looks like this kernel thread is blocked until condition finishes. If this is correct, does scheduler context switch to a different thread?
Then call goes below (pasting the code directly):
Here, NotifyAll
presumably notifies other threads that queue is full. Does that mean we have multiple kernel threads working on ReadData/SendData flow?
if (numBytes < fReceiveQueue.Available())
fReceiveCondition.NotifyAll();
If there are articles on threads/scheduler, that would be helpful!