Daniel B. answered 05/23/21
PhD in Computer Science with 42 years in Computer Research
In general, a "race condition" refers to any situation where the result of a computation
depends on relative speed of processes.
I suspect that your question is about a special kind of race condition -- starvation.
That would occur if a process kept requesting a connection and was always denied because
some other process always happed to jump in and get the last available connection.
TCP/IP avoids starvation by never denying a request; if a process requests a connection
when none is available, then the process is blocked and placed on a queue.
Connections are then assigned to processes pulled off the queue in FIFO fashion.
This works as long as there is enough memory for the queue.
This does not prevent all race conditions.
Depending on relative speed of processes they can get a connection in different order.
That order may become observable if the two processes update the same file.
If that is not desirable, then this race condition is to be solved on the algorithmic level,
rather than on the operation system level.
There is another solution to starvation based on delay with exponential decay.
That has the advantage as not requiring a queue, but is applicable only for a fix set of processes, and is normally not used in operating systems.