A cockle cylinder works by using a rotating, perforated drum with special indentations to separate grains based on size. Grains smaller than the indents are scooped up, lifted as the cylinder turns, and then fall into a collecting trough to be discharged. Longer grains or impurities remain on the cylinder's surface and slide out a different opening. This process is used for cleaning grains in mills and separating them from impurities like broken pieces, weed seeds, and round seeds.