2. As shown in Figure 1, in the unit square $A B C D$, a semicircle is drawn inside with $A B$ as the diameter. Tangents $C E$ and $D F$ (where $E$ and $F$ are the points of tangency) are drawn from points $C$ and $D$ to the semicircle. Then the length of segment $E F$ is ( ).
(A) $\frac{\sqrt{5}}{3}$
(B) $\frac{3}{5}$
(C) $\frac{\sqrt{3}}{2}$
(D) $\frac{2}{3}$
2. B.

As shown in Figure 6, let the center of the semicircle be $G$, and connect $A E$, $A F$, $B E$, $B F$, and $G F$.

Since $A$, $D$, $F$, and $G$ are concyclic,
$\angle B G F = \angle A D F$.
Thus, $\triangle A D F \sim \triangle B G F$,
$$
\frac{B F}{A F} = \frac{B G}{A D} = \frac{1}{2}.
$$

Let $B F = x$, then $A F = 2x$.
In the right triangle $\triangle A B F$, $x^2 + (2x)^2 = 1$.
Solving this, we get $x^2 = \frac{1}{5}$.
In the isosceles trapezoid $A B F E$, by Ptolemy's theorem,
$$
E F \cdot A B + B F \cdot A E = A F \cdot B E,
$$

which simplifies to $E F + x^2 = (2x)^2$.
Thus, $E F = 3x^2 = \frac{3}{5}$.