CA Penal Code § 1381 (2021)
2021 California Code|Penal Code - PEN|PART 2 - OF CRIMINAL PROCEDURE|TITLE 10 - MISCELLANEOUS PROCEEDINGS|CHAPTER 8 - Dismissal of the Action for Want of Prosecution or Otherwise|Section 1381.

1381.  Whenever a defendant has been convicted, in any court of this state, of the commission of a felony or misdemeanor and has been sentenced to and has entered upon a term of imprisonment in a state prison or has been sentenced to and has entered upon a term of imprisonment in a county jail for a period of more than 90 days or has been committed to and placed in a county jail for more than 90 days as a condition of probation or has been committed to and placed in an institution subject to the jurisdiction of the Department of the Youth Authority or whenever any person has been committed to the custody of the Director of Corrections pursuant to Chapter 1 (commencing with Section 3000) of Division 3 of the Welfare and Institutions Code and has entered upon his or her term of commitment, and at the time of the entry upon the term of imprisonment or commitment there is pending, in any court of this state, any other indictment, information, complaint, or any criminal proceeding wherein the defendant remains to be sentenced, the district attorney of the county in which the matters are pending shall bring the defendant to trial or for sentencing within 90 days after the person shall have delivered to said district attorney written notice of the place of his or her imprisonment or commitment and his or her desire to be brought to trial or for sentencing unless a continuance beyond the 90 days is requested or consented to by the person, in open court, and the request or consent entered upon the minutes of the court in which event the 90-day period shall commence to run anew from the date to which the consent or request continued the trial or sentencing. In the event that the defendant is not brought to trial or for sentencing within the 90 days the court in which the charge or sentencing is pending shall, on motion or suggestion of the district attorney, or of the defendant or person confined in the county jail or committed to the custody of the Director of Corrections or his or her counsel, or of the Department of Corrections, or of the Department of the Youth Authority, or on its own motion, dismiss the action. If a charge is filed against a person during the time the person is serving a sentence in any state prison or county jail of this state or while detained by the Director of Corrections pursuant to Chapter 1 (commencing with Section 3000) of Division 3 of the Welfare and Institutions Code or while detained in any institution subject to the jurisdiction of the Department of the Youth Authority it is hereby made mandatory upon the district attorney of the county in which the charge is filed to bring it to trial within 90 days after the person shall have delivered to said district attorney written notice of the place of his or her imprisonment or commitment and his or her desire to be brought to trial upon the charge, unless a continuance is requested or consented to by the person, in open court, and the request or consent entered upon the minutes of the court, in which event the 90-day period shall commence to run anew from the date to which the request or consent continued the trial. In the event the action is not brought to trial within the 90 days the court in which the action is pending shall, on motion or suggestion of the district attorney, or of the defendant or person committed to the custody of the Director of Corrections or to a county jail or his or her counsel, or of the Department of Corrections, or of the Department of the Youth Authority, or on its own motion, dismiss the charge. The sheriff, custodian, or jailer shall endorse upon the written notice of the defendant’s desire to be brought to trial or for sentencing the cause of commitment, the date of commitment, and the date of release.(Amended by Stats. 1987, Ch. 828, Sec. 91.)