In this paper, we show that the “most regular” word in the language formed by all the words containing a fixed number of each letter of an alphabet gives the optimal resource allocation policy of the generic system composed by two processes sharing a resource. This system will be modeled as a Petri net to derive the proof of this result which is partially generalized to non periodic allocation sequences and non rational frequencies. For N processes sharing a resource, we show that a strongly optimal sequence may not exist. In this case, we give an heuristic to find a good allocation sequence which relates to regular words in higher dimensions.