Generators of the ring of sections of a line bundle This is probably a really simple question, but I never really studied classical algebraic geometry, and so I don't know where to start looking. 
Suppose $X$ is a smooth projective algebraic curve over a field $k$, and $\mathcal{L}$ a line bundle on $X$. Then I can consider the graded ring of sections $R(\mathcal{L}) = \bigoplus_{n \ge 0}H^0(X, \mathcal{L}^{\otimes n})$. How can I determine (in terms of $\mathcal{L}$) an $N$ such that $R(\mathcal{L})$ is generated as a $k$-algebra by elements of degree $\le N$?
Also, what if $X$ is a smooth proper curve over $\mathbb{Z}_p$, and we ask instead for $\mathbb{Z}_p$-generators of the ring of sections?
 A: First consider the case $X$ is a projective smooth curve of genus $g$ over $k$. 


*

*If $\deg\mathcal L<0$, then $R(\mathcal L)=H^0(X, O_X)$, and $N=0$ suits. 

*If $\deg\mathcal L=0$, then $H^0(X, \mathcal L^n)\ne 0$ iff $\mathcal L^n\simeq O_X$. So we can take $N=d$ if $\mathcal L\in \mathrm{Pic}(X)$ has finite order $d$, and $N=0$ otherwise. 
Suppose from now on that $\deg\mathcal L>0$. Then there exists $a>0$ such that $\mathcal L^a\simeq O_X(D)$ for some effective divisor $D>0$ on $X$. It is enough to take $a\ge 2g/\deg\mathcal L$ by Riemann-Roch. 
There exists $b>0$ such that $H^1(X, \mathcal L^n)=0$ for all $n\ge b$. Again by Riemann-Roch, it is enough to have $b\ge (2g-1)/\deg \mathcal L$. 
For any $n\ge a+b$, the exact sequence 
$$ 0\to \mathcal L^{n-a}\to \mathcal L^n\to \mathcal L^n|_D \to 0$$ 
implies the exact sequence 
$$ 0 \to H^0(X, \mathcal L^{n-a})\to H^0(X, \mathcal L^n)\to H^0(D,\mathcal L^n|_D)\to 0.$$
Let $n\ge 2(a+b)$ and write $n=q(a+b)+r$ with $a+b\le r\le 2(a+b)-1$. Then 
$$\mathcal L^n|_D= (\mathcal L^{a+b}|_D)^q\otimes (\mathcal L^r|_D).$$ 
As $D$ is affine, 
$$H^0(D, \mathcal L^n|_D)= (H^0(D, \mathcal L^{a+b}|_D))^q\otimes H^0(D, \mathcal L^r|_D).$$ 
Hence 
$$H^0(X, \mathcal L^{a+b})^q \otimes H^0(X, \mathcal L^r) \to H^0(D,\mathcal L^n|_D)$$ 
is surjective. If $N=2(a+b)-1$ and $V$ is the sum of the $H^0(\mathcal L^m)$ for $m\le N$,  then 
$$H^0(X,\mathcal L^n)\subseteq H^0(X,\mathcal L^{n-a})+k[V].$$
By induction on $n\ge 2(a+b)$, we see that $R(\mathcal L)$ is equal to $k[V]$.  
Edit Add some more details and simply a little bit below. 
Now we pass to the relative situation. Replace $k$ with a Noetherian local ring $A$ and denote by $s$ the closed point of $S:=\mathrm{Spec}A$. The fibers of $X\to S$ all have the same genus $g$. Suppose again $\deg \mathcal L_s>0$. Then the above choice of $a, b$ implies that $H^1(X_s, \mathcal L_s^b)=0$, hence  $H^1(X_t, \mathcal L_t^b)=0$ for all $t\in S$ (use the fact that $\deg \mathcal L_t$ is independent on $t$ or Hartshorne, Theorem III.12.11(a)), hence 
$$H^0(X, \mathcal L^b)\otimes_A k(s)\to H^0(X_s, \mathcal L_s^b)$$
is an isomorphism (Mumford, Abelian Varieties, page 53, Corollary 3 with $p=1$). And the same holds for $\mathcal L^a$. Let $N=2(a+b)-1$ and let $V$ be defined as above for $\mathcal L$. Then by the above isomorphism, Nakayama and the computations over $X_s$, we get 
$$ H^0(X,\mathcal L^n)\subseteq H^0(X,\mathcal L^{n-a})+A[V]$$
for $n>N$. Therefore $R(\mathcal L)$ is generated by $A[V]$.  
