XY-System: how cannabis decides its sex
In short
Cannabis has, like humans, an XY system of sex determination. Female plants carry two X chromosomes, males one X and one Y. Because only the father can pass on a Y, the pollen decides the sex of the offspring.
Separate sexes, visible for a century
Cannabis is dioecious, meaning there are separate male and female plants. The sex chromosomes of cannabis and hop were spotted about a hundred years ago because X and Y differ visibly in size. In cannabis the Y is even larger than the X, which is rare among plants.
An unusual detail: the Y is nearly empty
In humans the sex-determining gene sits on the Y. In cannabis it is different. Through its particular inheritance the Y is heavily degenerated and has lost many genes. Newer genome analyses find no clear sex-determining gene on the Y. Instead a candidate gene sits on the X, a gene from the ethylene pathway that steers the development of the female flower. This is why cannabis is said to probably lack an active-Y system.
What that means for the offspring
For practice the rule stays simple. A normal cross of XX by XY gives roughly half female, half male offspring. The Y travels only through the pollen and only to the male offspring. Bring a female plant to form pollen instead, and that pollen carries only X, so all offspring turn out female. This is the basis of feminized seeds.