A model of commodity trading consists of $n$ traders, each bringing to the market his own individual good and each having his own preference for the goods on the market. The trade results in a so-called core allocation, that is, an exchange of goods which cannot be destabilized by a coalition of traders. Shapley and Scarf, who proposed the model, proved the existence of such an exchange by means of an algorithm invented by Gale. The algorithm determines sequentially a cyclic decomposition of the set of traders into trading groups with equally priced goods that satisfies the stability requirement. In this paper the work of the algorithm is studied under an assumption that the traders' individual preferences are independent and uniform. It is shown that the decreasing sequence of the market sizes has the same distribution as a Markov chain $\{\nu_i\}$ on integers in which the next state $\nu'$ is obtained from the current state $\nu$ by randomly mapping $\lbrack\nu\rbrack$ into $\lbrack\nu\rbrack$ and deleting all the cycles. The number of steps of the algorithm is proved to be asymptotically normal with mean and variance both of order $n^{1/2}$.