I'll write $(x, y)$ or $(r, \theta)$ for the coordinates of the point in the operational space, respectively in cartesian or polar coordinates.
First important remark : the map $(\theta_A, \theta_B) \mapsto (x,y)$ shears and then flatten the torus onto the annulus. The shearing part is bijective, and the "flattening" is two-to-one, except on the boundary of the annulus where it is one-to-one. Hence, there will be in general two possible choices of $(\theta_A, \theta_B)$ for any given position of the chalk. If $(\theta_A, \theta_B)$ works, then by symmetry, so does $(2\theta-\theta_A, -\theta_B)$.
To make things a bit clearer, I'll write $a$, $b$ instead of $l_A$, $l_B$.
I - Finding $\theta_B$
By Al-Kashi's theorem (the law of cosine),
$$r^2 = a^2+b^2+2ab\cos(\theta_B).$$
Among the two possible set of parameters for a given position, there is always exactly one with $\theta_B \in [0, \pi]$. I choose to compute this position. Then:
$$\theta_B = \arccos \left( \frac{r^2-a^2-b^2}{2ab} \right),$$
and:
$$\sin(\theta_B) = \frac{\sqrt{(r-a+b)(r+a-b)(a+b-r)(a+b+r)}}{2ab}.$$
I think this formula can also be deduced from the law of sine and Heron's formula for the area. If you choose the other value of $\theta_B$, which lies in $[-\pi, 0]$, then $\sin(\theta_B)$ becomes the opposite of the value above.
II - Finding $\theta_A$
Now, let's develop the equations giving $x$ and $y$:
$$\begin{cases}
x & = & a \cos (\theta_A) + b \cos (\theta_A+\theta_B) \\
y & = & a \sin (\theta_A) + b \sin (\theta_A+\theta_B)
\end{cases}$$
becomes:
$$\begin{cases}
x & = & [a + b \cos (\theta_B)] \cos (\theta_A) - b \sin(\theta_B) \sin(\theta_A) \\
y & = & b \sin (\theta_B) \cos (\theta_A) + [a + b \cos (\theta_B)] \sin (\theta_A)
\end{cases}$$
If we replace $\cos(\theta_B)$ by its expression we found at the beginning, we see that each column has norm $r$. So, by dividing by $r$, we get:
$$\begin{pmatrix}
\cos(\theta) \\ \sin(\theta)
\end{pmatrix}
= \begin{pmatrix}
\frac{a+b\cos(\theta_B)}{r} & -\frac{b \sin(\theta_B)}{r} \\
\frac{b \sin(\theta_B)}{r} & \frac{a+b\cos(\theta_B)}{r}
\end{pmatrix}
\begin{pmatrix}
\cos(\theta_A) \\ \sin(\theta_A)
\end{pmatrix}$$
Since the 2x2 matrix is a rotation matrix, it is enough to transpose it to get its inverse, whence:
$$\begin{pmatrix}
\cos(\theta_A) \\ \sin(\theta_A)
\end{pmatrix}
= \begin{pmatrix}
\frac{a+b\cos(\theta_B)}{r} & \frac{b \sin(\theta_B)}{r} \\
-\frac{b \sin(\theta_B)}{r} & \frac{a+b\cos(\theta_B)}{r}
\end{pmatrix}
\begin{pmatrix}
\cos(\theta) \\ \sin(\theta)
\end{pmatrix}.$$
From here, finding $\theta_A$ is just a matter of computing an angle from its sine and cosine.
III - Parametrization of the circle
If you have an arc in operational space and you want to compute a time-dependent parametrization $(\theta_A, \theta_B) (t)$ which follows the arc you want, all you have to do is to compute pointwise $\theta_B$ and $\theta_A$ with the recipe above. However, it can be quite tedious, especially for the special case where everything can be made explicit.
I won't deal with your arc $p_2$, as I don't have an equation for this curve. That said, let's have a look at $p_1$. It is a circle of radius $a$ and center $(b, 0)$. Since it makes a full turn around the origin, the parameter $\theta_A$ must also make a turn. I'll assume that one can do so monotonically, i.e. one can take $\theta_A (t)= t$. Let $f(t)$ be the value of $\theta_B$ at time $t$. Then:
$$\begin{cases}
x (t) & = & a \cos (t) + b \cos (t+f(t)) \\
y (t) & = & a \sin (t) + b \sin (t+f(t))
\end{cases}$$
But since $(x,y)$ belongs to the circle,
$$(x-b)^2+y^2=a^2$$
Replace $x$ and $y$ by the functions of $t$, develop, simplify a lot, and get:
$$b(1-\cos(f(t)+t)) + a(\cos(f(t))-\cos(t)) = 0,$$
which, with the help of some trigonometric formula, yields:
$$\sin \left(\frac{f(t)+t}{2} \right) \left[ b \sin \left(\frac{f(t)+t}{2} \right) - a \sin \left(\frac{f(t)-t}{2} \right) \right] = 0.$$
The equation above has one obvious solution: $f(t) = -t$. Hence, if you input $(\theta_A, \theta_B) (t) = (t, -t)$, you will draw the curve $p_1$. The second branch is more delicate to compute. By developping the sine, we get:
$$(a+b) \sin \left(\frac{t}{2} \right) \cos \left(\frac{f(t)}{2} \right) = (a-b) \cos \left(\frac{t}{2} \right) \sin \left(\frac{f(t)}{2} \right),$$
whence:
$$\tan \left(\frac{f(t)}{2} \right) = \frac{a+b}{a-b} \tan \left(\frac{t}{2} \right).$$
Finally, we get:
$$f(t) = 2 \arctan \left( \frac{a+b}{a-b} \tan \left(\frac{t}{2} \right) \right),$$
which is well-defined for $t \neq \pi$ (but that is not a problem, as $f(\pi) = \pi$ necessarily).