A convict only has one year from the time that the conviction is final to apply for a writ of habeas corpus. This is because of the Antiterrorism and Effective Death Penalty Act of 1996. This rule looks like it is simple, but it's not. Appealing a case tolls the one year period, and deciding when a conviction is really final is sometimes difficult in light of the fact that some appeals courts can choose in their discretion whether or not they are going to hear a case.
After the conviction is final, if the one-year deadline has not passed, the principle of exhaustion of remedies controls which courts will hear a writ application. Generally, if one is convicted in a Texas trial court, one has to apply in the Court of Criminal Appeals, only after that can one then apply in a federal trial court. Contempt judgments and commitments as a sexually violent predator have more steps. State judges, trial and appellate, are politicians, subject to losing elections if they make unpopular rulings. Getting to federal court is where one often gets one's first real chance for relief, since they don't lose their jobs if they make unpopular rulings since they serve for life on good behavior. It means as a practical matter, that it can take years before a defendant can get to a decent forum.